Question: Suppose you are performing control flow analysis on the following code snippet: ( a ) Suppose that we treat each instruction in the code as

Suppose you are performing control flow analysis on the following code snippet:
(a) Suppose that we treat each instruction in the code as a separate node (except goto, whichshouldbeanedge),e.g.,w :=2atline2andx :=3- watline3areseparatenodes. Given these nodes, draw the control flow graph (CFG1) for this code snippet. Note once more that each node in the CFG should represent exactly one statement/instruction in the code snippet. Make sure to also label your nodes with numbers, as you will need to reference them for the next few parts. You can assume that the return block is the exit block. Hint: Not every line has to be a node. Think about how you should handle "else goto xx" appropriately.
(b) List the basic blocks generated from part (a), using as few basic blocks as possible. The basic blocks should be represented as a sequence of line numbers surrounded by curly braces. For example, if node 20-24 form a basic block, then you should include {20,21,22,23,24} in your response. Similarly, if only node 36 forms a basic block, then you should include {36} in your response.
(c) In a CFG, a node x dominates node y if all paths from the entry node to node y include node x. Node x is also referred to as the dominator of node y. List the dominator sets for each node y in your CFG from part (a), where a dominator set is the set of nodes that dominate node y. A dominator set should be represented as a set of node labels (which you added in part (a)) surrounded by curly braces. For example, if nodes r, t, and x dominate node y, then you should include y: {r, t, x} in your response.
(d) In a CFG, a node x strictly dominates node y if all paths from the entry node to node y include node x, and x = y. We define the dominance frontier of a node x as the set of all nodes y in the CFG such that node x dominates an immediate predecessor of node y, but node x does not strictly dominate node y. In other words, the dominance of node x is said to be terminated at its dominance frontier. Given your CFG from part (a), is there any node that has a non-empty dominance frontier? If there is, provide one example of such a node in your CFG by referencing its label, and identify its dominance frontier. The dominance frontier should be represented as a set of node labels surrounded by curly braces. For example, if nodes r, t, and x comprise the dominance frontier of node y, then you should include y: {r, t, x} in your response. If there is no such node, explain why all nodes have an empty dominance frontier.
(e) In a CFG, a back edge is an edge such that the target node dominates the source node. List all back edges in your CFG from part (a). Back edges should be represented as y x, where y represents the label of the source node, and x represents the label of the target node.
Suppose you are performing control flow analysis

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!