Dominators Global Data Flow Analysis
Dominators Global Data Flow Analysis
3. Transitive
a DOM b and b DOM c implies that a DOM c
• The rule (1) says that a definition d reaches the end of the block B
if and only if either
i. d is in IN[B], i.e d reaches the beginning of B and is not killed by B ,
or
ii. d is generated within B i.e., it appears in B and its identifier is not
subsequently redefined within B.
• The rule (2) says that a definition reaches the beginning of the
block B if and only if it reaches the end of one of its predecessors.
Input: A flow graph for which GEN[B] and KILL[B] have been
computed for each block B.
A flow Graph
For block B1 :
NEWIN=OUT[B2] , since B2 is the only predecessor of B1
NEWIN=GEN[B2]=00100 = IN[B1] IN [ B] KILL[ B]
OUT[B1] = IN[B1] – KILL[B1] + GEN[B1] 00100
= 00100 – 00111 + 11000 11000
00000
= 11000
For block B2 :
NEWIN=OUT[B1] + OUT[B5] , since B1 and B5 are the predecessor of B2
IN[B2] = 11000 + 00000 = 11000
OUT[B2] = IN[B2] – KILL[B2] + GEN[B2]
= 11000 – 10000 + 00100
= 01100
Pass-2 Pass-3
Block B IN[B] OUT[B] Block B IN[B] OUT[B]
B1 01100 11000 B1 01111 11000
B2 11111 01111 B2 11111 01111
B3 01111 00110 B3 01111 00110
B4 00110 00101 B4 00110 00101
B5 00111 00111 B5 00111 00111
Friday, April 8, 2022 SCS1303 Compiler Design 27
Computing ud-chains
• From reaching definitions information we can compute ud-
chains.
• If a use of variable A is preceded in its block by a definition of
A, then only the last definition of A in the block prior to this
use reaches the use.
– i.e. ud-chain for this use contains only one definition.
• If a use of A is preceded in its block B by no definition of A,
then the ud-chain for this use consists of all definitions of A in
IN[B].
• Since ud-chain take up much space, it is important for an
optimizing compiler to format them compactly.