16.07.2014 Views

PROGRAM STRUCTURE TREES - Software Systems Lab

PROGRAM STRUCTURE TREES - Software Systems Lab

PROGRAM STRUCTURE TREES - Software Systems Lab

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

3.1 Regions in structured programs<br />

Obtaining an region tree of a structured annotated program is trivial.<br />

Every loop and every condition is a region. The nesting of the region<br />

tree is equivalent to the nesting of the loops and conditions in the<br />

original program.<br />

Therefore this approach is taken in several algorithms, without explicitally<br />

specifying it as an region detection algorithm.<br />

However as soon as more complicated constructs like loops with<br />

multiple exits (breaks), exceptions or even gotos appear this approach<br />

does not work any more. Unfortunately many programming languages<br />

allow at least some of these constructs so a more general approach is<br />

necessary.<br />

3.2 The Program Structure Tree<br />

The in [4] published algorithm nowadays can be seen as the classical<br />

approach to calculated region trees, or as they are called in this paper,<br />

program structure trees (PST) for a general, possibly irreducible, CFG.<br />

One reason for this is the fast and streigtforward algorithm.<br />

Based on a simple data structure, called bracket list, the CFG is<br />

analysed without any previous information required. The runtime is in<br />

O(V + E).<br />

The algorithm can detect simple regions, however no refined regions.<br />

To detect refined regions, a possible approach is to insert merge<br />

basic blocks beforehand. However is has two drawbacks. First of<br />

all, deciding where to insert merge blocks is not trivial, but probably<br />

requires some analysis. Furthermore modifiying the program often<br />

invalidates existing analysis like dominance information, and is nothing<br />

that someone wants in a production compiler.<br />

3.3 The Refined Program Structure Tree<br />

In [5] the PST approach was extended and a such called Refined Program<br />

Structure Tree (RPST) was introduced. This RPST was used<br />

to model workflows in buisness processes, however it could also be<br />

applied to control flow graphs.<br />

One of the main advantages of the RPST is the refined definition of<br />

a region, that allows not only to present simple regions with just one<br />

entry and exit edge, but also regions that still have several entry and<br />

exit edges, which could be joined to a single entry or exit edge. This<br />

refinement permits the detection of regions, that cannot be handled in<br />

a plain PST.<br />

To calculate the RPST a preliminary analysis is required to build<br />

the triconnected components of the CFG as described in [3] and corrected/improved<br />

in [2]. If this analysis is not yet available the afford<br />

required to implement the RPST construction algorithm seemd to be<br />

high, especially as the triconnected components algorithm is not trivial.<br />

Another drawback of this algorithm and the refined region definition<br />

is, that a region cannot be described in constant memory, but has to be<br />

defined by all incoming and outgoing edges. To know if a basic block<br />

is part of a region a auxilary data structure has to store a mapping in<br />

between basic blocks and regions, otherwise a graph walk is required.<br />

6

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!