Control Flow Ana 1
-
Upload
dilip-thelip -
Category
Documents
-
view
217 -
download
0
Transcript of Control Flow Ana 1
-
7/28/2019 Control Flow Ana 1
1/9
Control Flow Analysis - Part 1
Y.N. Srikant
Department of Computer ScienceIndian Institute of Science
Bangalore 560 012
NPTEL Course on Compiler Design
Y.N. Srikant Control Flow Analysis
http://find/http://goback/ -
7/28/2019 Control Flow Ana 1
2/9
Outline of the Lecture
Why control ow analysis?Dominators and natural loops
Intervals and reducibilityT 1 T 2 transformations and graph reductionRegions
Y.N. Srikant Control Flow Analysis
http://goforward/http://find/http://goback/ -
7/28/2019 Control Flow Ana 1
3/9
Why Control-Flow Analysis?
Control-ow analysis (CFA) helps us to understand thestructure of control-ow graphs (CFG)To determine the loop structure of CFGsFormulation of conditions for code motion use dominator
information, which is obtained by CFAConstruction of the static single assignment form (SSA)requires dominance frontier information from CFAIt is possible to use interval structure obtained from CFA tocarry out data-ow analysisFinding Control dependence, which is needed inparallelization, requires CFA
Y.N. Srikant Control Flow Analysis
http://find/ -
7/28/2019 Control Flow Ana 1
4/9
Dominators
We say that a node d in a ow graph dominates node n ,
written d dom n , if every path from the initial node of theow graph to n goes through d Initial node is the root, and each node dominates only itsdescendents in the tree (including itself)The node x strictly dominates y , if x dominates y andx = y x is the immediate dominator of y (denoted idom (y )), if x is the closest strict dominator of y A dominator tree shows all the immediate dominatorrelationshipsPrinciple of the dominator algorithm
If p 1 , p 2 , ..., p k , are all the predecessors of n , and d = n ,then d dom n , iff d dom p i for each i
Y.N. Srikant Control Flow Analysis
http://find/http://goback/ -
7/28/2019 Control Flow Ana 1
5/9
An Algorithm for nding Dominators
D (n ) = OUT [n ] for all n in N (the set of nodes in the owgraph), after the following algorithm terminates{ /*n 0 = initial node; N = set of all nodes; */
OUT [n 0] = {n 0};for n in N { n 0} do OUT [n ] = N ;
while (changes to any OUT [n ] or IN [n ] occur ) dofor n in N { n 0} do
IN [n ] =P a predecessor of n
OUT [P ];
OUT [n ] = {n } IN [n ]
}
Y.N. Srikant Control Flow Analysis
http://find/ -
7/28/2019 Control Flow Ana 1
6/9
Dominator Example
Y.N. Srikant Control Flow Analysis
http://find/ -
7/28/2019 Control Flow Ana 1
7/9
Dominators, Back Edges, and Natural Loops
Y.N. Srikant Control Flow Analysis
http://find/http://goback/ -
7/28/2019 Control Flow Ana 1
8/9
Dominators, Back Edges, and Natural Loops
Y.N. Srikant Control Flow Analysis
http://find/ -
7/28/2019 Control Flow Ana 1
9/9
Dominators and Natural Loops
Edges whose heads dominate their tails are called back edges (a b : b = head , a = tail )Given a back edge n d
The natural loop of the edge is d plus the set of nodes thatcan reach n without going through d d is the header of the loop
A single entry point to the loop that dominates all nodes inthe loopAtleast one path back to the header exists (so that the loop
can be iterated)
Y.N. Srikant Control Flow Analysis
http://find/