



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




1
Question 1:
Consider a program P and its control flow graph G = (B,E) where B = {bb 1 , bb2 , bb 3 , …, bbk } is a set of basic blocks and E! B x B is a set of directed edges between the basic blocks. Let the set I = {i 1 , i 2 , i 2 , …, i (^) n} be the set of valid inputs to the program.
For the questions below, state true or false and explain:
a. For an edge (bbx , bby ) which is not in the control flow graph, that is (bbx , bby) " E, there is no valid input im#I such that the program follows the edge (bbx , bb (^) y) during its execution.
b. For an edge (bbx , bby) which is in the control flow graph, that is (bbx , bby) # E, for all valid inputs i (^) m#I, the program follows the edge (bbx , bby) during its execution.
c. For an edge (bbx , bby) which is in the control flow graph, that is (bbx , bby) # E, there is some valid input i (^) m#I such that the program follows the edge (bbx , bby) during its execution.
d. For two basic blocks bbx and bby where bbx dominates bb (^) y, for all valid inputs i (^) m#I such that block bb (^) y is executed, the basic block bbx is executed before bby.
e. For two basic blocks bbx and bb (^) y where there is a control flow path from bbx to bb (^) y , all values defined in bb (^) x in reach bb (^) y.
a. Draw the basic block structure and control flow graph for this program.
b. Apply the iterative algorithm to calculate dominator sets and show step by step the dominator set calculation for every basic block.
c. Is the iterative dominator set algorithm guaranteed to converge always? If yes why? If no why?
d. Is the iterative dominator set algorithm guaranteed to yield the correct answer always? If yes why? If no why?
e. Apply the iterative data flow algorithm and for each of the basic blocks (for each of the registers) calculate the IN, OUT, GEN and KILL sets and the reaching definitions.
Question 3:
Consider the control flow graph below
Def a Def b Def c Def d
Def e Use b Use c
Statement 1 Use a Use b Def c
Use a Use b Def d
Def b Use c Def a
Use a
Block 6
An extended basic block (BBB) is a sequence of blocks B 1 , B 2 ,.. ., Bk such that for 1 ≤ i ≤ k, Bi is the only predecessor of Bi+1 and B 1 (called leader of an extended basic block) does not have a unique predecessor. Devise an algorithm which takes CFG as input and generates possible extended basic blocks from it including the leaders. If you have the dominator information available will it be useful to generating EBBs in a more efficient manner? How (give detailed explanation possibly with an example to support your answer)?
A value is partially dead at a given program point if there exists a path on which there is no use of the value before its definition (if any). We would like to find out values which are partially dead at the entrance and exit of each basic block. Formulate this as a dataflow problem and write an algorithm to solve it. Give all details of the framework including seed of the solution, forward/backward problem, unification operator etc.
2