Parallel Flow-Sensitive Pointer Analysis by Graph-Rewriting Vaivaswatha Nagaraj R. Govindarajan Indian Institute of Science, Bangalore PACT 2013 PACT'13
2 Outline ● Introduction ● Background ● Flow-sensitive graph-rewriting formulation ● Implementation and Results ● Conclusion Vaivaswatha Nagaraj (IISc, Bangalore) PACT'13
3 Outline ● Introduction Introduction ● Background ● Flow-sensitive graph-rewriting formulation ● Implementation and Results ● Conclusion Vaivaswatha Nagaraj (IISc, Bangalore) PACT'13
4 Flow-sensitive pointer analysis x = &a 1 y = &b 2 3 z = x z = y z points-to {?} z points-to {?} 4 Vaivaswatha Nagaraj (IISc, Bangalore) PACT'13
5 Flow-sensitive pointer analysis x = &a 1 x points-to a y points-to b y = &b 2 3 z = x z = y x points-to a x points-to a y points-to b y points-to b z points-to a z points-to b 4 Vaivaswatha Nagaraj (IISc, Bangalore) PACT'13
6 Flow-sensitive vs flow-insensitive x = &a 1 x points-to a y points-to b y = &b 2 3 z = x z = y x points-to a x points-to a y points-to b y points-to b z points-to { a,b } z points-to {a, b } 4 Vaivaswatha Nagaraj (IISc, Bangalore) PACT'13
7 Outline ● Introduction ● Background – Staged flow-sensitive analysis Staged flow-sensitive analysis – Graph-rewriting ● Flow-sensitive graph-rewriting formulation ● Implementation and Results ● Conclusion Vaivaswatha Nagaraj (IISc, Bangalore) PACT'13
8 Staged flow-sensitive pointer analysis [Flow-sensitive pointer analysis for millions of lines of code – Ben Hardekopf. et al. - CGO'11] ● Scales to large programs ● Faster, less precise analysis used to speed up the primary analysis Vaivaswatha Nagaraj (IISc, Bangalore) PACT'13
9 Staged flow-sensitive pointer analysis [Flow-sensitive pointer analysis for millions of lines of code – Ben Hardekopf. et al. - CGO'11] ● Scales to large programs ● Faster, less precise analysis used to speed up the primary analysis Our goal: Parallelize the staged flow-sensitive pointer analysis Vaivaswatha Nagaraj (IISc, Bangalore) PACT'13
10 Staged flow-sensitive analysis [Flow-sensitive pointer analysis for millions of lines of code – Ben Hardekopf. et al. - CGO'11] x 1 points-to { a , b } a points-to {p,q} b points-to {r,s} 1 *x 1 = u 1 2 v 1 = *y 1 w 1 = *z 1 3 In a traditional analysis, points-to info of both a & b will be propagated to both 2 and 3 Vaivaswatha Nagaraj (IISc, Bangalore) PACT'13
11 Staged flow-sensitive analysis [Flow-sensitive pointer analysis for millions of lines of code – Ben Hardekopf. et al. - CGO'11] x 1 points-to { a , b } a points-to {p,q} b points-to {r,s} 1 *x 1 = u 1 z 1 points-to { a } y 1 points-to { b } 2 v 1 = *y 1 w 1 = *z 1 3 Vaivaswatha Nagaraj (IISc, Bangalore) PACT'13
12 Staged flow-sensitive analysis [Flow-sensitive pointer analysis for millions of lines of code – Ben Hardekopf. et al. - CGO'11] x 1 points-to { a , b } a points-to {p,q} b points-to {r,s} 1 *x 1 = u 1 z 1 points-to { a } y 1 points-to { b } 2 v 1 = *y 1 w 1 = *z 1 3 Points-to info of only Points-to info of only b is required here a is required here Vaivaswatha Nagaraj (IISc, Bangalore) PACT'13
13 Staged flow-sensitive analysis [Flow-sensitive pointer analysis for millions of lines of code – Ben Hardekopf. et al. - CGO'11] How does staged analysis work? (1) Use a fast analysis to get less precise points-to information 1 *x 1 = u 1 2 v 1 = *y 1 w 1 = *z 1 3 x 1 → { a,b } z 1 → { a } *w 1 = t 2 4 y 1 → { b } w 1 → { c } Vaivaswatha Nagaraj (IISc, Bangalore) PACT'13
14 Staged flow-sensitive analysis [Flow-sensitive pointer analysis for millions of lines of code – Ben Hardekopf. et al. - CGO'11] How does staged analysis work? (2) Use the less precise info to find variables potentially (1) Use a fast analysis referenced at indirections to get less precise 1 *x 1 = u 1 points-to information a 1 = (a 0 ) b 1 = (b 0 ) µ(a 1 ) 2 v 1 = *y 1 w 1 = *z 1 3 x 1 → { a,b } z 1 → { a } µ(b 1 ) *w 1 = t 2 4 y 1 → { b } w 1 → { c } c 2 = (c 1 ) Vaivaswatha Nagaraj (IISc, Bangalore) PACT'13
15 Staged flow-sensitive analysis [Flow-sensitive pointer analysis for millions of lines of code – Ben Hardekopf. et al. - CGO'11] How does staged analysis work? 1 *x 1 = u 1 Flow-sensitivity - a 1 = (a 0 ) All variables in SSA form b 1 = (b 0 ) µ(a 1 ) 2 v 1 = *y 1 w 1 = *z 1 3 µ(b 1 ) *w 1 = t 2 4 c 2 = (c 1 ) Vaivaswatha Nagaraj (IISc, Bangalore) PACT'13
16 Staged flow-sensitive analysis [Flow-sensitive pointer analysis for millions of lines of code – Ben Hardekopf. et al. - CGO'11] How does staged analysis work? (3) Build def-use chains and propagate only along these chains 1 *x 1 = u 1 Flow-sensitivity - a 1 = (a 0 ) All variables in SSA form b 1 = (b 0 ) µ(a 1 ) 2 v 1 = *y 1 w 1 = *z 1 3 µ(b 1 ) *w 1 = t 2 4 Propagation of information c 2 = (c 1 ) is thus optimized Vaivaswatha Nagaraj (IISc, Bangalore) PACT'13
17 Parallelizing the staged analysis Can the staged flow-sensitive pointer analysis be parallelized and scaled to multiple cores? Vaivaswatha Nagaraj (IISc, Bangalore) PACT'13
18 Towards a parallel algorithm ● Flow-insensitive pointer analysis has already been parallelized # ● Parallelization of flow-insensitive analysis involves transforming it to a graph-rewriting problem – expose amorphous data-parallelism # [Parallel Inclusion-based Points-to Analysis - Mario Mendez-Lojo, et al. - OOPSLA'10] Vaivaswatha Nagaraj (IISc, Bangalore) PACT'13
19 Towards a parallel algorithm ● Flow-insensitive pointer analysis has already been parallelized # ● Parallelization of flow-insensitive analysis involves transforming it to a graph-rewriting problem – expose amorphous data-parallelism Our goal: Parallelize the staged flow-sensitive pointer analysis Formulate it as a graph-rewriting problem # [Parallel Inclusion-based Points-to Analysis - Mario Mendez-Lojo, et al. - OOPSLA'10] Vaivaswatha Nagaraj (IISc, Bangalore) PACT'13
20 Outline ● Introduction ● Background – Staged flow-sensitive analysis – Graph-rewriting Graph-rewriting ● Flow-sensitive graph-rewriting formulation ● Implementation and Results ● Conclusion Vaivaswatha Nagaraj (IISc, Bangalore) PACT'13
21 Graph-rewriting [Parallel Inclusion-based Points-to Analysis - Mario Mendez-Lojo, et al. - OOPSLA'10] Points-to constraint Constraint graph p x a x = &a c x y y = x Vaivaswatha Nagaraj (IISc, Bangalore) PACT'13
22 Graph-rewriting [Parallel Inclusion-based Points-to Analysis - Mario Mendez-Lojo, et al. - OOPSLA'10] Points-to constraint Constraint graph p x a x = &a c x y y = x p p x a x a Apply rewrite-rule c c p y y Example: copy rewrite rule Vaivaswatha Nagaraj (IISc, Bangalore) PACT'13
23 Outline ● Introduction ● Background ● Flow-sensitive graph-rewriting formulation Flow-sensitive graph-rewriting formulation ● Implementation and Results ● Conclusion Vaivaswatha Nagaraj (IISc, Bangalore) PACT'13
24 Graph-rewriting formulation 1 *x 1 = u 1 a 1 = (a 0 ) b 1 = (b 0 ) µ(a 1 ) 2 v 1 = *y 1 w 1 = *z 1 3 µ(b 1 ) *w 1 = t 2 4 c 2 = (c 1 ) Graph: Nodes: Variables in the program Edges: Points-to, copy, load, store, etc ... Rewrite rules? Vaivaswatha Nagaraj (IISc, Bangalore) PACT'13
25 Challenges Directly using the flow-insensitive graph formulation for flow-sensitive analysis leads to the following challenges ● Spurious edges – leads to imprecision ● Strong and weak updates at store constraints are not handled Vaivaswatha Nagaraj (IISc, Bangalore) PACT'13
26 Challenges Directly using the flow-insensitive graph formulation for flow-sensitive analysis leads to the following challenges ● Spurious edges – leads to imprecision – Solution: potential edges ● Strong and weak updates at store constraints are not handled – Solution: klique nodes Vaivaswatha Nagaraj (IISc, Bangalore) PACT'13
27 Outline ● Introduction ● Background ● Flow-sensitive graph-rewriting formulation – Problem of spurious edges Problem of spurious edges – Handling strong and weak updates ● Implementation and Results ● Conclusion Vaivaswatha Nagaraj (IISc, Bangalore) PACT'13
28 Spurious edges - Load rule for flow-insensitive analysis: Points-to constraints y 1 = &a x 1 = *y 1 Vaivaswatha Nagaraj (IISc, Bangalore) PACT'13
29 Spurious edges - Load rule for flow-insensitive analysis: Formulate graph Points-to constraints p y 1 = &a y 1 a l x 1 = *y 1 x 1 Vaivaswatha Nagaraj (IISc, Bangalore) PACT'13
30 Spurious edges - Load rule for flow-insensitive analysis: Formulate graph Apply load rule Points-to constraints p p y 1 = &a y 1 y 1 a a l l x 1 = *y 1 c x 1 x 1 Vaivaswatha Nagaraj (IISc, Bangalore) PACT'13
31 Spurious edges - Load rule for flow-insensitive analysis: Formulate graph Apply load rule Points-to constraints p p y 1 = &a y 1 y 1 a a l l x 1 = *y 1 c x 1 x 1 - Loss of precision when used for flow-sensitive analysis: x 1 = *y 1 µ(a 1 ) z 1 = *y 1 µ(a 2 ) Vaivaswatha Nagaraj (IISc, Bangalore) PACT'13
Recommend
More recommend