Upcoming SlideShare
×

# Lecture03

527 views
482 views

Published on

0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total views
527
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
5
0
Likes
0
Embeds 0
No embeds

No notes for slide

### Lecture03

1. 1. Control-Flow AnalysisLast time – Undergraduate compilers in a dayToday – Control-flow analysis – Building basic blocks – Building control-flow graphs – LoopsCIS570 Lecture 3 Control-Flow Analysis 2ContextData-flow – Flow of data values from defs to usesControl-flow – Sequencing of operations e.g., Evaluation of then-code and else-code depends on if-testCIS570 Lecture 3 Control-Flow Analysis 3 1
2. 2. Representing Control-FlowHigh-level representation – Control flow is implicit in an ASTLow-level representation: – Use a Control-flow graph (CFG) – Nodes represent statements (low-level linear IR) – Edges represent explicit flow of controlOther options – Control dependences in program dependence graph (PDG) [Ferrante87] – Dependences on explicit state in value dependence graph (VDG) [Weise 94]CIS570 Lecture 3 Control-Flow Analysis 4What Is Control-Flow Analysis?Control-flow analysis discovers the flow of control within a procedure(e.g., builds a CFG, identifies loops) 1 a := 0Example b := a * b1 a := 0 3 c := b/d2 b := a * b c < x?3 L1: c := b/d4 if c < x goto L2 5 e := b / c5 e := b / c f := e + 16 f := e + 17 L2: g := f 7 g := f8 h := t - g h := t - g9 if e > 0 goto L3 e > 0?10 goto L1 No Yes11 L3: return 10 goto 11 returnCIS570 Lecture 3 Control-Flow Analysis 5 2