Download Basic Control Flow Analysis in Trimaran Installation - Assignment | CS 6241 and more Assignments Computer Science in PDF only on Docsity!
CS 6241 – Class 2Trimaran Installation OverviewBasic Control Flow Analysis
Georgia Tech.January 10, 2008
Updates^ ^ http://www.cc.gatech.edu/~ntclark/6241^ ^ Newsgroup?^ ^ HW1^ ^ Pictures
Needed Software (older versions likely towork but I’m not certain)^ ^ perl, gzip, gunzip^ ^ gnu make >=3.80^ ^ autoconf 2.54, automake 1.7 (need these versions!)^ ^ gcc – we use 4.1.1, 3.4.4, 3.2 also should work^ ^ Gnu ranlib, ar (binutils 2.9 – 2.16)^ ^ gdb – 6.x^ ^ tcsh – Use this or you will have to translate some stuff^ ^ emacs, vi, nano or whatever text editor you prefer^ ^ Graph visualizing tools
»^ dot –
http://www.research.att.com/sw/tools/graphviz
Installation – Step 1^ ^ Source on the course webpage, cs6241.tbz2^ ^ In your home directory,^ ^ tar jxvf cs6241.tbz »^ Will create 5 subdirectories, documentation »^ openimpact, elcor, simu, scripts, benchmarks Enviroment variables/path – this is critical! »^ scripts/envrc – should have everything you need^ ^
Or, scripts/envrc.bash for you bash users
»^ Modify first line if you don’t put trimaran in$HOME/trimaran »^ Add to your .cshrc: “source scripts/envrc”^ ^
So you don’t forget
Trimaran Overview
C source Impact^ Elcor^ Simu C emulation code
Lcode – HPL_PD specific Lcode, aka bridge codeRebel
Frontend – parsing, profilingfunction inlining, memory depanalysis. Also, does some backendstuff – region formation, optimizationBackend – analysis, optimization, schedulingregister allocation, code generationEmulator – emulate VLIW semantics usingC code – “compiled simulation”
Running Trimaran^ ^ Install trimaran, verify your code works on strcpy and wc^ ^ tcc – gcc equivalent, sorta
»^ Command line way to invoke entire system »^ “tcc –help” to get options »^ “tcc –bench strcpy” to run strcpy with basic blocks »^ Save output to examine trimaran/benchmarks »^ source, compile flags, link flags »^ input for profiling the code, output to check if ran properly »^ To add a new benchmark, follow the organization that is there
Control Flow^ ^ Control transfer = branch (taken or fall-through)^ ^ Control flow
»^ Branching behavior of an application »^ What sequences of instructions can be executed Execution
^ Dynamic control flow
»^ Direction of a particular instance of a branch »^ Predict, speculate, squash, etc. Compiler
^ Static control flow
»^ Not executing the program »^ Input not known, so what could happen Control flow analysis »^ Determining properties of the program branch structure »^ Determining instruction execution properties
Basic Block (BB)^ ^ Group operations into units with equivalent executionconditions^ ^ Defn: Basic block
- a sequence of consecutive operations
in which flow of control enters at the beginning andleaves at the end without halt or possibility of branchingexcept at the end^ »^ Straight-line sequence of instructions^ »^ If one operation is executed in a BB, they all are Finding BB’s^ »^ The first operation starts a BB^ »^ Any operation that is the target of a branch starts a BB^ »^ Any operation that immediately follows a branch starts a BB
Control Flow Graph (CFG)^ ^ Defn Control Flow Graph
Directed graph, G = (V,E) whereeach vertex V is a basic blockand there is an edge E, v1 (BB1) ^ v2 (BB2) if BB2 canimmediately follow BB1 in someexecution sequence^ »^ A BB has an edge to all blocks itcan branch to^ »^ Standard representation used bymany compilers^ »^ Often have 2 pseudo vertices^ ^
entry node exit node
Entry^ BB1 BB2^ BB3^ BB4 BB5 BB6^ BB7^ Exit
CFG Example x = z – 2;y = 2 * z;if (c) {x = x + 1;y = y + 1;} else {x = x – 1;y = y – 1;} z = x + y
x = z – 2;y = 2 * z;if (c) B2 else B
x = x + 1;y = y + 1;goto B
z = x + y
x = x – 1;y = y – 1;
then(taken)
else(fallthrough)
B
B^
B
B
Dominator (DOM)^ ^ Defn: Dominator
- Given a CFG(V, E, Entry, Exit), a
node x dominates a node y, if every path from the Entryblock to y contains x 3 properties of dominators^ »^ Each BB dominates itself^ »^ If x dominates y, and y dominates z, then x dominates z^ »^ If x dominates z and y dominates z, then either x dominates y ory dominates x Intuition^ »^ Given some BB, which blocks are guaranteed to have executedprior to executing the BB
Dominator Examples
Entry^ BB1 BB2^ BB3^ BB4 BB5 BB6^ BB7^ Exit
BB
BB
BB
Entry BB
BB1 BB6 BB7^ Exit
Dominator Analysis^ ^ Compute dom(BBi) = set ofBBs that dominate BBi^ ^ Initialization
»^ Dom(entry) = entry »^ Dom(everything else) = allnodes Iterative computation »^ while change, do^ ^
change = false for each BB (except the entryBB)^ ^ tmp(BB) = BB + {intersect ofDom of all predecessor BB’s}^ ^ if (tmp(BB) != dom(BB))^
dom(BB) = tmp(BB) change = true
Entry^ BB1 BB2^ BB3^ BB4 BB5 BB6^ BB7^ Exit
Immediate Dominator^ ^ Defn: Immediate^ dominator
(idom)– Each
node n has a uniqueimmediate dominator mthat is the last dominatorof n on any path from theinitial node to n^ »^ Closest node thatdominates
Entry^ BB1 BB2^ BB3^ BB4 BB5 BB6^ BB7^ Exit