SPARSE ABSTRACT INTERPRETATION!
|
|
- Alexis Bruce
- 5 years ago
- Views:
Transcription
1 PROGRAMMING LANGUAGES LABORATORY! Universidade Federal de Minas Gerais - Department of Computer Science SPARSE ABSTRACT INTERPRETATION! PROGRAM ANALYSIS AND OPTIMIZATION DCC888! Fernando Magno Quintão Pereira! fernando@dcc.ufmg.br The material in these slides have been taken from the paper "Parameterized ConstrucAon of Program RepresentaAons for Sparse Dataflow Analyses", by Tavares et al. which is available in the course webpage.
2 Constant PropagaAon Revisited x = input a = 1 c = a + 10 What is the soluaon that our constant propagaaon analysis produces for this program? a < c b = x * a output b a = a + 1
3 Constant PropagaAon Revisited x = input a = 1 c = a + 10 a < c {x!nac, a!undef, b!undef, c!undef} {x!nac, a!1, b!undef, c!undef} {x!nac, a!1, b!undef, c!11} 1) How much space does this soluaon requires? Answer in terms of I, the number of instrucaons, and V, the set of variables. {x!nac, a!nac, b!nac, c!11} b = x * a output b a = a + 1 {x!nac, a!nac, b!undef, c!11} {x!nac, a!nac, b!nac, c!11} {x!nac, a!nac, b!nac, c!11} 2) Is there any redundancy in the soluaon given in the code on the les? 3) Why can't we simply bind the informaaon directly to the variable name, i.e., the variable is constant or not?
4 Binding InformaAon to Variables x = input a = 1 c = a + 10 a < c b = x * a output b a = a + 1 AssociaAng the informaaon with a variable name does not work in constant propagaaon, because the same variable name may denote a variable that is constant at some program points, and nonconstant at others. How could we solve this problem, so that the abstract state of a variable, i.e., constant or not, be invariant along this variable's enare live range?
5 Constant PropagaAon in SSA Form Programs x 0 = input a 0 = 1 c 0 = a a 1 =!(a 0, a 2 ) a 1 < c 0 b 0 = x 0 * a 1 output b 0 If we convert the program to StaAc Single Assignment form, then we can guarantee that the informaaon associated with a variable name is invariant along the enare live range of this variable. Why can we provide this guarantee about constant propagaaon, if the program is in StaAc Single Assignment form? a 2 = a 1 + 1
6 Sparse Constant PropagaAon x 0 = input a 0 = 1 c 0 = a a 1 = ϕ(a 0, a 2 ) a 1 < c 0 b 0 = x 0 * a 1 output b 0 a 2 = a [x 0 ] = NAC [a 0 ] = 1 [c 0 ] = 11 [a 1 ] = NAC [b 0 ] = NAC [a 2 ] = NAC The only instrucaon that determines if a variable is constant or not is the assignment. We have split live ranges at every point where new informaaon is acquired. Thus, we can bind the informaaon, i.e., the abstract state of a variable, to its live range. Whenever this is possible, we call the analysis sparse.
7 Dense vs Sparse x = input x 0 = input [x 0 ] = NAC a = 1 {x!nac, a!undef, b!undef, c!undef} a 0 = 1 [a 0 ] = 1 c = a + 10 {x!nac, a!1, b!undef, c!undef} c 0 = a [c 0 ] = 11 a < c {x!nac, a!1, b!undef, c!11} a 1 = ϕ(a 0, a 2 ) a 1 < c 0 [a 1 ] = NAC {x!nac, a!nac, b!undef, c!11} {x!nac, a!nac, b!nac, c!11} b = x * a output b {x!nac, a!nac, b!nac, c!11} b 0 = x 0 * a 1 output b 0 [b 0 ] = NAC a = a + 1 {x!nac, a!nac, b!nac, c!11} a 2 = a [a 2 ] = NAC Dense Which other analyses can we solve sparsely with SSA form? Sparse
8 Sparse Analyses If a data-flow analysis binds informaaon to pairs of program points variable names, then we call it dense. If the data-flow analysis binds informaaon to variables, then we call it sparse. But there is one more requirement for a data-flow analysis to be sparse: it must not use trivial transfer func0ons. We say that a transfer funcaon is trivial if it does not generate new informaaon. In other words, the transfer funcaon is an idenaty.
9 Trivial Transfer FuncAons The transfer funcaon associated with the assignment "a = 1" is non-trivial, because it changes the abstract state of the variable name "a". On the other hand, the transfer funcaon associated with the instrucaon "output b" is trivial, as it does not change the abstract state of any variable. a = 1 {x!nac, a!undef, b!undef, c!undef} {x!nac, a!1, b!undef, c!undef} output b {x!nac, a!nac, b!nac, c!11} {x!nac, a!nac, b!nac, c!11} A trivial transfer funcaon f is an idenaty, i = f(i). In other words, it receives some data-flow informaaon i, and outputs the same informaaon.
10 Building Sparse Data-Flow Analyses We want to build program representaaons that "sparsify" data-flow analyses. We will do it via live range spli7ng. We split the live range of a variable via copy instrucaons. a = 1 c < a a = 1 a 0 = a c < a 0!"#$!"#!$%&!#'(")*+!',"*$- $%&!'.,+./0!',"*$!1%&.&!1& %/2&!"*#&.$&3!/!*&1!4,'5!,6 2/."/7(&!/ 8 9!$%:#!#'(")*+!"$# ("2&!./*+&; <&!%/2&!.&*/0&3!%&%'()*$%!,6!2/."/7(&!/9!$%/$!"#!3,0"*/$&3!75!$%&!#'(")*+!',"*$9!$,!/ 8 ;
11 Spli[ng Points We split live ranges at the places where new informaaon is generated. In the case of constant propagaaon, we split at the definiaon point of variables. We split live ranges at the places where different informaaon may collide. In the case of constant propagaaon, we split at the join points of programs. L 1 : c = 1 L 0 : if (?) L 3 : print c L 2 : c = read() These are the places where new information is defined. And this is the place where information collides. We have dataflow facts coming from L1 and L2.
12 Spli[ng All Over is not What we Want If we split live ranges at every program point, then, naturally the informaaon associated with every live range will be invariant. x = input a = 1 x 0 = input a 1 = 1 x 1 = x 0 However, this live range spli[ng strategy does not gives us a sparse analysis. Why? a 2 = a 1, x 2 = x 1 b = a + x b 2 = a 2 + x 2 b 3 = b 2, a 3 = a 2, x 3 = x 2 c = b * a c 3 = b 3 * a 3 c 4 = c 3, b 4 = b 3, a 4 = a 3, x 4 = x 3 output c output c 4
13 We do not want trivial transfer funcaons We do not have a sparse analysis because many of the transfer funcaons associated with the copies are trivial. x 0 = input a 1 = 1 b 2 = a 2 + x 2 x 1 = x 0 a 2 = a 1, x 2 = x 1 For$instance,$here$our$transfer$ func0on$will$copy$the$abstract$state$of$ variable$a 2 $into$variable$a 3.$Thus,$these$ two$variables$will$always$have$the$ same$abstract$state,$and$the$transfer$ func0on$that$we$have$for$assignments$ is$not$genera0ng$any$new$informa0on. b 3 = b 2, a 3 = a 2, x 3 = x 2 c 3 = b 3 * a 3 output c 4 c 4 = c 3, b 4 = b 3, a 4 = a 3, x 4 = x 3 But, in this case, where do we split live ranges?
14 The Single InformaAon Property The informaaon that a data-flow analysis computes is a set of points in a la[ce. A dense analysis maps pairs of (program points variables) to these points. We say that a data-flow analysis has the single informa0on property for a given program if we can assign a single element of the underlying la[ce to each variable, and this informaaon is invariant along the enare live range of the variable. x 0 = input [x 0 ] = NAC NAC a 0 = 1 [a 0 ] = 1...!2! c 0 = a 0-2 [c 0 ] = -1 UNDEF
15 Universidade Federal de Minas Gerais Department of Computer Science Programming Languages Laboratory EXAMPLES OF LIVE RANGE SPLITTING DCC 888
16 Class Inference Analysis Some languages, such as Python, JavaScript and Lua, store the methods and fields of objects in hash-tables. It is possible to speedup programs wricen in these languages by replacing these tables by virtual tables. A class inference engine tries to assign a virtual table to a variable v based on the ways that v is used. Consider the Python program on the right. Where is class inference informaaon acquired? def test(i): v = OX() if i % 2: tmp = i + 1 v.m1(tmp) else: v = OY() v.m2() print v.m3() l 3 : tmp = i + 1 l 4 : v.m 1 ( ) l 1 : v = OX( ) l 2 : (i%2)? l 7 : v.m 3 ( ) l 5 : v = OY( ) l 6 : v.m 2 ( ) : CustomizaAon: opamizing compiler technology for SELF, a dynamically-typed object-oriented programming language
17 Class Inference Analysis We discover informaaon based on the way an object is used. If the program calls a method m on an object o, then we assume that m is part of the class of o. l 1 : v = OX( ) l 2 : (i%2)? l 3 : tmp = i + 1 l 4 : v.m 1 ( ) l 7 : v.m 3 ( ) So, where should we split live ranges, to ensure the single informaaon property? l 5 : v = OY( ) l 6 : v.m 2 ( ) l 3 : tmp = i + 1 {m 1,m 3 } l 4 : v.m 1 ( ) l 1 : v = OX( ) l 2 : (i%2)? {m 1,m 3 } {m 1,m 3 } {} l 5 : v = OY( ) {m 2,m 3 } l 6 : v.m 2 ( ) {m 3 } {m 3 } l 7 : v.m 3 ( )
18 Backward PropagaAon You are probably wondering why informaaon propagates backwardly, and not forwardly, in this analysis, aser all, once I use a method, I know that the method is in the class aser the use. 1) Do we really know this in Python? 2) What about in Java? 3) What could be different in these two languages to jusafy the second quesaon?
19 Backward PropagaAon You are probably wondering why informaaon propagates backwardly, and not forwardly, in this analysis, aser all, once I use a method, I know that the method is in the class aser the use. class X:! def init (self):! self.x = 0;! def m(self):! print(self.x)! self.m = 0! >>> x = X() >>> x.m() 1 >>> x.m() Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'int' object is not callable
20 The Points where We Acquire InformaAon l 1 : v = OX( ) {m 1,m 3 } l 2 : (i%2)? {m 1,m 3 } {} In the class inference analysis, informaaon propagates backwards: if a method m is invoked on an object o at a program point p, we know that o must have the method m everywhere before p. l 3 : tmp = i + 1 l 5 : v = OY( ) {m 1,m 3 } {m 2,m 3 } l 4 : v.m 1 ( ) l 6 : v.m 2 ( ) {m 3 } {m 3 } l 7 : v.m 3 ( ) 1) So, in the end, where is informaaon acquired? 2) And where is informaaon colliding? 3) How many variable names would we have in the transformed program?
21 Backward Live Range Spli[ng Given this IR, how can we solve class inference analysis? tmp = i + 1 v 1 = OX( ) (i%2)? (v 2, ") =! (v 1 ) v 3 = OY( ) We represent these backward merge points using these special instructions, that we call sigmafunctions, to distinguish them from the phi-functions used in the forward merge points. No information is arriving at the second parameter of the sigmafunction, thus we represent it as an undefined name, denoted by " (v 4 ) = (v 2 ) v 2.m 1 ( ) v 6 =! (v 4, v 5 ) v 6.m 3 ( ) (v 5 ) = (v 3 ) v 3.m 2 ( ) We use this notation of parallel copies, e.g.,, to indicate that there is some live range splitting happening at that program point. We shall talk more about this notation soon.
22 Class Inference as a Constraint System What do you noace about the right side of these equaaons? v 1 = OX( ) (i%2)? (v 2, v 7 ) =! (v 1 ) [v 2 ] " [v 7 ] # [v 1 ] {} # [v 7 ] {m 1 } $ [v 4 ] # [v 2 ] tmp = i + 1 v 3 = OY( ) {m 2 } $ [v 5 ] # [v 3 ] (v 4 ) = (v 2 ) v 2.m 1 ( ) (v 5 ) = (v 3 ) v 3.m 2 ( ) [v 6 ] # [v 5 ] [v 6 ] # [v 4 ] v 6 =! (v 4, v 5 ) v 6.m 3 ( ) {m 3 } # [v 6 ]
23 Is SSA Form Really Necessary? The representaaon that we have produced is in SSA form. It is very convenient to keep the program in this representaaon: Helps other analyses. Compiler already does it. Fast liveness check. Yet, we do not really need SSA form for this paracular backward analysis. tmp = i + 1 (v 4 ) = (v 2 ) v 2.m 1 ( ) If we only split live ranges where informaaon is produced, how would our IR be? v 1 = OX( ) (i%2)? (v 2, v 7 ) =! (v 1 ) v 6 =! (v 4, v 5 ) v 6.m 3 ( ) v 3 = OY( ) (v 5 ) = (v 3 ) v 3.m 2 ( ) : Fast Liveness Checking for SSA-Form Programs, CGO (2008)
24 A More Concise RepresentaAon v 1 = OX( ) (i%2)? (v 2, v 7 ) =! (v 1 ) The program on the right is no longer in SSA form. It has fewer variable names. How would be the constraint system for this new program representaaon? v 1 = OX( ) (i%2)? (v 2, v 7 ) =! (v 1 ) tmp = i + 1 v 3 = OY( ) tmp = i + 1 v 3 = OY( ) (v 4 ) = (v 2 ) v 2.m 1 ( ) (v 5 ) = (v 3 ) v 3.m 2 ( ) (v 6 ) = (v 2 ) v 2.m 1 ( ) (v 6 ) = (v 3 ) v 3.m 2 ( ) v 6 =! (v 4, v 5 ) v 6.m 3 ( ) v 6.m 3 ( )
25 A Constraint System for the Non-SSA form Program v 1 = OX( ) [v 2 ]! [v 7 ] " [v 1 ] (i%2)? (v 2, v 7 ) =! (v 1 ) {} " [v 7 ] {m 1 } # [v 6 ] " [v 2 ] tmp = i + 1 (v 6 ) = (v 2 ) v 2.m 1 ( ) v 6.m 3 ( ) v 3 = OY( ) (v 6 ) = (v 3 ) v 3.m 2 ( ) {m 2 } # [v 6 ] " [v 3 ] {m 3 } " [v 6 ] Which constraint system is simpler: this one, or that for the SSA-form program?
26 Tainted Flow Analysis The goal of the tainted flow analysis is to find out if there is a path from a source of malicious informaaon to a sensiave operaaon. 1) Does the program below contain a tainted flow vulnerability? 2) To which kind of acack? l 1 : v = input( ) l 2 : v = "Hi!" l 3 : echo v l 4 : echo v 3) Where is new informaaon acquired in this type of analysis? 4) How does this informaaon propagate along the CFG? l 7 : echo v l 5 : is v Clean? l 6 : echo v
27 InformaAon in the tainted flow analysis propagates forwardly. And we can learn new facts from condiaonal tests. CondiAonal Tests l 1 : v = input( ) l 3 : echo v l 2 : v = "Hi!" {v = tainted} {v = clean} l 4 : echo v So, where should we split live ranges, to ensure the single informaaon property? {v = tainted} {v = clean} l 5 : is v Clean? T F {v = clean} {v = tainted} l 7 : echo v l 6 : echo v
28 Spli[ng ASer CondiAonals v 1 = input( ) v 2 = "Hi!" echo v 1 echo v 2 And which constraints can we extract from this program representaaons? v 3 =! (v 1, v 2 ) is v 3 Clean? (v 4, v 5 ) =! (v 3 ) echo v 4 echo v 5 We use sigma-functions after conditional tests, to split live ranges. In fact, we use sigma-functions whenever we need to copy the contents of a variable to multiple locations.
29 Tainted Analysis as a Constraint System v 1 = input( ) v 2 = "Hi!" {Clean}! [v 2 ] echo v 1 echo v 2 {Tainted}! [v 1 ] v 3 =! (v 1, v 2 ) is v 3 Clean? (v 4, v 5 ) =! (v 3 ) [v 1 ] " [v 2 ]! [v 3 ] {Clean}! [v 5 ] {Tainted}! [v 4 ] echo v 4 echo v 5
30 Null Pointer Analysis Type safe languages, such as Java, prefix method calls with a test that checks if the object is null. In this way, we cannot have segmentaaon faults, but only well-defined excepaons. Exception in thread "main"! java.lang.nullpointerexception!! at Test.main(Test.java:7)! l 2 : v.m( ) l 3 : v.m( ) l 1 : v = foo( ) Consider the program on the right. Which calls can result in null pointer excepaons, and which calls are always safe? l 4 : v.m( )
31 Null Pointer Analysis 1) Can the call at l 4 result in a null pointer excepaon? 2) Where is informaaon produced? Java, being a programming language that is type safe, must ensure dynamically that every call to an object that is null fires an excepaon. 3) How is a null pointer check implemented? 4) What do we gain by eliminaang these tests? 5) Can you split the live ranges of this program? v = maybe v = not null l 2 : v.m( ) l 3 : v.m( ) v = not null l 1 : v = foo( ) l 4 : v.m( ) v = maybe
32 Spli[ng ASer Uses In the case of null check eliminaaon, we split live ranges aser uses. If we invoke a method m on an object o, and no excepaon happens, then we know that m can be safely invoked on o in any program point aser the use point. As an example, an excepaon can never happen at this point, because otherwise it would have happened at the previous use of v 1, e.g., v 1.m() How can we transform this problem in a constraint system? v 1.m( ) v 2 = v 1 v 2.m( ) v 3 = v 2 v 1 = foo( ) v 4 =! (v 3, v 1 ) v 4.m( )
33 Null Pointer Check EliminaAon as Constraints Can you think about other analyses that would use the same live range spli[ng strategy as null pointer check eliminaaon? v 1 = foo( ) {Maybe}! [v 1 ] {Not Null}! [v 2 ] v 1.m( ) v 2 = v 1 {Not Null}! [v 3 ] v 2.m( ) v 3 = v 2 [v 3 ] " [v 1 ]! [v 4 ] v 4 =! (v 3, v 1 ) v 4.m( )
34 Universidade Federal de Minas Gerais Department of Computer Science Programming Languages Laboratory LIVE RANGE SPLITTING STRATEGIES DCC 888
35 Live Range Spli[ng NotaAon We use three special notaaons to indicate that we are spli[ng live ranges. Phi-funcAons split at join points. Sigma-funcAons split at branch points. Parallel copies split at interior points. v 1 = OX( ) (i%2)? (v 2, v 7 ) =! (v 1 ) tmp = i + 1 v 3 = OY( ) (v 4 ) = (v 2 ) v 2.m 1 ( ) (v 5 ) = (v 3 ) v 3.m 2 ( ) v 6 =! (v 4, v 5 ) v 6.m 3 ( )
36 Parallel Copies We split live ranges at interior nodes via parallel copies. Usually there is no assembly equivalent of a parallel copy; nevertheless, we can implement them with move or swap instrucaons. SemanAcally, we have a program point p like: (a 1 = a 0 ) (b 1 = b 0 ) x 1 = f(y 0, z 0 ), we read all the variables used at p, e.g., a 0, b 0, y 0, z 0, then write all the variables defined at p, e.g., a 1, b 1, x 1. All the reads happen in parallel. All the writes happen in parallel.
37 Phi-FuncAons Phi-funcAons work as mulaplexers: they choose a copy based on the program flow. We may have mulaple phi-funcaons at the beginning of a basic-block. If we have N phi-funcaons with M arguments at a basic block, then we have M parallel copies of N variables. L 0 : a 0 =! L 1 : b 0 =! c 0 =! L 2 : a 2 =! (a 0, a 1 ) b 2 =! (b 0, b 1 ) c 2 =! (c 0, c 1 )... a 1 =! b 1 =! c 1 =! In this example, if control reaches L 2 from L 0, then we have the parallel copy (a 2 = a 0 ) (b 2 = b 0 ) (c 2 = c 0 ); otherwise we have the parallel copy (a 2 = a 1 ) (b 2 = b 1 ) (c 2 = c 1 )
38 Sigma-FuncAons Sigma-FuncAons work as demulaplexers: they choose a parallel copy based on the path taken at a branch. In this example, if we branch from L 0 to L 1, then the following parallel copy takes place: (a 1 = a 0 ) (b 1 = b 0 ) (c 1 = c 0 ); otherwise we have the parallel copy (a 2 = a 0 ) (b 2 = b 0 ) (c 2 = c 0 ) L 0 :... a 0 =! b 0 =! c 0 =!... (a 1, a 2 ) =! a 0 (b 1, b 2 ) =! b 0 (c 1, c 2 ) =! c 0 L 1 :! = a 1! = b 1! = c 1... L 2 :! = a 2! = b 2! = c 2...
39 Live Range Spli[ng Strategy A live range spli[ng strategy for variable v, is a set P v = I I of "oriented" program points. The set I denotes points that produce informaaon that propagates forwardly. The set I denotes points that produce informaaon that propagates backwardly. Live ranges must be split at least in every point of P v. And each split point may cause further spli[ng, as we will see soon. We have seen this kind of cascading behavior, when converang a program to SSA form. Do you remember the exact situaaon?
40 l 1 : v = OX( ) Quiz Time: Class Inference l 2 : (i%2)? l 3 : tmp = i + 1 l 5 : v = OY( ) l 4 : v.m 1 ( ) l 6 : v.m 2 ( ) l 7 : v.m 3 ( ) What is the live range spli[ng strategy for the class inference analysis of our original example?
41 Quiz Time: Class Inference l 1 : v = OX( ) l 2 : (i%2)? l 3 : tmp = i + 1 l 5 : v = OY( ) Class inference acquires informaaon from uses, and propagates it backwardly. This gives us the following live range spli[ng strategy: P v = {l 4, l 6, l 7 } l 4 : v.m 1 ( ) l 6 : v.m 2 ( ) l 7 : v.m 3 ( )
42 Quiz Time: Null Pointer Check EliminaAon l 1 : v = foo( ) What is the live range spli[ng strategy for our "null pointer check eliminaaon" analysis? l 2 : v.m( ) l 3 : v.m( ) l 4 : v.m( )
43 Quiz Time: Null Pointer Check EliminaAon l 2 : v.m( ) l 1 : v = foo( ) Null pointer check eliminaaon takes informaaon from the uses, and from the definiaon of variables, and propagates it forwardly. This gives us the following live range spli[ng strategy: P v = {l 1, l 2, l 3, l 4 } l 3 : v.m( ) l 4 : v.m( )
44 Quiz Time: Tainted Flow Analysis l 1 : v = input( ) l 2 : v = "Hi!" l 3 : echo v l 4 : echo v l 5 : is v Clean? l 7 : echo v l 6 : echo v What is the live range spli[ng strategy for our tainted flow analysis, considering our example?
45 Quiz Time: Tainted Flow Analysis l 1 : v = input( ) l 2 : v = "Hi!" l 3 : echo v l 4 : echo v l 5 : is v Clean? Tainted flow analysis takes informaaon from definiaons and condiaonal tests, and propagates this informaaon forwardly. This gives us the following live range spli[ng strategy: P v = {l 1, l 2, out(l 5 )}. We let out(l 5 ) denote the program point aser l 5. l 7 : echo v l 6 : echo v
46 Quiz Time: Constant PropagaAon l 1 : x = input l 2 : a = 1 Finally, what is the live range spli[ng strategy if we decide to do constant propagaaon in this example on the les? l 3 : c = a + 10 l 4 : a < c l 5 : b = x * a l 6 : output b l 7 : a = a + 1
47 Quiz Time: Constant PropagaAon l 1 : x = input l 2 : a = 1 l 3 : c = a + 10 l 4 : a < c l 5 : b = x * a l 6 : output b There are two main implementaaons of constant propagaaon. The simplest one just takes informaaon from definiaons. The more involved one uses also the result of equality tests to find out if a variable is constant or not. Assuming the simplest kind, we would have the following strategies: P x = {l 1 }, P a = {l 2, l 7 }, P c = {l 3 } and P b = {l 5 }. NoAce that we have to split live ranges for each different variable in our program. l 7 : a = a + 1 : Constant propagaaon with condiaonal branches, TOPLAS, 1991
48 Meet Nodes Consider a forward (resp. backward) data-flow problem where S(p, v) is the maximum fixed point soluaon for variable v and program point p. We say that a program point m is a meet node for variable v if, and only if, m has n predecessors (resp. successors), s 1,, s n, n > 2, and there exists i, j, 1 i < j n, such that S(s i, v) S(s j, v). l 3 : tmp = i + 1 l 4 : v.m 1 ( ) l 1 : v = OX( ) l 2 : (i%2)? l 7 : v.m 3 ( ) l 5 : v = OY( ) l 6 : v.m 2 ( ) NoAce that there is no cheap way to compute the meet nodes by just considering the structure of the program. Why?
49 CompuAng Meet Nodes In order to know the meet nodes, we must solve the analysis. But we need them to solve the analysis! So we will just approximate the set of meet nodes, using only structural properaes of the program's CFG: Dominance: a CFG node n dominates a node n' if every program path from the entry node of the CFG to n' goes across n. If n n', then we say that n strictly dominates n' Dominance fronber (DF): a node n' is in the dominance fronaer of a node n if n dominates a predecessor of n', but does not strictly dominate n'. Iterated dominance fronber (DF+): the iterated dominance fronaer of a node n is the fixed point of the sequence: DF 1 (n) = DF(n) DF i+1 (n) = DF i (n) {DF(z) z DF i (n)}
50 Iterated Dominance FronAer What is the DF+ of each node marked in red? a e f g h l i j k b c d a e f g h l i j k b c d a e f g h l i j k b c d a e f g h l i j k b c d
51 Iterated Dominance FronAer a e f g h l i j k b c d a e f g h l i j k b c d a e f g h l i j k b c d a e f g h l i j k b c d
52 Spli[ng at Meet Nodes If informaaon is produced at a point p, then we must recombine this informaaon at the iterated dominance fronaer of p. In this case, we are approximaang meet nodes as the nodes in the DF+(p). We split the live range of a variable v at meet nodes, for a forward analysis, in the same way we did it when building the StaAc Single Assignment form: If we have a node n with m predecessors, then we create a phi-funcaon at n, with m entries. How would we split if we had a definiaon of v at f? b c d f a e h l g i k j
53 Spli[ng at Meet Nodes If informaaon is produced at a point p, then we must recombine this informaaon at the iterated dominance fronaer of p. In this case, we are approximaang meet nodes as the nodes in the DF+(p). 1) When are all these copies really necessary? 2) How (and under which assumpaons) could we remove some of these copies? v =! v =! (v, v) v =! (v, v) v =! (v, v) v =! (v, v,v) v =! (v, v,v)
54 Pseudo-Defs and Pseudo-Uses at Extreme Nodes We can assume that we have a pseudo-definiaon of the variable, at the entry node of the Control Flow Graph. This pseudo-definiaon avoids the problem of paths in which a variable might not have been iniaalized. v =! But, in any case, we only need to split live ranges where these live ranges exist, i.e., where the variable is alive. v =! (v, v) Nevertheless, it is not wrong to insert phi-funcaons at places where the variable is not alive. We can simplify macers a licle bit assuming a pseudo use at the exit node of the CFG. v =! (v, v) v =! v =! (v, v) v =! (v, v, v) v =! (v, v, v)! = v
55 Backward Analyses For backward analyses we do everything "backwardly". Instead of the iterated dominance fronaer, we consider the iterated post-dominance fronaer. Post-Dominance: a CFG node n post-dominates a node n' if every program path from n' to the exit node of the CFG goes across n. If n n', then we say that n strictly post-dominates n' Post-Dominance fronber (DF): a node n' is in the post-dominance fronaer of a node n if n post-dominates a successor of n', but does not strictly post-dominate n'. Iterated post-dominance fronber (PDF+): the iterated post-dominance fronaer of a node n is the fixed point of the sequence: PDF 1 (n) = PDF(n) PDF i+1 (n) = PDF i (n) {PDF(z) z PDF i }
56 Dominators and Post-Dominators a m x What is the dominance and post-dominance relaaons between each node in these three graphs? b n y
57 Dominators and Post-Dominators a m x Node 'a' dominates node 'b', for any path from start to 'b' goes across 'a'. Similarly, node 'b' postdominates node 'a', for any (backwards) path from the end of the CFG to 'a' must go across 'b'. b n y Node n post-dominates node m, but m does not dominate n. Node x dominates node y, but y does not post-dominate node x.
58 a e f g h l i j k b c d a e f g h l i j k b c d a e f g h l i j k b c d a e f g h l i j k b c d Iterated Post-Dominance FronAer What is PDF+ of each node marked in red?
59 a e f g h l i j k b c d a e f g h l i j k b c d a e f g h l i j k b c d a e f g h l i j k b c d Iterated Post-Dominance FronAer
60 A Cheap Trick The post-dominance relaaons are equivalent to the dominance relaaons if we reverse the edges of the CFG. b a e i As an example, the post-dominance fronaer of h, in the CFG on the upper right is the same as the dominancefronaer of h in the CFG in the lower right. c d f h l a g k j b e i c f g j d h k l
61 Spli[ng for Backward Analyses If we produce informaaon for variable v at a program point p, then we must split the live range of v at every node that is in the post-dominance fronaer of v. We do this live range spli[ng via sigma-funcaons, which we insert at the nodes in PDF+(v). a How would we split live ranges if we had a definiaon of variable v at node k in the control flow graph on the right? b c d f e h g i k j! = v l
62 Spli[ng for Backward Analyses If we produce informaaon for variable v at a program point p, then we must split the live range of v at every node that is in the post-dominance fronaer of v. We do this live range spli[ng via sigma-funcaons, which we insert at the nodes in PDF+(v). If we have a node n with m successors, then we create a sigma-funcaon at n, defining m new versions of v. b c (v, v, v) =! v (v, v) =! v (v, v) =! v (v, v) =! v i j d (v, v) =! v " = v l
63 Renaming Variables Once we have split variables, we must rename them, ensuring that each variable is bound to a unique informaaon, which is invariant along its live range. v =! How would we rename variables in each program? v = " (v, v, v) =! v v =! (v, v) b (v, v) =! v i v =! c (v, v) =! v (v, v) =! v j v =! (v, v) v =! (v, v) v =! (v, v, v) d (v, v) =! v " = v v =! (v, v, v) l! = v " = v
64 Renaming Variables v 1 = " 1) Can you devise an algorithm to rename variables? v 7 = " (v 1, v 6, v 3 ) =! v 7 v 3 =! (v 2, v 1 ) b (v 5, v 4 ) =! v 6 i v 2 = " c (v 1, v 2 ) =! v 5 (v 2, v 3 ) =! v 4 j v 4 =! (v 1, v 2 ) v 3 =! (v 2, v 1 ) v 7 =! (v 3, v 1, v 1 ) d (v 6, v 1 ) =! v 2 " = v 3 v 5 =! (v 4, v 3,v 7 ) l " = v 6 2) Is this algorithm the same for forward and backward analyses? " = v 1
65 Forward analyses: Renaming Variables For each definiaon site v = at a program point p, in any order: Find a new name v i to v; Rename every use of v that is dominated by p to v i Backward analyses: For each use site = v where informaaon originates, at a program point p, in any order: Find a new name v i to v; Rename every use of v, and each definiaon of v, that is postdominated by p to v i 1) For the backward analysis we are considering only use sites. Why not to consider also definiaon sites?
66 Pruning Unused Copies Our live range spli[ng algorithm may insert copies that are not used (nor defined) in the program, if we do not consider the pseudo-definiaons and the pseudo-uses. We can remove some of these copies. This process is called pruning. x = 1) Consider the program on the right. How would we split live ranges for a forward analysis that extracts informaaon from definiaons and condiaonal tests? 2) Can you name an actual analysis that behaves like this? x > 0 x < 100 = x
67 Pruning Unused Copies 1) Many new versions of variable x are unnecessary. Can you name a few? 2) How could we simplify the program on the right? 3) What is the complexity of this simplificaaon algorithm? x = x 0 = x > 0 x < 100 x 0 > 0 (x 4, x 1 ) =! x 0 x 0 < 100 (x 2, x 5 ) =! x 0 x 3! = (x 1, x 2 ) = x = x 3
68 Pruning by Liveness We can prune by liveness: if a copy of the variable is not alive, i.e., there is no path from this copy to a use of the variable that does not go across a redefiniaon of it, then we can eliminate this copy. x 0 = We have to run the liveness analysis dataflow algorithm, or is there a simpler way to find if a variable is useful or not? x 0 = x 0 > 0 (x 4, x 1 ) =! x 0 x 0 < 100 (x 2, x 5 ) =! x 0 x 0 > 0 (", x 1 ) =! x 0 x 0 < 100 (x 2, ") =! x 0 x 3! = (x 1, x 2 ) x 3! = (x 1, x 2 ) = x 3 = x 3
69 BidirecAonal Analyses l 1 : a = y l 0 : a = x There exist data-flow analyses that propagate informaaon both forwardly, and backwardly. Consider, for instance, bitwidth analysis: we want to know the size, in bits, of each variable. 1) Why would we be willing to know the size, in bits, of each variable? 2) Which statements produce new informaaon in this analysis? l 2 : if a > 10 goto l 3 l 3 : print v[a] 3) How does each of these statements propagate informaaon? : Bitwidth analysis with applicaaon to silicon compilaaon, PLDI (2000)
70 BidirecAonal Analyses " l 1 : a = y " l 0 : a = x 1) Which informaaon can we infer from the backward constraints? 2) And which informaaon can we learn from the forward constraints? " l 2 : if a > 10 goto l 3 3) How would be the intermediate program representaaon that we create for this example?! l 3 : print v[a] Backward flow: we know that a < v.len here, or the program would be wrong! Forward flow: we know that a > 10 at this program point.
71 Which constraints can we derive from this new program representaaon? BidirecAonal Analyses l 1 : a 1 = y l 0 : a 0 = x (a 2, a 3 ) =! (a 0 ) l 1 : a = y l 0 : a = x a 4 =! (a 1, a 2 ) l 2 : if a 4 > 10 goto l 3 (!, a 5 ) =! (a 4 ) l 2 : if a > 10 goto l 3 l 3 : print v[a] l 3 : a 6 =! (a 5, a 3 ) print v[a 6 ]
72 BidirecAonal Analyses l 1 : a 1 = y l 0 : a 4 =ϕ (a 1, a 2 ) l 2 : if a 4 > 10 goto l 3 (, a 5 ) =σ (a 4 ) l 3 : a 0 = x (a 2, a 3 ) =σ (a 0 ) a 6 =ϕ (a 5, a 3 ) print v[a 6 ] Forward flow: [a 0 ] [x] [a 1 ] [y] [a 2 ] [a 0 ] [a 3 ] [a 0 ] [a 4 ] MAX([a 1 ], [a 2 ]) [a 5 ] MIN([a 4 ], 10) [a 6 ] MAX([a 3 ], [a 5 ]) 1) Can you explain each one of these constraints? 2) And how are the backward constraints like?
73 BidirecAonal Analyses l 1 : a 1 = y l 0 : a 4 =ϕ (a 1, a 2 ) l 2 : if a 4 > 10 goto l 3 (, a 5 ) =σ (a 4 ) l 3 : a 0 = x (a 2, a 3 ) =σ (a 0 ) a 6 =ϕ (a 5, a 3 ) print v[a 6 ] Forward flow: [a 0 ] [x] [a 1 ] [y] [a 2 ] [a 0 ] [a 3 ] [a 0 ] [a 4 ] MAX([a 1 ], [a 2 ]) [a 5 ] MIN([a 4 ], 10) [a 6 ] MAX([a 3 ], [a 5 ]) Backward flow: [a 6 ] < [v.len] [a 5 ] [a 6 ] [a 3 ] [a 6 ] [a 4 ] [a 5 ] [a 1 ] [a 4 ] [a 2 ] [a 4 ] [a 0 ] MIN([a 2 ], [a 3 ]) [x] [a 0 ] [y] [a 1 ] Can you provide a raaonale for the backward constraints?
74 ImplemenAng Parallel Copies Actual instrucaon sets, in general, will not provide parallel copies. We must implement them using more convenaonal instrucaons. We already know how to implement phi-funcaons: we can replace these instrucaons with copies. But, how do we implement sigma-funcaons, and parallel copies placed at interior nodes? L 0 : a 0 = read() 1 : b 0 = read() 2 : if a 0 > b 0 goto L 6 L 0 : a 0 = read() 1 : b 0 = read() 2 : if a 0 > b 0 goto L 6 L 3 : b 1 = a 0 4 : goto L 0 L 6 : goto L 7 L 3 : b 1 = a 0 4 : b 2 = b 1 5 : goto L 0 L 6 : b 2 = b 0 7 : goto L 7 b 2 =!(b 0, b 1 ) L 7 : ret b 2 b 2 =!(b 0, b 1 ) L 8 : ret b 2
75 Dealing with Sigma-FuncAons We can represent sigma-funcaons as single-arity phifuncaons, at the beginning of basic blocks. v 1 = OX( ) (i%2)? (v 2, v 7 ) =! (v 1 ) And how do we implement parallel copies, e.g., (a 2 = a 1 ) (b 2 = b 1 ) (c 2 = c 1 )? v 1 = OX( ) (i%2)? tmp = i + 1 v 3 = OY( ) v 2 =! (v 1 ) tmp = i + 1 v 7 =! (v 1 ) v 3 = OY( ) (v 4 ) = (v 2 ) v 2.m 1 ( ) (v 5 ) = (v 3 ) v 3.m 2 ( ) v 2.m 1 ( ) v 4 = v 2 v 3.m 2 ( ) v 5 = v 3 v 6 =! (v 4, v 5 ) v 6.m 3 ( ) v 6 =! (v 4, v 5 ) v 6.m 3 ( )
76 ImplemenAng Parallel Copies Parallel copies can be implemented as sequences of move instrucaons. But ensuring correctness is not exactly a trivial problem. (a 2 = a 1 ) (b 2 = b 1 ) (c 2 = c 1 ) Phi-Assignment: v 1... v m =! l 1,..., l n v 11,..., v 1n v m1,..., v mn Sigma-Assignment: l 1,..., l n a 2 = a 1 ; b 2 = b 1 ; c 2 = c 1 This same strategy, of implemenang parallel copies as sequences of move instrucaons, can also be used to implement the parallel copies embedded in phi-funcaons and in sigmafuncaons. v 11,..., v 1n v m1,..., v mn =" v 1... v m Parallel-Assignment: v 1 u 1... v m =... u m : TilAng at Windmills with Coq: Formal VerificaAon of a CompilaAon Algorithm for Parallel Moves, JAR, 2008
77 A Bit of History A well-known acempt to implement a framework for Sparse Analyses is due to Choi et al. There have been many program representaaons for Sparse Analyses, such as Ananian's SSI and Bodik's e-ssa. These slides use the representaaon of Tavares et al. These representaaons sall use the core ideas introduced by Cytron et al. to build the staac single assignment form. Cytron, R., Ferrante, J., Rosen, B., Wegman, M., and Zadeck, K., "An Efficient Method of CompuAng StaAc Single Assignment Form", POPL, p (1989) Tavares, Boissinot, Pereira, and Rastello. "Parameterized ConstrucAon of Program RepresentaAons for Sparse Dataflow Analyses", CC, (2014) Choi, J., Cytron, R., and Ferrante, J., "AutomaAc ConstrucAon of Sparse Data Flow EvaluaAon Graphs", POPL, p (1991) Ananian, S., "The StaAc Single InformaAon Form", MSc DissertaAon, Massachusecs InsAtute of Technology (1999) Bodik., R., Gupta, R., and Sarkar, V., "ABCD: eliminaang array bounds checks on demand", PLDI, p (2000)
What is SSA? each assignment to a variable is given a unique name all of the uses reached by that assignment are renamed
Another Form of Data-Flow Analysis Propagation of values for a variable reference, where is the value produced? for a variable definition, where is the value consumed? Possible answers reaching definitions,
More informationVerifying the LLVM. Steve Zdancewic DeepSpec Summer School 2017
Verifying the LLVM Steve Zdancewic DeepSpec Summer School 2017 Vminus OperaAonal SemanAcs Only 5 kinds of instrucaons: Binary arithmeac Memory Load Memory Store Terminators Phi nodes What is the state
More informationTAINTED FLOW ANALYSIS!
PROGRAMMING LANGUAGES LABORATORY! Universidade Federal de Minas Gerais - Department of Computer Science TAINTED FLOW ANALYSIS! PROGRAM ANALYSIS AND OPTIMIZATION DCC888! Fernando Magno Quintão Pereira!
More informationComputing Static Single Assignment (SSA) Form
Computing Static Single Assignment (SSA) Form Overview What is SSA? Advantages of SSA over use-def chains Flavors of SSA Dominance frontiers revisited Inserting φ-nodes Renaming the variables Translating
More informationTainted Flow Analysis on e-ssaform
Tainted Flow Analysis on e-ssaform Programs Andrei Rimsa, Marcelo d Amorim and Fernando M. Q. Pereira The Objective of this work is to detect security vulnerabilities in programs via static analysis Vulnerabilities
More informationCOSE312: Compilers. Lecture 17 Intermediate Representation (2)
COSE312: Compilers Lecture 17 Intermediate Representation (2) Hakjoo Oh 2017 Spring Hakjoo Oh COSE312 2017 Spring, Lecture 17 May 31, 2017 1 / 19 Common Intermediate Representations Three-address code
More informationCSC D70: Compiler Optimization Static Single Assignment (SSA)
CSC D70: Compiler Optimization Static Single Assignment (SSA) Prof. Gennady Pekhimenko University of Toronto Winter 08 The content of this lecture is adapted from the lectures of Todd Mowry and Phillip
More informationConstruction of Static Single-Assignment Form
COMP 506 Rice University Spring 2018 Construction of Static Single-Assignment Form Part II source IR IR target code Front End Optimizer Back End code Copyright 2018, Keith D. Cooper & Linda Torczon, all
More informationLecture 11: Data Flow Analysis III
CS 515 Programming Language and Compilers I Lecture 11: Data Flow Analysis III (The lectures are based on the slides copyrighted by Keith Cooper and Linda Torczon from Rice University.) Zheng (Eddy) Zhang
More informationDataflow Analysis. A sample program int fib10(void) { int n = 10; int older = 0; int old = 1; Simple Constant Propagation
-74 Lecture 2 Dataflow Analysis Basic Blocks Related Optimizations SSA Copyright Seth Copen Goldstein 200-8 Dataflow Analysis Last time we looked at code transformations Constant propagation Copy propagation
More informationTopic-I-C Dataflow Analysis
Topic-I-C Dataflow Analysis 2012/3/2 \course\cpeg421-08s\topic4-a.ppt 1 Global Dataflow Analysis Motivation We need to know variable def and use information between basic blocks for: constant folding dead-code
More informationCompiler Design. Data Flow Analysis. Hwansoo Han
Compiler Design Data Flow Analysis Hwansoo Han Control Flow Graph What is CFG? Represents program structure for internal use of compilers Used in various program analyses Generated from AST or a sequential
More informationLecture 10: Data Flow Analysis II
CS 515 Programming Language and Compilers I Lecture 10: Data Flow Analysis II (The lectures are based on the slides copyrighted by Keith Cooper and Linda Torczon from Rice University.) Zheng (Eddy) Zhang
More informationCompiler Design Spring 2017
Compiler Design Spring 2017 8.5 Reaching definitions Dr. Zoltán Majó Compiler Group Java HotSpot Virtual Machine Oracle Corporation Admin issues Brief reminder: Code review takes place today @ 15:15 You
More informationCMSC 631 Program Analysis and Understanding. Spring Data Flow Analysis
CMSC 631 Program Analysis and Understanding Spring 2013 Data Flow Analysis Data Flow Analysis A framework for proving facts about programs Reasons about lots of little facts Little or no interaction between
More informationCS 553 Compiler Construction Fall 2006 Homework #2 Dominators, Loops, SSA, and Value Numbering
CS 553 Compiler Construction Fall 2006 Homework #2 Dominators, Loops, SSA, and Value Numbering Answers Write your answers on another sheet of paper. Homework assignments are to be completed individually.
More informationCSE P 501 Compilers. Value Numbering & Op;miza;ons Hal Perkins Winter UW CSE P 501 Winter 2016 S-1
CSE P 501 Compilers Value Numbering & Op;miza;ons Hal Perkins Winter 2016 UW CSE P 501 Winter 2016 S-1 Agenda Op;miza;on (Review) Goals Scope: local, superlocal, regional, global (intraprocedural), interprocedural
More informationClass 5. Review; questions. Data-flow Analysis Review. Slicing overview Problem Set 2: due 9/3/09 Problem Set 3: due 9/8/09
Class 5 Review; questions Assign (see Schedule for links) Slicing overview Problem Set 2: due 9/3/09 Problem Set 3: due 9/8/09 1 Data-flow Analysis Review Start at slide 21 of Basic Analysis 3 1 Static
More informationGeneralizing Data-flow Analysis
Generalizing Data-flow Analysis Announcements PA1 grades have been posted Today Other types of data-flow analysis Reaching definitions, available expressions, reaching constants Abstracting data-flow analysis
More information: Advanced Compiler Design Compu=ng DF(X) 3.4 Algorithm for inser=on of φ func=ons 3.5 Algorithm for variable renaming
263-2810: Advanced Compiler Design 3.3.2 Compu=ng DF(X) 3.4 Algorithm for inser=on of φ func=ons 3.5 Algorithm for variable renaming Thomas R. Gross Computer Science Department ETH Zurich, Switzerland
More informationOnline Cryptography Course. Using block ciphers. Review: PRPs and PRFs. Dan Boneh
Online Cryptography Course Using block ciphers Review: PRPs and PRFs Block ciphers: crypto work horse n bits PT Block n bits E, D CT Block Key k bits Canonical examples: 1. 3DES: n= 64 bits, k = 168 bits
More informationCSC D70: Compiler Optimization Dataflow-2 and Loops
CSC D70: Compiler Optimization Dataflow-2 and Loops Prof. Gennady Pekhimenko University of Toronto Winter 2018 The content of this lecture is adapted from the lectures of Todd Mowry and Phillip Gibbons
More informationCompiler Design Spring 2017
Compiler Design Spring 2017 8.6 Live variables Dr. Zoltán Majó Compiler Group Java HotSpot Virtual Machine Oracle Corporation Last lecture Definition: A variable V is live at point P if there is a path
More informationData-Flow Analysis. Compiler Design CSE 504. Preliminaries
Data-Flow Analysis Compiler Design CSE 504 1 Preliminaries 2 Live Variables 3 Data Flow Equations 4 Other Analyses Last modifled: Thu May 02 2013 at 09:01:11 EDT Version: 1.3 15:28:44 2015/01/25 Compiled
More informationSpace-aware data flow analysis
Space-aware data flow analysis C. Bernardeschi, G. Lettieri, L. Martini, P. Masci Dip. di Ingegneria dell Informazione, Università di Pisa, Via Diotisalvi 2, 56126 Pisa, Italy {cinzia,g.lettieri,luca.martini,paolo.masci}@iet.unipi.it
More informationStatic Program Analysis
Static Program Analysis Xiangyu Zhang The slides are compiled from Alex Aiken s Michael D. Ernst s Sorin Lerner s A Scary Outline Type-based analysis Data-flow analysis Abstract interpretation Theorem
More informationDataflow Analysis. Chapter 9, Section 9.2, 9.3, 9.4
Dataflow Analysis Chapter 9, Section 9.2, 9.3, 9.4 2 Dataflow Analysis Dataflow analysis is a sub area of static program analysis Used in the compiler back end for optimizations of three address code and
More informationA Functional Perspective
A Functional Perspective on SSA Optimization Algorithms Patryk Zadarnowski jotly with Manuel M. T. Chakravarty Gabriele Keller 19 April 2004 University of New South Wales Sydney THE PLAN ➀ Motivation an
More informationDataflow Analysis Lecture 2. Simple Constant Propagation. A sample program int fib10(void) {
-4 Lecture Dataflow Analysis Basic Blocks Related Optimizations Copyright Seth Copen Goldstein 00 Dataflow Analysis Last time we looked at code transformations Constant propagation Copy propagation Common
More informationIntroduction to data-flow analysis. Data-flow analysis. Control-flow graphs. Data-flow analysis. Example: liveness. Requirements
Data-flow analysis Michel Schinz based on material by Erik Stenman and Michael Schwartzbach Introduction to data-flow analysis Data-flow analysis Example: liveness Data-flow analysis is a global analysis
More informationwhere Q is a finite set of states
Space Complexity So far most of our theoretical investigation on the performances of the various algorithms considered has focused on time. Another important dynamic complexity measure that can be associated
More informationDataflow Analysis - 2. Monotone Dataflow Frameworks
Dataflow Analysis - 2 Monotone dataflow frameworks Definition Convergence Safety Relation of MOP to MFP Constant propagation Categorization of dataflow problems DataflowAnalysis 2, Sp06 BGRyder 1 Monotone
More informationFlow grammars a flow analysis methodology
Flow grammars a flow analysis methodology James S. Uhl and R. Nigel Horspool Dept. of Computer Science, University of Victoria P.O. Box 3055, Victoria, BC, Canada V8W 3P6 E-mail: juhl@csr.uvic.ca, nigelh@csr.uvic.ca
More information1 Trees. Listing 1: Node with two child reference. public class ptwochildnode { protected Object data ; protected ptwochildnode l e f t, r i g h t ;
1 Trees The next major set of data structures belongs to what s called Trees. They are called that, because if you try to visualize the structure, it kind of looks like a tree (root, branches, and leafs).
More informationMIT Loop Optimizations. Martin Rinard
MIT 6.035 Loop Optimizations Martin Rinard Loop Optimizations Important because lots of computation occurs in loops We will study two optimizations Loop-invariant code motion Induction variable elimination
More informationDesigning Information Devices and Systems I Spring 2018 Lecture Notes Note Introduction to Linear Algebra the EECS Way
EECS 16A Designing Information Devices and Systems I Spring 018 Lecture Notes Note 1 1.1 Introduction to Linear Algebra the EECS Way In this note, we will teach the basics of linear algebra and relate
More informationPath Testing and Test Coverage. Chapter 9
Path Testing and Test Coverage Chapter 9 Structural Testing Also known as glass/white/open box testing Structural testing is based on using specific knowledge of the program source text to define test
More informationLecture Overview SSA Maximal SSA Semipruned SSA o Placing -functions o Renaming Translation out of SSA Using SSA: Sparse Simple Constant Propagation
1 Lecture Overview SSA Maximal SSA Semipruned SSA o Placing -functions o Renaming Translation out of SSA Using SSA: Sparse Simple Constant Propagation [Chapter 9] 2 SSA Revisited It is desirable to use
More informationECE 5775 (Fall 17) High-Level Digital Design Automation. Scheduling: Exact Methods
ECE 5775 (Fall 17) High-Level Digital Design Automation Scheduling: Exact Methods Announcements Sign up for the first student-led discussions today One slot remaining Presenters for the 1st session will
More informationPath Testing and Test Coverage. Chapter 9
Path Testing and Test Coverage Chapter 9 Structural Testing Also known as glass/white/open box testing Structural testing is based on using specific knowledge of the program source text to define test
More informationDataflow Analysis. Dragon book, Chapter 9, Section 9.2, 9.3, 9.4
Dataflow Analysis Dragon book, Chapter 9, Section 9.2, 9.3, 9.4 2 Dataflow Analysis Dataflow analysis is a sub-area of static program analysis Used in the compiler back end for optimizations of three-address
More informationSTA 414/2104: Machine Learning
STA 414/2104: Machine Learning Russ Salakhutdinov Department of Computer Science! Department of Statistics! rsalakhu@cs.toronto.edu! h0p://www.cs.toronto.edu/~rsalakhu/ Lecture 2 Linear Least Squares From
More informationSIFT, GLOH, SURF descriptors. Dipartimento di Sistemi e Informatica
SIFT, GLOH, SURF descriptors Dipartimento di Sistemi e Informatica Invariant local descriptor: Useful for Object RecogniAon and Tracking. Robot LocalizaAon and Mapping. Image RegistraAon and SAtching.
More informationAlpha-Beta Pruning: Algorithm and Analysis
Alpha-Beta Pruning: Algorithm and Analysis Tsan-sheng Hsu tshsu@iis.sinica.edu.tw http://www.iis.sinica.edu.tw/~tshsu 1 Introduction Alpha-beta pruning is the standard searching procedure used for solving
More informationDesigning Information Devices and Systems I Fall 2018 Lecture Notes Note Introduction to Linear Algebra the EECS Way
EECS 16A Designing Information Devices and Systems I Fall 018 Lecture Notes Note 1 1.1 Introduction to Linear Algebra the EECS Way In this note, we will teach the basics of linear algebra and relate it
More information: Compiler Design. 9.5 Live variables 9.6 Available expressions. Thomas R. Gross. Computer Science Department ETH Zurich, Switzerland
252-210: Compiler Design 9.5 Live variables 9.6 Available expressions Thomas R. Gross Computer Science Department ETH Zurich, Switzerland Outline Warp up reaching definifons Live variables Available expressions
More informationEqualities and Uninterpreted Functions. Chapter 3. Decision Procedures. An Algorithmic Point of View. Revision 1.0
Equalities and Uninterpreted Functions Chapter 3 Decision Procedures An Algorithmic Point of View D.Kroening O.Strichman Revision 1.0 Outline Decision Procedures Equalities and Uninterpreted Functions
More informationRegister Allocation. Maryam Siahbani CMPT 379 4/5/2016 1
Register Allocation Maryam Siahbani CMPT 379 4/5/2016 1 Register Allocation Intermediate code uses unlimited temporaries Simplifying code generation and optimization Complicates final translation to assembly
More informationWriting Circuit Equations
2 C H A P T E R Writing Circuit Equations Objectives By the end of this chapter, you should be able to do the following: 1. Find the complete solution of a circuit using the exhaustive, node, and mesh
More informationMathematical Foundations of Programming. Nicolai Kraus. Draft of February 15, 2018
Very short lecture notes: Mathematical Foundations of Programming University of Nottingham, Computer Science, module code G54FOP, Spring 2018 Nicolai Kraus Draft of February 15, 2018 What is this? This
More informationData Flow Analysis (I)
Compiler Design Data Flow Analysis (I) Hwansoo Han Control Flow Graph What is CFG? Represents program structure for internal use of compilers Used in various program analyses Generated from AST or a sequential
More informationSoftware Testing Lecture 2
Software Testing Lecture 2 Justin Pearson September 25, 2014 1 / 1 Test Driven Development Test driven development (TDD) is a way of programming where all your development is driven by tests. Write tests
More informationProgram Verification as Probabilistic Inference
Program Verification as Probabilistic Inference Sumit Gulwani Microsoft Research, Redmond sumitg@microsoft.com Nebojsa Jojic Microsoft Research, Redmond jojic@microsoft.com Abstract In this paper, we propose
More informationConcurrent Vector Systems in Cartesian Coordinates
Concurrent Vector Systems in Cartesian Coordinates CARPERPETUATION (kar' pur pet u a shun) n. The act, when vacuuming, of running over a string or a piece of lint at least a dozen times, reaching over
More informationAlpha-Beta Pruning: Algorithm and Analysis
Alpha-Beta Pruning: Algorithm and Analysis Tsan-sheng Hsu tshsu@iis.sinica.edu.tw http://www.iis.sinica.edu.tw/~tshsu 1 Introduction Alpha-beta pruning is the standard searching procedure used for 2-person
More informationDataflow analysis. Theory and Applications. cs6463 1
Dataflow analysis Theory and Applications cs6463 1 Control-flow graph Graphical representation of runtime control-flow paths Nodes of graph: basic blocks (straight-line computations) Edges of graph: flows
More informationSparse Representa+on of Implicit Flows with Applica+ons to Side-Channel Detec+on. Bruno Rodrigues Diego Aranha Fernando Pereira
Sparse Representa+on of Implicit Flows with Applica+ons to Side-Channel Detec+on Bruno Rodrigues Diego Aranha Fernando Pereira Goal The goal of this work is to implement informa+on flow analysis precisely
More informationECE 5775 (Fall 17) High-Level Digital Design Automation. Control Flow Graph
ECE 5775 (Fall 17) High-Level Digital Design Automation Control Flow Graph Announcements ECE colloquium on Monday 9/11 from 4:30pm, PHL 233 Smart Healthcare by Prof. Niraj Jha of Princeton Lab 1 is due
More informationFoundations of
91.304 Foundations of (Theoretical) Computer Science Chapter 3 Lecture Notes (Section 3.2: Variants of Turing Machines) David Martin dm@cs.uml.edu With some modifications by Prof. Karen Daniels, Fall 2012
More informationCSE 331 Winter 2018 Reasoning About Code I
CSE 331 Winter 2018 Reasoning About Code I Notes by Krysta Yousoufian Original lectures by Hal Perkins Additional contributions from Michael Ernst, David Notkin, and Dan Grossman These notes cover most
More informationLecture 4 Introduc-on to Data Flow Analysis
Lecture 4 Introduc-on to Data Flow Analysis I. Structure of data flow analysis II. Example 1: Reaching defini?on analysis III. Example 2: Liveness analysis IV. Generaliza?on 15-745: Intro to Data Flow
More informationHow many hours would you estimate that you spent on this assignment?
The first page of your homework submission must be a cover sheet answering the following questions. Do not leave it until the last minute; it s fine to fill out the cover sheet before you have completely
More informationRegister Alloca.on. CMPT 379: Compilers Instructor: Anoop Sarkar. anoopsarkar.github.io/compilers-class
Register Alloca.on CMPT 379: Compilers Instructor: Anoop Sarkar anoopsarkar.github.io/compilers-class 1 Register Alloca.on Intermediate code uses unlimited temporaries Simplifying code genera.on and op.miza.on
More informationCSC 5170: Theory of Computational Complexity Lecture 4 The Chinese University of Hong Kong 1 February 2010
CSC 5170: Theory of Computational Complexity Lecture 4 The Chinese University of Hong Kong 1 February 2010 Computational complexity studies the amount of resources necessary to perform given computations.
More informationThe Chameleons of Camelot
The Chameleons of Camelot João F. Ferreira joao@joaoff.com Last changed: July 27, 2009 Brief description and goals This scenario presents a generalization of the problem The Chameleons of Camelot, found
More informationSparse Analysis of Variable Path Predicates Based Upon SSA-Form
Sparse Analysis of Variable Path Predicates Based Upon SSA-Form Thomas S. Heinze and Wolfram Amme Institute of Computer Science, Friedrich Schiller University Jena, Germany {t.heinze,wolfram.amme}@uni-jena.de
More informationOptimizing Intra-Task Voltage Scheduling Using Data Flow Analysis Λ
Optimizing Intra-Task Voltage Scheduling Using Data Flow Analysis Λ Dongkun Shin Jihong Kim School of CSE School of CSE Seoul National University Seoul National University Seoul, Korea 151-742 Seoul, Korea
More informationLecture 5 Introduction to Data Flow Analysis
Lecture 5 Introduction to Data Flow Analysis I. Structure of data flow analysis II. III. IV. Example 1: Reaching definition analysis Example 2: Liveness analysis Framework Phillip B. Gibbons 15-745: Intro
More informationConstant Propagation w/ SSA- and Predicated SSA Form
Constant Propagation w/ SSA- and Predicated SSA Form Jens Knoop Vienna University of Technology, Austria This is joint work with Oliver Rüthing Outline of the Talk Part I: Constant Propagation Part II:
More informationTopics on Compilers
Assignment 2 4541.775 Topics on Compilers Sample Solution 1. Test for dependences on S. Write down the subscripts. Which positions are separable, which are coupled? Which dependence test would you apply
More informationA.I. in health informatics lecture 3 clinical reasoning & probabilistic inference, II *
A.I. in health informatics lecture 3 clinical reasoning & probabilistic inference, II * kevin small & byron wallace * Slides borrow heavily from Andrew Moore, Weng- Keen Wong and Longin Jan Latecki today
More informationCSE 331 Winter 2018 Homework 1
Directions: - Due Wednesday, January 10 by 11 pm. - Turn in your work online using gradescope. You should turn in a single pdf file. You can have more than one answer per page, but please try to avoid
More informationMath 471 (Numerical methods) Chapter 3 (second half). System of equations
Math 47 (Numerical methods) Chapter 3 (second half). System of equations Overlap 3.5 3.8 of Bradie 3.5 LU factorization w/o pivoting. Motivation: ( ) A I Gaussian Elimination (U L ) where U is upper triangular
More informationLinear Programming The Simplex Algorithm: Part II Chapter 5
1 Linear Programming The Simplex Algorithm: Part II Chapter 5 University of Chicago Booth School of Business Kipp Martin October 17, 2017 Outline List of Files Key Concepts Revised Simplex Revised Simplex
More informationData flow analysis. DataFlow analysis
Data flow analysis DataFlow analysis compile time reasoning about the runtime flow of values in the program represent facts about runtime behavior represent effect of executing each basic block propagate
More informationSearch and Lookahead. Bernhard Nebel, Julien Hué, and Stefan Wölfl. June 4/6, 2012
Search and Lookahead Bernhard Nebel, Julien Hué, and Stefan Wölfl Albert-Ludwigs-Universität Freiburg June 4/6, 2012 Search and Lookahead Enforcing consistency is one way of solving constraint networks:
More informationLexical Analysis Part II: Constructing a Scanner from Regular Expressions
Lexical Analysis Part II: Constructing a Scanner from Regular Expressions CS434 Spring 2005 Department of Computer Science University of Alabama Joel Jones Copyright 2003, Keith D. Cooper, Ken Kennedy
More informationCSE 331 Software Design & Implementation
CSE 331 Software Design & Implementation Kevin Zatloukal Summer 2017 Lecture 2 Reasoning About Code With Logic (Based on slides by Mike Ernst, Dan Grossman, David Notkin, Hal Perkins, Zach Tatlock) Recall
More informationScalar Optimisation Part 2
Scalar Optimisation Part 2 Michael O Boyle January 2014 1 Course Structure L1 Introduction and Recap 4-5 lectures on classical optimisation 2 lectures on scalar optimisation Last lecture on redundant expressions
More informationComputational Models Lecture 8 1
Computational Models Lecture 8 1 Handout Mode Ronitt Rubinfeld and Iftach Haitner. Tel Aviv University. May 11/13, 2015 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice
More informationPredicate abstrac,on and interpola,on. Many pictures and examples are borrowed from The So'ware Model Checker BLAST presenta,on.
Predicate abstrac,on and interpola,on Many pictures and examples are borrowed from The So'ware Model Checker BLAST presenta,on. Outline. Predicate abstrac,on the idea in pictures 2. Counter- example guided
More informationClass Note #14. In this class, we studied an algorithm for integer multiplication, which. 2 ) to θ(n
Class Note #14 Date: 03/01/2006 [Overall Information] In this class, we studied an algorithm for integer multiplication, which improved the running time from θ(n 2 ) to θ(n 1.59 ). We then used some of
More informationReasoning About Imperative Programs. COS 441 Slides 10b
Reasoning About Imperative Programs COS 441 Slides 10b Last time Hoare Logic: { P } C { Q } Agenda If P is true in the initial state s. And C in state s evaluates to s. Then Q must be true in s. Program
More informationAlpha-Beta Pruning: Algorithm and Analysis
Alpha-Beta Pruning: Algorithm and Analysis Tsan-sheng Hsu tshsu@iis.sinica.edu.tw http://www.iis.sinica.edu.tw/~tshsu 1 Introduction Alpha-beta pruning is the standard searching procedure used for 2-person
More informationTree sets. Reinhard Diestel
1 Tree sets Reinhard Diestel Abstract We study an abstract notion of tree structure which generalizes treedecompositions of graphs and matroids. Unlike tree-decompositions, which are too closely linked
More informationModern Algebra Prof. Manindra Agrawal Department of Computer Science and Engineering Indian Institute of Technology, Kanpur
Modern Algebra Prof. Manindra Agrawal Department of Computer Science and Engineering Indian Institute of Technology, Kanpur Lecture 02 Groups: Subgroups and homomorphism (Refer Slide Time: 00:13) We looked
More informationLecture 2: Divide and conquer and Dynamic programming
Chapter 2 Lecture 2: Divide and conquer and Dynamic programming 2.1 Divide and Conquer Idea: - divide the problem into subproblems in linear time - solve subproblems recursively - combine the results in
More informationControl Dependence. Stanford University CS243 Winter 2006 Wei Li 1
Control Dependence Wei Li 1 Control Dependence Introduction Formal Definition Optimal Control Dependence Computation 2 xample START a b c d CFG ND b is control dependent on a c is control dependent on
More informationSocio- Ecological Systems as Complex Systems
Socio- Ecological Systems as Complex Systems Slides prepared by Ana Elena Escalante Basin by Hallie Eakin, Ana E Escalante, Lakshmi Charli- Joseph and Beth Tellman is licensed under a CreaAve Commons ACribuAon-
More informationProof Techniques (Review of Math 271)
Chapter 2 Proof Techniques (Review of Math 271) 2.1 Overview This chapter reviews proof techniques that were probably introduced in Math 271 and that may also have been used in a different way in Phil
More informationCommunication Engineering Prof. Surendra Prasad Department of Electrical Engineering Indian Institute of Technology, Delhi
Communication Engineering Prof. Surendra Prasad Department of Electrical Engineering Indian Institute of Technology, Delhi Lecture - 41 Pulse Code Modulation (PCM) So, if you remember we have been talking
More informationMotivation. Dictionaries. Direct Addressing. CSE 680 Prof. Roger Crawfis
Motivation Introduction to Algorithms Hash Tables CSE 680 Prof. Roger Crawfis Arrays provide an indirect way to access a set. Many times we need an association between two sets, or a set of keys and associated
More informationSpecial Nodes for Interface
fi fi Special Nodes for Interface SW on processors Chip-level HW Board-level HW fi fi C code VHDL VHDL code retargetable compilation high-level synthesis SW costs HW costs partitioning (solve ILP) cluster
More informationScattering amplitudes in Einstein-Yang-Mills and other supergravity theories
Scattering amplitudes in Einstein-Yang-Mills and other supergravity theories Radu Roiban Pennsylvania State U. Based on work with M. Chiodaroli, M. Gunaydin and H. Johansson and Z. Bern, JJ Carrasco, W-M.
More informationScalar Optimisation Part 1
calar Optimisation Part 1 Michael O Boyle January, 2014 1 Course tructure L1 Introduction and Recap 4/5 lectures on classical optimisation 2 lectures on scalar optimisation Today example optimisations
More informationEconomics 205, Fall 2002: Final Examination, Possible Answers
Economics 05, Fall 00: Final Examination, Possible Answers Comments on the Exam Grades: 43 possible; high: 413; median: 34; low: 36 I was generally happy with the answers to questions 3-8, satisfied with
More informationFormal Reasoning CSE 331. Lecture 2 Formal Reasoning. Announcements. Formalization and Reasoning. Software Design and Implementation
CSE 331 Software Design and Implementation Lecture 2 Formal Reasoning Announcements Homework 0 due Friday at 5 PM Heads up: no late days for this one! Homework 1 due Wednesday at 11 PM Using program logic
More informationComputational Models Lecture 8 1
Computational Models Lecture 8 1 Handout Mode Nachum Dershowitz & Yishay Mansour. Tel Aviv University. May 17 22, 2017 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice
More informationLecture 8 HASHING!!!!!
Lecture 8 HASHING!!!!! Announcements HW3 due Friday! HW4 posted Friday! Q: Where can I see examples of proofs? Lecture Notes CLRS HW Solutions Office hours: lines are long L Solutions: We will be (more)
More informationRussell s logicism. Jeff Speaks. September 26, 2007
Russell s logicism Jeff Speaks September 26, 2007 1 Russell s definition of number............................ 2 2 The idea of reducing one theory to another.................... 4 2.1 Axioms and theories.............................
More information