summaryrefslogtreecommitdiff
path: root/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp
diff options
context:
space:
mode:
authorAnand Shukla <ashukla@cs.uiuc.edu>2002-07-18 20:56:47 +0000
committerAnand Shukla <ashukla@cs.uiuc.edu>2002-07-18 20:56:47 +0000
commite617f927413b052c4912b05b2297ef348498511d (patch)
tree20d321acad9d20414c460a1862b154fd075a2ffd /lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp
parente221976b37705d2947baee553ce9947d6d9e9e3f (diff)
downloadllvm-e617f927413b052c4912b05b2297ef348498511d.tar.gz
llvm-e617f927413b052c4912b05b2297ef348498511d.tar.bz2
llvm-e617f927413b052c4912b05b2297ef348498511d.tar.xz
minor corrections
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2971 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp')
-rw-r--r--lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp56
1 files changed, 20 insertions, 36 deletions
diff --git a/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp b/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp
index a3ddab2d64..391bc5bb89 100644
--- a/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp
+++ b/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp
@@ -70,10 +70,12 @@ bool ProfilePaths::runOnFunction(Function &F){
static int mn = -1;
- if(F.size() <=1) {
+ if(F.isExternal()) {
return false;
}
+ //std::cerr<<"Instrumenting\n-----------------\n";
+ //std::cerr<<F;
//increment counter for instrumented functions. mn is now function#
mn++;
@@ -118,18 +120,25 @@ bool ProfilePaths::runOnFunction(Function &F){
Graph g(nodes,edges, startNode, exitNode);
-#ifdef DEBUG_PATH_PROFILES
- std::cerr<<"Original graph\n";
- printGraph(g);
-#endif
+ //#ifdef DEBUG_PATH_PROFILES
+ //std::cerr<<"Original graph\n";
+ //printGraph(g);
+ //#endif
BasicBlock *fr = &F.front();
// The graph is made acyclic: this is done
// by removing back edges for now, and adding them later on
vector<Edge> be;
- g.getBackEdges(be);
-
+ std::map<Node *, int> nodePriority; //it ranks nodes in depth first order traversal
+ g.getBackEdges(be, nodePriority);
+ /*
+ std::cerr<<"Node priority--------------\n";
+ for(std::map<Node *, int>::iterator MI = nodePriority.begin(),
+ ME = nodePriority.end(); MI!=ME; ++MI)
+ std::cerr<<MI->first->getElement()->getName()<<"->"<<MI->second<<"\n";
+ std::cerr<<"End Node priority--------------\n";
+ */
//std::cerr<<"BackEdges-------------\n";
// for(vector<Edge>::iterator VI=be.begin(); VI!=be.end(); ++VI){
//printEdge(*VI);
@@ -159,8 +168,9 @@ bool ProfilePaths::runOnFunction(Function &F){
// All paths for now are acyclic,
// since no back edges in the graph now
// numPaths is the number of acyclic paths in the graph
- int numPaths=valueAssignmentToEdges(g);
+ int numPaths=valueAssignmentToEdges(g, nodePriority);
+ if(numPaths<=1 || numPaths >5000) return false;
//std::cerr<<"Numpaths="<<numPaths<<std::endl;
//printGraph(g);
//create instruction allocation r and count
@@ -186,33 +196,7 @@ bool ProfilePaths::runOnFunction(Function &F){
//get increments along different paths,
//and assign "increments" and "updates" (to r and count)
//"optimally". Finally, insert llvm code along various edges
- processGraph(g, rVar, countVar, be, stDummy, exDummy, numPaths);
- /*
- //get the paths
- static std::ofstream to("paths.sizes");
- static std::ofstream bbs("paths.look");
- assert(to && "Cannot open file\n");
- assert(bbs && "Cannot open file\n");
- for(int i=0;i<numPaths; ++i){
- std::vector<BasicBlock *> vBB;
-
- getBBtrace(vBB, i, M);
- //get total size of vector
- int size=0;
- bbs<<"Meth:"<<mn<<" Path:"<<i<<"\n-------------\n";
- for(vector<BasicBlock *>::iterator VBI=vBB.begin(); VBI!=vBB.end();
- ++VBI){
- BasicBlock *BB=*VBI;
- size+=BB->size();
- if(BB==M->front())
- size-=numPaths;
- bbs<<BB->getName()<<"->";
- }
- bbs<<"\n--------------\n";
- to<<"::::: "<<mn<<" "<<i<<" "<<size<<"\n";
- }
- */
- //}
-
+ processGraph(g, rVar, countVar, be, stDummy, exDummy, numPaths, mn);
+
return true; // Always modifies function
}