Interprocedural Path Profiling David Melski Thomas Reps University of Wisconsin.

Slides:



Advertisements
Similar presentations
Analyzing Regression Test Selection Techniques
Advertisements

Overview Structural Testing Introduction – General Concepts
Course Outline Traditional Static Program Analysis –Theory Compiler Optimizations; Control Flow Graphs Data-flow Analysis – today’s class –Classic analyses.
1 CS 201 Compiler Construction Lecture Interprocedural Data Flow Analysis.
Bebop: A Symbolic Model Checker for Boolean Programs Thomas Ball Sriram K. Rajamani
22C:19 Discrete Structures Trees Spring 2014 Sukumar Ghosh.
1 Constant Propagation for Loops with Factored Use-Def Chains Reporter : Lai, Yen-Chang.
Interprocedural Slicing using Dependence Graphs Susan Horwitz, Thomas Reps, and David Binkley University of Wisconsin-Madison.
Graphs Graphs are the most general data structures we will study in this course. A graph is a more general version of connected nodes than the tree. Both.
Midwestern State University Department of Computer Science Dr. Ranette Halverson CMPS 2433 CHAPTER 4 - PART 2 GRAPHS 1.
Interprocedural analysis © Marcelo d’Amorim 2010.
Recap from last time We were trying to do Common Subexpression Elimination Compute expressions that are available at each program point.
Specialized Reference Counting Garbage Collection using Data Structure Annotations By Eric Watkins and Dzin Avots for CS 343 Spring 2002.
Feedback: Keep, Quit, Start
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Advanced Compilers CMPSCI 710.
Improving code generation. Better code generation requires greater context Over expressions: optimal ordering of subtrees Over basic blocks: Common subexpression.
The Use of Program Profiling for Software Maintenance with Applications to the Year 2000 Problem Thomas Reps, Thomas Ball, Manuvir Das, and James Larus.
ECE1724F Compiler Primer Sept. 18, 2002.
CS 206 Introduction to Computer Science II 11 / 10 / 2008 Instructor: Michael Eckmann.
Previous finals up on the web page use them as practice problems look at them early.
Improving Data-flow Analysis with Path Profiles ● Glenn Ammons & James R. Larus ● University of Wisconsin-Madison ● 1998 ● Presented by Jessica Friis.
Incremental Path Profiling Kevin Bierhoff and Laura Hiatt Path ProfilingIncremental ApproachExperimental Results Path profiling counts how often each path.
Interprocedural Analysis Noam Rinetzky Mooly Sagiv Tel Aviv University Textbook Chapter 2.5.
DAST 2005 Tirgul 12 (and more) sample questions. DAST 2005 Q.We’ve seen that solving the shortest paths problem requires O(VE) time using the Belman-Ford.
Comparison Caller precisionCallee precisionCode bloat Inlining context-insensitive interproc Context sensitive interproc Specialization.
Improving Code Generation Honors Compilers April 16 th 2002.
Schedule Midterm out tomorrow, due by next Monday Final during finals week Project updates next week.
Pointer analysis. Pointer Analysis Outline: –What is pointer analysis –Intraprocedural pointer analysis –Interprocedural pointer analysis Andersen and.
Prof. Bodik CS 164 Lecture 16, Fall Global Optimization Lecture 16.
Procedure Optimizations and Interprocedural Analysis Chapter 15, 19 Mooly Sagiv.
Impact Analysis of Database Schema Changes Andy Maule, Wolfgang Emmerich and David S. Rosenblum London Software Systems Dept. of Computer Science, University.
1 ECE 453 – CS 447 – SE 465 Software Testing & Quality Assurance Instructor Kostas Kontogiannis.
1 Introduction to Parsing Lecture 5. 2 Outline Regular languages revisited Parser overview Context-free grammars (CFG’s) Derivations.
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
Fixed Parameter Complexity Algorithms and Networks.
Precise Interprocedural Dataflow Analysis via Graph Reachibility
Software (Program) Analysis. Automated Static Analysis Static analyzers are software tools for source text processing They parse the program text and.
P ath & E dge P rofiling Michael Bond, UT Austin Kathryn McKinley, UT Austin Continuous Presented by: Yingyi Bu.
Dataflow Frequency Analysis based on Whole Program Paths Eduard Mehofer Institute for Software Science University of Vienna
Graphs Data Structures and Algorithms A. G. Malamos Reference Algorithms, 2006, S. Dasgupta, C. H. Papadimitriou, and U. V. Vazirani Introduction to Algorithms,Third.
Predicated Static Single Assignment (PSSA) Presented by AbdulAziz Al-Shammari
Auther: Kevian A. Roudy and Barton P. Miller Speaker: Chun-Chih Wu Adviser: Pao, Hsing-Kuo.
1 Program Slicing Amir Saeidi PhD Student UTRECHT UNIVERSITY.
Graphs, Puzzles, & Map Coloring
Data Structure Introduction.
Compiler Principles Fall Compiler Principles Lecture 0: Local Optimizations Roman Manevich Ben-Gurion University.
Graphs. Definitions A graph is two sets. A graph is two sets. –A set of nodes or vertices V –A set of edges E Edges connect nodes. Edges connect nodes.
Targeted Path Profiling : Lower Overhead Path Profiling for Staged Dynamic Optimization Systems Rahul Joshi, UIUC Michael Bond*, UT Austin Craig Zilles,
Whole Program Paths James R. Larus. Outline 1. Find acyclic path fragments 2. Convert into whole-program path 3. Determine hot subpaths.
Practical Path Profiling for Dynamic Optimizers Michael Bond, UT Austin Kathryn McKinley, UT Austin.
Targeted Path Profiling : Lower Overhead Path Profiling for Staged Dynamic Optimization Systems Rahul Joshi, UIUC Michael Bond*, UT Austin Craig Zilles,
1 Control Flow Analysis Topic today Representation and Analysis Paper (Sections 1, 2) For next class: Read Representation and Analysis Paper (Section 3)
Author: Haoyu Song, Murali Kodialam, Fang Hao and T.V. Lakshman Publisher/Conf. : IEEE International Conference on Network Protocols (ICNP), 2009 Speaker:
CS412/413 Introduction to Compilers Radu Rugina Lecture 18: Control Flow Graphs 29 Feb 02.
1 Control Flow Graphs. 2 Optimizations Code transformations to improve program –Mainly: improve execution time –Also: reduce program size Can be done.
1 Software Testing & Quality Assurance Lecture 13 Created by: Paulo Alencar Modified by: Frank Xu.
Graphs. Contents Terminology Graphs as ADTs Applications of Graphs.
Introduction to Graph Theory
1 Trees : Part 1 Reading: Section 4.1 Theory and Terminology Preorder, Postorder and Levelorder Traversals.
1 Graph theory Outline A graph is an abstract data type for storing adjacency relations –We start with definitions: Vertices, edges, degree and sub-graphs.
David W. Goodwin, Kent D. Wilken
White-Box Testing.
Princeton University Spring 2016
Topic 10: Dataflow Analysis
Control Flow Analysis CS 4501 Baishakhi Ray.
White-Box Testing.
Graphs Chapter 11 Objectives Upon completion you will be able to:
CS 583 Analysis of Algorithms
Chapter 11 Graphs.
Pointer analysis.
Presentation transcript:

