next up previous
Next: Call Graph Transformation into Up: Control-Flow and Call-Graph Analysis Previous: Control-Flow and Call-Graph Analysis

Partitioning the Control-Flow Graph into Unique Paths

The control flow of each function is partitioned into unique paths (UPs) to provide a small set of measurement points. The motivation for restructuring the control flow into UPs is twofold.

  1. Each UP has a unique vertex or edge that provides the insertion point for instrumentation code at a later stage. This code may perform arbitrary on-the-fly analysis, e.g. simple profiling or more complex cache performance analysis.
  2. Each UP is comprised of a range of instructions that are executed in sequence if and only if the unique vertex or edge is executed. This range of instructions does not have to be contiguous in the address space. The range of instructions provides a scope for static analysis to determine the instrumentation code for dynamic on-the-fly analysis, which preserves the order of events.

The first aspect, the strategy of instrumenting edges (or vertices where possible), is also fundamental to the aforementioned work on optimal profiling and tracing by Ball and Larus []. It is the second aspect that distinguishes this new approach from their work. The option of performing static analysis on the control flow to determine and optimize the instrumentation code for order-dependent on-the-fly analysis requires the definition of ranges for the analysis. Naively, one could choose basic blocks to comprise these ranges. But it has been demonstrated for profiling and tracing that fewer instrumentation points can be obtained by a more selective instrumentation technique. UPs provide such a framework supporting efficient instrumentation for on-the-fly analysis.

The set of UPs is called a unique path partitioning (UPPA) and is defined as follows: Let G(V,E) be the control-flow graph (directed graph) of a function with a set of edges (transitions) E and a set of vertices (basic blocks) V.

Let p be a path tex2html_wrap_inline773 with the ordered set of edges tex2html_wrap_inline775 and the ordered set of vertices tex2html_wrap_inline777, i.e., a sequence of distinct vertices connected by edges []. The edge tex2html_wrap_inline779 may also be denoted as tex2html_wrap_inline781. Vertex tex2html_wrap_inline783 is called an head vertex and vertex tex2html_wrap_inline785 a tail vertex, while all other tex2html_wrap_inline787 are internal vertices. Let H be the set of all head vertices and T be the set of all tail vertices.


        definition58

The properties 6 and 7 are operational restrictions motivated by the application of the partitioning for on-the-fly analysis of program behavior. The break at calls allows the insertion of instrumentation code for separate compilation. Thus, the compiler is not required to perform interprocedural analysis. The break at loop boundaries ensures that the frequency of events can be identified. The frequency of events outside a loop differs from the frequency inside loops (unless the loop was iterated only once). Thus, a UP associated with an event should not cross loop boundaries.


 example97


 theorem118


proof121


definition133

The significance of the ordering is related to the number of measurement points for on-the-fly analysis. A smaller partitioning yields fewer measurement points, which improves the performance of on-the-fly analysis. The following algorithm provides a method to find a small partitioning. The algorithm uses the terminology of a loop header for a vertex with an incoming edges from outside the loop. A loop exit is a vertex with an outgoing edge leaving the loop. This is illustrated in Figure 2a.

  figure136
Figure: Sample Graphs


 algorithm142


example156


theorem167


proof173

In terms of the ordering of UPPAs, the basic block partitioning tex2html_wrap_inline1109 is the partitioning with the largest number of measurement points. Algorithm 1 constructs a partitioning that has an equal or smaller number of measurement points. We found that the algorithm produces a much smaller UPPA if possible. The algorithm may in fact produce a minimal UPPA (with the smallest possible number of measurement points). We have not yet succeeded in proving the minimality due to the fact that a given graph may have more than one minimal UPPA.

In summary, the control-flow graph can be transformed into a small UPPA by Algorithm 1. The small set of measurement points is given by a unique vertex or unique edge of each UP. This provides the framework for efficient on-the-fly analysis with regard to the definition of UPPAs.

Another short example for a small UPPA construction shall be given, which is used to discuss the possibility of letting paths begin and end in edges as well as vertices.


example201

In general, the method may still be further tuned with regard to the dynamic behavior. Currently, a path has to begin and end in a vertex. Consider the notion of open paths that can start and end in a vertex or an edge. Then, another small UPPA of the loop in Figure 2a would be:


Consider the number of measurement points executed during each loop iteration. For tex2html_wrap_inline1117, there are two measurement points for an iteration reaching b1, one each in paths 2 and 3. For tex2html_wrap_inline1121, there is only one measurement point on b1 in path 3'. The definition of UPPAs does not take dynamic properties into account.


next up previous
Next: Call Graph Transformation into Up: Control-Flow and Call-Graph Analysis Previous: Control-Flow and Call-Graph Analysis

Robert Palmer
Mon May 19 10:38:07 EDT 1997