[llvm-commits] CVS: llvm/lib/Reoptimizer/LightWtProfiling/Trigger/FirstTrigger.cpp

Brian Gaeke gaeke at niobe.cs.uiuc.edu
Tue Aug 12 22:08:17 PDT 2003


Changes in directory llvm/lib/Reoptimizer/LightWtProfiling/Trigger:

FirstTrigger.cpp updated: 1.10 -> 1.11

---
Log message:

Include Globals.h and SecondTrigger.h to pull in extern decls instead
 of declaring them here.
Don't need to use namespace std.
Move initialization code for reoptimizer to Initialization.cpp.
Give llvm_first_trigger a comment.


---
Diffs of the changes:

Index: llvm/lib/Reoptimizer/LightWtProfiling/Trigger/FirstTrigger.cpp
diff -u llvm/lib/Reoptimizer/LightWtProfiling/Trigger/FirstTrigger.cpp:1.10 llvm/lib/Reoptimizer/LightWtProfiling/Trigger/FirstTrigger.cpp:1.11
--- llvm/lib/Reoptimizer/LightWtProfiling/Trigger/FirstTrigger.cpp:1.10	Thu Aug  7 22:56:07 2003
+++ llvm/lib/Reoptimizer/LightWtProfiling/Trigger/FirstTrigger.cpp	Tue Aug 12 22:05:45 2003
@@ -9,6 +9,8 @@
 //===----------------------------------------------------------------------===//
 
 #include "GetTimer.h"
+#include "Globals.h"
+#include "SecondTrigger.h"
 #include "RegSaveRestore.h"
 #include "scheduler.h"
 #include "SLI.h"
@@ -25,60 +27,10 @@
 #include <libcpc.h>
 #endif
 
-using namespace std;
-
-extern long THRESHOLD_LEVEL_2;
-extern long LEVEL_TWO_EXITS; 
-
-// Function used as space for the second-level instrumentation trace cache.
-extern "C" void dummyFunction2 ();
-
-// From SecondTrigger.cpp:
-extern uint32_t scanForBranch (const uint64_t startAddr, uint64_t &foundAddr);
-
-// Global counters for diagnostics:
-extern std::map<uint64_t, int> exitCounter;
-extern std::map<uint64_t, uint64_t> firstTriggerAddr; //tracestart addr
-extern std::map<uint64_t, std::pair<long, long> > backOffCounters; 
-
-int reopt_threshold = DEFAULT_THRESHOLD_LEVEL_1;
-int exit_count=0;
-
-TraceCache *tr;
-TraceCache *tr2;
-VirtualMem *vm;
-
-// Initialization method for the reoptimizer. A call to this function
-// from main() is inserted by the opt -instloops pass
-// (Transforms/Instrumentation/ProfilePaths/InstLoops.cpp).
-// reoptimizerInitialize is passed a pointer to reopt_threshold in t
-// (why?)
-extern "C" void reoptimizerInitialize(int *t){
-  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: This should not be necessary if we are already setting
-  // reopt_threshold above. Remove the junk from InstLoops.cpp that
-  // makes reopt_threshold visible to the called program, and remove
-  // this, later.
-  *t=30;
-
-  //initialize_timer();
-}
-
+/// This is the function that performs first-level profiling. A call
+/// to this function from most back-edges is inserted by the InstLoops
+/// pass. It must be careful to save all the registers it may use.
+///
 extern "C" void llvm_first_trigger(){
   uint64_t i_reg_save[6];
   uint32_t f_reg_save[32];
@@ -103,7 +55,7 @@
 
   // This is where we keep the counter for each first-level
   // instrumented branch.
-  static map<uint64_t, int> counterMap;
+  static std::map<uint64_t, int> counterMap;
 
   // Get return address of this invocation (on SPARC, this is in %i7).
   uint64_t pcAddr = (uint64_t) __builtin_return_address(0);





More information about the llvm-commits mailing list