Interprocedural Path Profiling David Melski Thomas Reps University of Wisconsin

Outline Introduction and Applications The Ball-Larus Intraprocedural Technique Overview of Interprocedural Path-profiling Conclusion

Introduction What is path profiling? –Counts the number of times particular path fragments are executed Our work: extensions of Ball-Larus –New interprocedural techniques –New intraprocedural techniques

Applications Program Optimization –Path-qualified dataflow analysis (Ammons, Larus) Software Maintenance –Path spectra (Reps et al.) –“Oddball” paths –Debugger applications

The Ball-Larus Technique “Remove” cycles from the CFG Label each vertex v with numPaths[v], the number of paths from v to Exit. Label each edge with an integer such that: –For each path p, p’s path number---the sum of the values on p’s edges---is unique value –Each path number is in [0..numpaths[Entry]-1] Add Instrumentation

Ball-Larus Tech. “Remove” cycles –Add surrogate edges –Remove backedges Left with a DAG: have a finite number of acyclic paths

Ball-Larus Tech. Label each vertex v with numPaths[v], (the number of paths from v to Exit.) Use bottom-up traversal

Ball-Larus Tech. Label edges such that: For each path p, p’s path number—the sum of p’s edges—is a unique value pathNum = 0 pathNum = 3 pathNum = 1 pathNum = 2

Ball-Larus Tech. Add Instrumentation: Var. pathNum Example: start w/ pathNum=0 pathNum+=0 (pathNum=0) Profile[pathNum] ++ pathNum=2

Edge Labels

