[llvm-commits] CVS: llvm/lib/Reoptimizer/LightWtProfiling/Trigger/Initialization.cpp
Brian Gaeke
gaeke at niobe.cs.uiuc.edu
Tue Aug 12 22:08:13 PDT 2003
Changes in directory llvm/lib/Reoptimizer/LightWtProfiling/Trigger:
Initialization.cpp added (r1.1)
---
Log message:
New file intended to contain all the Reoptimizer's initialization code.
---
Diffs of the changes:
Index: llvm/lib/Reoptimizer/LightWtProfiling/Trigger/Initialization.cpp
diff -c /dev/null llvm/lib/Reoptimizer/LightWtProfiling/Trigger/Initialization.cpp:1.1
*** /dev/null Tue Aug 12 22:07:55 2003
--- llvm/lib/Reoptimizer/LightWtProfiling/Trigger/Initialization.cpp Tue Aug 12 22:06:45 2003
***************
*** 0 ****
--- 1,59 ----
+ //===-- LightWtProfiling/Trigger/Initialization.cpp --------------*- C++ -*--=//
+ //
+ // Initialization functions called either from the main() of an
+ // instrumented program, or later when we determine that further
+ // instrumentation will be necessary.
+ //
+ //===----------------------------------------------------------------------===//
+
+ #include "GetTimer.h"
+ #include "Globals.h"
+ #include "llvm/Bytecode/Reader.h"
+
+ // Function used as space for the second-level instrumentation trace cache.
+ extern "C" void dummyFunction2 ();
+
+ // Definitions of globals declared extern in Globals.h
+ int reopt_threshold;
+ long THRESHOLD_LEVEL_2;
+ long LEVEL_TWO_EXITS;
+ TraceCache *tr;
+ TraceCache *tr2;
+ VirtualMem *vm;
+ Module *M;
+
+ /// Initialization method for the reoptimizer. A call to this function
+ /// from main() is inserted by the opt -instloops pass
+ /// (Transforms/Instrumentation/ProfilePaths/InstLoops.cpp).
+ ///
+ extern "C" void reoptimizerInitialize(){
+ vm = new VirtualMem();
+ tr = new TraceCache(30000, vm);
+ tr2 = new TraceCache(dummyFunction2, 30000, vm);
+
+ if(getenv("THRESHOLD_LEVEL_2")!=NULL)
+ THRESHOLD_LEVEL_2 = atoi(getenv("THRESHOLD_LEVEL_2"));
+ else
+ THRESHOLD_LEVEL_2= DEFAULT_THRESHOLD_LEVEL_2;
+
+ LEVEL_TWO_EXITS = THRESHOLD_LEVEL_2/3;
+
+ if(getenv("THRESHOLD_LEVEL_1")!=NULL)
+ reopt_threshold = atoi(getenv("THRESHOLD_LEVEL_1"));
+ else
+ reopt_threshold = DEFAULT_THRESHOLD_LEVEL_1;
+
+ // FIXME: When do we need to call this?
+ //initialize_timer();
+ }
+
+ /// Initialization method for the reoptimizer that parses the bytecode
+ /// which was stored in the executable image. This is not supposed to
+ /// be called until 2nd-level instrumentation, probably because parsing
+ /// bytecode incurs some overhead.
+ ///
+ void initModules () {
+ std::string err;
+ M = ParseBytecodeBuffer(LLVMBytecode, llvm_length, "NOFILENAME", &err);
+ assert(M && "Module parsing failed!");
+ }
More information about the llvm-commits
mailing list