from last class. the above is click’s solution (pldi 95)

21
From last class

Post on 15-Jan-2016

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: From last class. The above is Click’s solution (PLDI 95)

From last class

Page 2: From last class. The above is Click’s solution (PLDI 95)

The above is Click’s solution (PLDI 95)

Page 3: From last class. The above is Click’s solution (PLDI 95)

The above is Click’s solution (PLDI 95)

Page 4: From last class. The above is Click’s solution (PLDI 95)

Control Dependences

• A node (basic block) Y is control-dependent on another X iff X determines whether Y executes– there exists a path from X to Y s.t. every node in the

path other than X and Y is post-dominated by Y– X is not post-dominated by Y

Page 5: From last class. The above is Click’s solution (PLDI 95)

Control Dependences

• A node (basic block) Y is control-dependent on another X iff X determines whether Y executes– there exists a path from X to Y s.t. every node in the

path other than X and Y is post-dominated by Y– X is not post-dominated by Y

Page 6: From last class. The above is Click’s solution (PLDI 95)

Example

Page 7: From last class. The above is Click’s solution (PLDI 95)

Example

Page 8: From last class. The above is Click’s solution (PLDI 95)

Control Dependence Graph

• Control dependence graph: Y decsendent of X iff Y is control dependent on Y– label each child edge with required condition– group all children with same condition under region

node

• Program dependence graph: super-impose dataflow graph (in SSA form or not) on top of the control dependence graph

Page 9: From last class. The above is Click’s solution (PLDI 95)

Example

Page 10: From last class. The above is Click’s solution (PLDI 95)

Example

Page 11: From last class. The above is Click’s solution (PLDI 95)

Another example

Page 12: From last class. The above is Click’s solution (PLDI 95)

Another example

Page 13: From last class. The above is Click’s solution (PLDI 95)

Another example

Page 14: From last class. The above is Click’s solution (PLDI 95)

Another example

Page 15: From last class. The above is Click’s solution (PLDI 95)

Summary so far

• Dataflow analysis– flow functions, lattice theoretic framework, optimistic

iterative analysis, MOP

• Rhodium/Collider– declarative specifications of flow functions

• Advanced Program Representations– SSA, CDG, PDG, code motion

• Next: dealing with procedures

Page 16: From last class. The above is Click’s solution (PLDI 95)

After that

• Pointer analysis

• Program analysis for verification

• Correctness

• Analyzing object-oriented languages

• Advanced topics (set constraints, ordering analyses and transformations, gc)

Page 17: From last class. The above is Click’s solution (PLDI 95)

Interprocedural analyses and optimizations

Page 18: From last class. The above is Click’s solution (PLDI 95)

Costs of procedure calls

• Up until now, we treated calls conservatively:– make the flow function for call nodes return top– start iterative analysis with incoming edge of the CFG

set to top– This leads to less precise results: “lost-precision” cost

• Calls also incur a direct runtime cost– cost of call, return, argument & result passing, stack

frame maintainance– “direct runtime” cost

Page 19: From last class. The above is Click’s solution (PLDI 95)

Addressing costs of procedure calls

• Technique 1: try to get rid of calls, using inlining and other techniques

• Technique 2: interprocedural analysis, for calls that are left

Page 20: From last class. The above is Click’s solution (PLDI 95)

Inlining

• Replace call with body of callee

• Turn parameter- and result-passing into assignments– do copy prop to eliminate copies

• Manage variable scoping correctly– rename variables where appropriate

Page 21: From last class. The above is Click’s solution (PLDI 95)

Program representation for inlining

• Call graph– nodes are procedures

– edges are calls, labelled by invocation counts/frequency

• Hard cases for builing call graph– calls to/from external routines

– calls through pointers, function values, messages

• Where in the compiler should inlining be performed?