Overview Introductory example program The program supergraph G* Modifying G* to create G*-fin Parameterized instrumentation

Introductory Example (main)

Introductory Example (pow function)

Supergraph G* Unique vertices Entry global and Exit global CFG for each procedure P –Unique Entry P and Exit P call and return-site vertices for each procedure call call-edges and return-edges connect calls to procedures

Invalid Path Example Do not want to consider invalid paths for profiling

Valid Paths Label interprocedural edges with parens Don’t accept paths with mismatched parens ( ) [ } { ] Invalid: ( { ] ) Same-Level: ( { } ) Unbalanced-Left: ( {

Interprocedural Cycles Complicates interprocedural profiling

Creating G*-fin Modify G*: –In each procedure: Add Gexit Remove Backedges –(Removes cycles in control-flow graphs) u8: Gexit pow

Creating G*-fin Modify G* (cont): –Remove recursive edges –(Removes cycles in call graph)

Observable Paths In G*-fin: –A finite number of unbalanced-left paths. –Each unbalanced-left path defines an observable path—an item that we log in a profile. –(observable paths are unbalanced-left because they may end in the middle of a procedure)

Context-Prefix and Active-Suffix Each path has –a context-prefix –an active-suffix –a counter The counter counts the executions of the active-suffix in the context of the context- prefix

Overview:  and  functions For vertex v in procedure P, assign fn  v –  v takes the number of paths from Exit P and returns the number of paths from v For edge e in procedure P, assign fn  e –  e takes the number of paths from Exit P and returns an integer value for e

Overview: Instrumentation Each procedure Q takes additional parameters: –pathNum (passed by reference) –numPathsExitQ (passed by value) On a procedure call to Q from P, calculate numPathsExitQ for current context: –numPathsExitQ =  r ( numPathsExitP )

Overview: Instrumentation numPathsExitPow =  r (numPathsExitMain) pathNumOnEntryPow = pathNum E.g., Function call:

Overview: Instrumentation pathNum +=  e (numPathsExitPow) E.g., Edge Traversal:

Overview: Instrumentation pathNum +=  e (numPathsExitPow) Profile[pathNum] ++ pathNum = pathNumOnEntryPow pathNum +=  e (numPathsExitPow) E.g., Backedge Traversal:

Assigning  functions Solve the following equations:

Assigning  call functions numPaths[ExitPow] =  rtn(numPaths[ExitMain]) numPaths[EntryPow] =  entry(  rtn(numPaths[ExitMain]) numPaths[Call] =  entry(  rtn(numPaths[ExitMain])  call =  entry   rtn

Discussion Relationship of  functions to Interprocedural DFA (e.g., Sharir and Pnueli’s  functions):

Assigning  functions Let the vertex w have successors w 1 … w k :

Conclusion Interprocedural Context Path Profiling –still some difficulties: Doubly exponential observable paths (but can “prune” paths) instrumentation is somewhat more costly (  2 ops per edge instead of 1) –Need static analysis to find  and  functions

Conclusion Developed a toolkit of path-profiling techniques: –Interprocedural vs. intraprocedural –Edge functions vs. edge values –Context vs. piecewise

Possible Approaches Remove most call-edges and return-edges Inline every non-recursive procedure Duplicate every non-recursive procedure Parameterize instrumentation in each procedure to behave differently for different contexts

Handling Recursion Assign values to each edge Entry global  Entry R i :

Handling Recursion Before a recursive call to R: –save pathNum (in pathNumBeforeCall ) –set pathNum to value on Entry global  Entry R After a recursive call –update profile with pathNum –restore pathNum to pre-call value (from pathNumBeforeCall )

Theory: Context-Free DAGs Let L be a context-free language over  Let G be a directed graph whose edges are labeled with members of  A path in G is an L-path if its word is in L (L,G) is a context-free DAG if the number of L-paths through G is finite

Interprocedural Piecewise Profiling Modification of context profiling: –For each procedure P: Add the vertex GEntry P Add the edge Entry global  GEntry P –Replace each surrogate edge Entry P  v with GEntry P  v Use Unbalanced-Right-Left paths in G*-fin (must handle unbalanced-right paths)

Other Techniques Intraprocedural context path profiling –Context indicates the path taken to a loop header Hybrid techniques –Exploit parameterization of the instrumentation

Discussion Keeping the numbering dense: –the number of paths can be exponential in the size of the graph –might require O(n) bits for pathNum –dense numbering important –piecewise or hybrid may be more practical