Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Data Flow Analysis 2 - Lecture Slides | CMSC 430, Study notes of Computer Science

Material Type: Notes; Professor: Tseng; Class: INTRO TO COMPILERS; Subject: Computer Science; University: University of Maryland; Term: Spring 2009;

Typology: Study notes

Pre 2010

Uploaded on 07/30/2009

koofers-user-vq8
koofers-user-vq8 🇺🇸

10 documents

1 / 5

Toggle sidebar

Related documents


Partial preview of the text

Download Data Flow Analysis 2 - Lecture Slides | CMSC 430 and more Study notes Computer Science in PDF only on Docsity! 1 Dataflow Analysis 2 CS430 2 Data-flow Analysis • Algorithm 1. Find basic blocks, build CFG 2. Find propagation functions for basic blocks 3. Propagate information around CFG 4. Propagate information into basic blocks • Example Code Control flow graph (CFG) CS430 3 Live Variables LV(B) = ∪ ( GEN(Bi) ∪ [ LV(Bi) - KILL(Bi) ] ) Bi ε SUCC(B) GEN(Bi) : All uses in Bi that are not killed by preceding definitions in Bi KILL(Bi): All uses of variables x that are defined in Bi A use of a variable x is a statement where the value of x may be read. A use of variable x is killed if x is reassigned a value; the “killing” definition must occur. CS430 4 Live Variables • Universe of facts? → All possible subsets of variables in the program • GEN and KILL sets for each basic block? → GEN = variables used in basic block AND not killed before reaching beginning of basic block → KILL = variables defined in basic block • Initial values of LV(B) before propagation starts? → All variables in the program  Assumes variable is live until proven otherwise  The conservative assumption CS430 5 Live Variables Example = x B2: B3: B4: B1: = x B4 B3 B2 B1 KILLGEN Basic Block LV(B) = ∪ ( GEN(Bi) ∪ [LV(Bi) - KILL(Bi) ] ) Bi ε SUCC(B) x = x = CS430 6 Available Expressions An expression e is defined if its value is computed. An expression e is killed if the values of any of its operands may have been changed. AVAIL(B) = ∩ ( GEN(Bi) ∪ [ AVAIL(Bi) - KILL(Bi) ] ) Bi ε PRED(B) GEN(Bi) : All definitions of expressions in Bi that are not subsequently killed in Bi KILL(Bi): All expressions with operand variables defined in Bi 2 CS430 7 Available Expressions • Universe of facts? → All possible subsets of expressions in the program • GEN and KILL sets for each basic block? → GEN = expressions defined in basic block AND operands not defined before reaching end of basic block → KILL = expressions whose operands are defined in basic block • Initial values of AVAIL(B) before propagation starts? → ∅  Assumes expression is not available until proven otherwise  The conservative assumption CS430 8 Available Expressions Example • Control flow graph • Solution • Local information CS430 9 Very Busy Expressions An expression e is defined if its value is used before any definition of its operands. An expression e is killed if the values of any of its operands may have been changed before it is used VBE(B) = ∩ ( GEN(Bi) ∪ [ VBE(Bi) - KILL(Bi) ] ) Bi ε SUCC(B) GEN(Bi) : All definitions of expressions in Bi that are used before they are killed in Bi KILL(Bi): All expressions with operand variables defined in Bi CS430 10 Very Busy Expressions • Universe of facts? → All possible subsets of expressions in the program • GEN and KILL sets for each basic block? → GEN = expressions used in basic block AND operands not defined before reaching beginning of basic block → KILL = expressions whose operands are defined in basic block • Initial values of VBE(B) before propagation starts? → ∅  Assumes expression is not busy until proven otherwise  The conservative assumption CS430 11 Very Busy Expressions Example = a+b B2: B3: B4: B1: b = B4 B3 B2 B1 KILLGEN Basic Block VBE(B) = ∩ ( GEN(Bi) ∪ [VBE(Bi) - KILL(Bi) ] ) Bi ε SUCC(B) = a+b a = CS430 12 Implementation Issues: Bit-vector Problems The set of facts (universe of facts) can often be expressed as finite subsets of a finite base set. Such sets can be represented as bit-vectors. Example: RD - { B1: a:=2, B2: c := d+2, B3: d := a-5 } B1:a B2:c B3:d B1:a, B2:c B1:a, B3:d B2:c, B3:d B1:a, B2:c, B3:d =
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved