Approaches to Control Flow Analysis: Algorithm and Interval, Slides of Computer Science

An in-depth exploration of control flow analysis, specifically focusing on algorithms and interval analysis. Topics covered include finding dominators, loop detection, extended basic blocks, pre-headers, reducible flow graphs, and node splitting. The document also discusses the advantages and disadvantages of different approaches to control flow analysis.

Typology: Slides

2012/2013

Uploaded on 03/28/2013

ekanath
ekanath 🇮🇳

3.8

(4)

76 documents

1 / 10

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Objectives_template
file:///D|/...ary,%20Dr.%20Sanjeev%20K%20Aggrwal%20&%20Dr.%20Rajat%20Moona/Multi-core_Architecture/lecture%2027/27_1.htm[6/14/2012 12:08:58 PM]
Module 14: Approaches to Control Flow Analysis
Lecture 27: Algorithm and Interval
The Lecture Contains:
Algorithm to Find Dominators
Loop Detection
Algorithm to Detect Loops
Extended Basic Block
Pre-Header
Loops With Common eaders
Reducible Flow Graphs
Node Splitting
Interval Analysis
Intervals
Interval Partition
Interval Graphs
Control Tree
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Approaches to Control Flow Analysis: Algorithm and Interval and more Slides Computer Science in PDF only on Docsity!

Module 14: Approaches to Control Flow Analysis

Lecture 27: Algorithm and Interval

The Lecture Contains:

Algorithm to Find Dominators

Loop Detection

Algorithm to Detect Loops

Extended Basic Block

Pre-Header

Loops With Common eaders

Reducible Flow Graphs

Node Splitting

Interval Analysis

Intervals

Interval Partition

Interval Graphs

Control Tree

Module 14: Approaches to Control Flow Analysis

Lecture 27: Algorithm and Interval

Algorithm to Find Dominators

D(n0) := {n0}; for n in N-{n0} do D(n) := N; while changes to any D(n) occur do for n in N-{n0} do D(n) := {n} n D(p);

Loop Detection

Search for a back-edge such that a → b is an edge and b dom a. Given a back edge a → b Find set of nodes that can reach node a without going through node b And node b These nodes form a natural loop with b as header. Given back edge a → b natural loop is a sub graph which contains a, b and all the nodes which can reach a without passing through b

Module 14: Approaches to Control Flow Analysis

Lecture 27: Algorithm and Interval

Extended Basic Block

Maximal sequence of instructions begining with a header and no other join nodes Single entry multiple exits block

Depth first traversal contains (i) all the nodes and (ii) edges which make depth first order. This is called depth first spanning tree. Forward edges: from a node to descendent Back edges: go from node to ancestor Cross edges: connects nodes such that neither is an ancestor in dfs

Module 14: Approaches to Control Flow Analysis

Lecture 27: Algorithm and Interval

Pre-Header

Many optimizations require code movement from inside a loop to just before it. Pre-header is a new empty block just before header. All edges from outside to header go to pre-header A new edge goes from pre-header to header

Loops With Common Headers

Two loops with different headers are either disjoint or nested Two loops with the same header Not clear if they are nested Or are one loop Can not be decided without looking at the source code

Module 14: Approaches to Control Flow Analysis

Lecture 27: Algorithm and Interval

In a reducible graph All the loops are natural loops There are no jumps in the middle of a loop Improper regions are multiple entry strongly connected regions

Programming languages do not allow irreducible flow graphs Fortran with loops of if and gotos construct irreducible flow graphs Most of the optimizations do not work for irreducible flow graphs Node splitting is a possible solution

Module 14: Approaches to Control Flow Analysis

Lecture 27: Algorithm and Interval

Node Splitting

Transformation used for converting non-reducible flow graphs to reducible flow graphs. If there is a node n with k predecessors:

Split n into k nodes generating nodes n1, n2, ..., nk The ith predecessor of n becomes the predecessors of ni All the successors of n become successors of all of the ni’ s

Interval Analysis

Divides flow graph into various regions Consolidate each region into a (abstract) node Resulting flow graph is an abstract flow graph Result of transformations produce control tree Root represents the original graph Leaf of control tree are basic blocks Internal nodes are abstract nodes Edges represent relationship between abstract nodes

Intervals

Each interval has a header node that dominates all the nodes in the interval. Given a flow graph with initial node n0, the interval with header n is denoted by I(n) and is defined as: N is in I(n) If all the predecessors of a node m are in I(n) then m is in I(n) No other node is in I(n)

file:///D|/...ry,%20Dr.%20Sanjeev%20K%20Aggrwal%20&%20Dr.%20Rajat%20Moona/Multi-core_Architecture/lecture%2027/27_10.htm[6/14/2012 12:08:59 PM]

Module 14: Approaches to Control Flow Analysis

Lecture 27: Algorithm and Interval

If the limit flow graph is a single node then the graph is reducible.

Control Tree

The result of applying a sequence of such transformations produces a control tree. It is defined as follows:

The root is sn abstract graph representing the original flowgraph The leaves are individual basic blocks The internal nodes are abstract nodes representing regions of the flowgraph The edges of the tree represent the relationship between each abstract node and the regions that are its descendants