



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!




CS6241 Homework 1 Due: Mon, Feb 7 by 6pm
Guidelines:
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 , bb (^) y ) 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 , bby) during its execution.
b. For an edge (bbx , bby) which is in the control flow graph, that is (bb (^) x , 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 bby 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 bbx 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