diff options
author | Anand Shukla <ashukla@cs.uiuc.edu> | 2002-09-20 16:44:35 +0000 |
---|---|---|
committer | Anand Shukla <ashukla@cs.uiuc.edu> | 2002-09-20 16:44:35 +0000 |
commit | 590df88d824f9616990d1a6793b5b3e1d135e70a (patch) | |
tree | 8c4cc3abf1e3e53659f671c9936002ab77b99d8c /lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp | |
parent | 65ce103d8dd619f16d910937884f31c2eaaec5cf (diff) |
Added checking threshold
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3864 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp')
-rw-r--r-- | lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp b/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp index cd341920a5..48d5e85e64 100644 --- a/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp +++ b/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp @@ -26,11 +26,13 @@ #include "llvm/Transforms/Instrumentation/ProfilePaths.h" #include "llvm/Transforms/Utils/UnifyFunctionExitNodes.h" +#include "llvm/Transforms/Instrumentation/Graph.h" #include "llvm/Support/CFG.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/iMemory.h" -#include "llvm/Transforms/Instrumentation/Graph.h" +#include "llvm/GlobalVariable.h" +#include "llvm/Module.h" #include <iostream> #include <fstream> @@ -184,15 +186,29 @@ bool ProfilePaths::runOnFunction(Function &F){ AllocaInst(Type::IntTy, ConstantUInt::get(Type::UIntTy, numPaths), "Count"); + static GlobalVariable *threshold = NULL; + static bool insertedThreshold = false; + + if(!insertedThreshold){ + threshold = new GlobalVariable(Type::IntTy, false, true, 0, + "reopt_threshold"); + + F.getParent()->getGlobalList().push_back(threshold); + insertedThreshold = true; + } + + assert(threshold && "GlobalVariable threshold not defined!"); + // insert initialization code in first (entry) BB // this includes initializing r and count - insertInTopBB(&F.getEntryNode(),numPaths, rVar, countVar); + insertInTopBB(&F.getEntryNode(),numPaths, rVar, countVar, threshold); //now process the graph: get path numbers, //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, mn); + processGraph(g, rVar, countVar, be, stDummy, exDummy, numPaths, mn, + threshold); return true; // Always modifies function } |