{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

w11Color

# w11Color - The Role of Program Analysis Program analysis...

This preview shows pages 1–10. Sign up to view the full content.

1 The Role of Program Analysis Program analysis must precede many optimizations. – Control flow analysis determines where program execution goes next, what is dependent on branches – Data flow analysis determines how program variables are affected by program sections – Data-dependence analysis determines which data references in a program access the same storage location. (Sometimes data flow analysis is used as a generic term for all these analyses)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
2 Simple Control Flow Analysis A IF (cond) THEN B ELSE C ENDIF D A B C D Control-Flow or Data-flow Graph
3 Control Flow Analysis Control flow imposes dependences – the execution of a code block must wait until the control conditions have been evaluated. – This is true even if there are no data dependences. Exercise: draw the control flow graph of this program segment d=100 IF (a==b) THEN c=d+e ELSE IF (c==e) THEN d=0 ENDIF b=b*2 DO i=d,e a[i]=0 ENDDO

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
4 Data flow analysis takes place over a control flow graph Data flow analysis attempts to track, at compile time, the flow of variable values, pointer values, expression types, etc. At compile time, we don’t know the effect of control flow, and we must approximate the behavior of the program at “join” points in the program Intra-procedural parts of algorithm are either “flow sensitive” or “flow insensitive” depending on how they treat branches, and joins from branches. Inter-procedural algorithms are either “context sensitive” or “context insensitive” depending on how they treat information flowing into (and out of) function calls.
5 Data flow equations At each point in a program, the effect of data flow is modeled by examining the information (not necessarily variable values) that – comes in to the block/statement, – is gen erated by the block/statement, – is kill ed by the block/statement, – goes out of the block/statement. out[B] = gen[B] (in[B] – kill[B])

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
6 out[B] = gen[B] (in[B] – kill[B]) Definition of out , gen , in , kill depends on the analysis we are doing Some analyses go top down through the program (and use the equation above), some analyses go bottom up and use the equation: In(b) = Gen(b) (Out(b) Kill(b))
7 Global Dataflow Analysis Analysis of how program attributes change across basic blocks Dataflow analysis has many applications. A few examples: – global live variable analysis – uninitialized variable analysis – available expression analysis – busy expression analysis (used along all paths before being killed)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
8 determining Def and Use sets in a basic block is easy. Exercise: determine Def, Use sets for Aside: Finding Local Def, Use c = d + e d = a [ j ] a [ j ] = sb [ i,k ] * p = *q
9 Sound and unsound analyses A safe or sound analysis is one in which any imprecision reduces the opportunities to do a transformation or optimization, but doesn’t cause incorrect transformations or optimizations to be performed.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern