
Improving Data-flow Analysis with Path Profiles* Glenn Ammons James R. Larust [email protected] [email protected] Department of Computer Sciences University of Wisconsin-Madison 1210 West Dayton St. Madison, WI 53706 Abstract can aid a compiler in optimizing these heavily executed por- tions of a program. Path-qualified data-flow analysis con- Data-flow analysis computes its solutions over the paths in sists of the following steps: a control-flow graph. These paths-whether feasible or in- feasible, heavily or rarely executed-contribute equally to a 1. Identify hot paths by profiling a program. We use a solution. However, programs execute only a small fraction Ba&Larus path profile [BL96] to determine how often of their potential paths and, moreover, programs’ execution acyclic paths in a program execute. time and cost is concentrated in a far smaller subset of hot 2. Identify and isolate the hot paths in the program’s paths. control-flow graph (CFG). This step produces a new This paper describes a new approach to analyzing and CFG in which each hot path is duplicated. Since a optimizing programs, which improves the precision of data hot path is separated from other paths, data-flow facts flow analysis along hot paths. Our technique identifies along the path do not merge with facts from other, and duplicates hot paths, creating a hot path graph in overlapping paths. Moreover, as programs do not exe- which these paths are isolated. After flow analysis, the cute many hot paths, this hot-path graph (HPG) is not graph is reduced to eliminate unnecessary duplicates of un- much larger than the original graph. profitable paths. In experiments on SPEC95 benchmarks, path qualification identified 2-112 times more non-local con- 3. Perform data-flow analysis on the HPG. The solutions stants (weighted dynamically) than the Wegman-Zadek con- found by this technique are conservative in the hot ditional constant algorithm, which translated into l-7% path graph-not in the original control-flow graph. more dynamic instructions with constant results. 4. Reduce the graph to preserve only valuable solutions. The HPG duplicates code for paths whose solutions 1 Introduction did not improve. Extra code both increases the cost of subsequent compiler analyses and adversely affects a processor’s instruction cache and branch predictor. Data-flow analysis computes its solutions over the paths in Reduction uses results from the data-flow analysis a control-flow graph. The well-known, meet-over-all-paths and formulation produces safe, precise solutions for general data- frequencies from the path profile to decide which paths flow problems. All paths-whether feasible or infeasible, to preserve in the TI&K~ hot-path graph (THPG). heavily or rarely executed-contribute equally to a solution. 5. Translate the original path profile into a path pro- This egalitarian approach, unfortunately, is at odds with file for the rHPG, so profiling information is avail- the realities of program behavior. Even moderately large able for subsequent analyses and optimizations. Ball- programs execute only a few tens of thousands of paths (out Lams path profiles are determined by a set of recording of a universe of billions of acyclic paths) and, moreover, edges, which start and end paths. The algorithm that programs’ execution time and cost is concentrated in a far produces an HPG also identifies recording edges in the smaller subset of hot paths [BL96, ABL97]. HPG, which allows interpretation of the original path This paper presents a new data-flow analysis technique profile as a path profile of the HPG. The reduction that attempts to compute more precise solutions along the step properly maintains these recording edges. hot paths in a program. Improved analysis along these paths The technique can be applied to any data-flow prob- “This research supported by: NSF NY1 Award CCR-9357779, with lem, although this paper focuses on constant propagation. support from Sun Microsystems and Intel, and NSF Grant MIP- In experiments on SPEC95 benchmarks, path qualification 9625558. ‘On sabbatical at Microsoft Research. identified 2-112 times more non-local constants (weighted dynamically) than the Wegman-Zadek conditional constant Permission 10 make digital or hard copies of all or pan of this wcrk for algorithm, which translated into l-7% more dynamic in- personal or classroom use is granted without ka provided that structions with constant results. Moreover, the technique is copies are not made or distributed for profit or ccmmwcial advan- tage and that copies bear this notice and the full citation on the first page. practical. With the exception of the go benchmark, the hot- To copy otherwise, 10 republish, 10 pcsf on sawen w 10 path graphs were 3-32% larger and the reduced hot-path redistributa 10 lists, requires prior specific psrmiasion and/w a fw. graphs were only l-7% larger than the original CFG. On SIGPLAN ‘98 Montrasl, Canada @ 1998 ACM 0-89791~987.4/98/0006...$5.00 72 go, the hot-path graphs were 184% larger and the reduced l It describes how to reduce the hot-path graph, by elim- hot-path graphs 70% larger. inating paths that prove unnecessary or unprofitable. l It shows how to preserve path-profiling information 1.1 Qualified Flow Analysis through the CFG transformations. Our implementation is based on Holley and Rosen’s qual- ified flow analysis technique [HR~I]. A qualified data-flow l It applies path qualification to constant propagation problem is a conventional data-flow problem together with and demonstrates a significant improvement over the a deterministic finite automaton, A, whose transitions are widely-used Wegman-Zadek technique. labelled by the edges of the control-flow graph, G. A en- codes additional information about the program-in path- qualified analysis, it recognizes hot paths. Data-flow analy- 1.3 Outline of the Paper sis answers questions of the form “What can be said about This paper is structured as follows. Section 2 sketches the the data-flow value at vertex v?” Qualified data-flow analy- theoretical groundwork and formalizes path profiles. Sec- sis answers questions of the form “What can be said about tion 3 describes the automaton that recognizes the hot path the data-flow value at vertex v given that A is in state q?” in the profile. Section 4 shows how data-flow tracing con- Holley and Rosen used qualified data-flow analysis to structs a new control-flow graph with duplicated hot paths. identify infeasible paths and exclude them from analysis. Section 5 shows how to reduce the traced graph. Section 6 They created an automaton in which infeasible paths ended presents the results of our experiments on SPEC95 bench- in a failure state. The best solution at v, given that A is not marks. Section 7 discusses related work. in the failure state, is the meet over the non-failure states of A. For path qualification, we use the Aho-Corasick al- gorithm [Aho94] to construct an automaton that recognizes 2 Preliminaries hot paths in a path profile. Holley and Rosen describe two techniques for solving This section states definitions and theorems used in the rest qualified problems, data-flow tracing and conted tupling. of this paper. This paper uses data-flow tracing, which constructs a new graph GA whose vertices encode the vertex from G and the state from A. The qualified problem is then solved as a con- 2.1 Data Flow Problems ventional data-flow problem over GA-qualified solutions in G have become true solutions in GA. GA is, of course, our We begin with standard definitions of data-flow problems hot-path graph. and their solutions. The qualified solution is never lower in the lattice than the unqualified solution. To see why, consider the solution Definition 1 A monotonic data-flow problem D is a tuple at vertex v of G. If P is the set of all paths from routine (L, A, F, G,r, l,, M) where: entry to v and I, is the data-flow value from path p E P, then the meet-over-all-paths solution 1, at v is given by l L is a complete semilattice with meet operation A. 1, = A 1,. l F is a set of monotonic functions from L to L. PEP Now partition P by the state of A. If Q is the set of l G = (V, E) is a control-flow graph with entry vertex r. states of A, Pp C_P is the set of paths in P that drive A to state q E Q. It is clear that l 1, E L is the data-pow fact associated with I-. l M : E + F maps the edges of G to functions in F. A 1, = A A 1,. PEP nEQ PEP, M can be extended to map every path p = [eo, el, . , ek] Or, omitting the outer meet on the right hand side and in G to a function f : L + L: converting the equality to an inequality, for all q E Q f = M(p) = M(ek) 0 M(ek-1) 0 . 0 M(eo) The next three definitions come from Holley and PEP PEP, Rosen p~8i]. The inequality is not strict, so the qualified solution is not necessarily sharper than the meet-over-all-paths solu- Definition 2 A solution I of D is a map I : V + L such tion. However, when it is sharper, it is doubly beneficial to that, for any path p from r to a vertex: u, I(u) < (M(p))&). find this increased precision in heavily executed code. Definition 3 A fixpoint J of D is a map J : V -+ L such 1.2 Contributions that J(r) 5 I, and, if e is an edge from vertex u to vertex v, J(v) 5 (M(e))(J(u))- This paper makes four contributions: l It shows how path profiles can improve the precision Definition 4 A good solution I of D is a solution of D of data-flow analysis through guided code duplication.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages13 Page
-
File Size-