[llvm-commits] CVS: reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp

Brian Gaeke gaeke at cs.uiuc.edu
Thu Jan 15 13:41:02 PST 2004


Changes in directory reopt/lib/LightWtProfiling:

RuntimeOptimizations.cpp updated: 1.17 -> 1.18

---
Log message:

Make TargetMachine and IntrinsicLowering instances static, so that we
don't make new ones for each trace (which doesn't work anyway).

Create and start using a new class called TraceFunction, so that we can
pass around all the analysis results we compute in TraceToFunction.


---
Diffs of the changes:  (+13 -8)

Index: reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp
diff -u reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp:1.17 reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp:1.18
--- reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp:1.17	Wed Jan 14 17:02:22 2004
+++ reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp	Thu Jan 15 13:40:23 2004
@@ -31,6 +31,9 @@
 
 namespace llvm {
 
+static TargetMachine *Target = 0;
+static IntrinsicLowering *IL = 0;
+
 /// This method is called when we have finally constructed a
 /// trace. The first parameter is the vector of basic blocks that form
 /// the trace; the second parameter is presumably one of the starting
@@ -65,16 +68,18 @@
   Trace T (vBB);
 
   // Turn the Trace object into a function.
-  Function *TF = runTraceToFunction (T);
-  DEBUG(std::cerr << "Function created from trace: \n" << *TF);
+  TraceFunction *TF = TraceFunction::get (T);
+  DEBUG(std::cerr << "Function created from trace: \n" << *TF->TraceFn);
 
   // Verify that the generated function's bytecode is good.
   FunctionPassManager PM (MP);
   PM.add (createVerifierPass ());
 
-  // Allocate a target machine.
-  IntrinsicLowering *IL = new DefaultIntrinsicLowering ();
-  TargetMachine *Target = allocateSparcTargetMachine (*MP->getModule (), IL);
+  // Allocate a target machine, if there isn't one already.
+  if (!IL)
+    IL = new DefaultIntrinsicLowering ();
+  if (!Target)
+    Target = allocateSparcTargetMachine (*MP->getModule (), IL);
   assert (Target && "Could not allocate target machine!");
 
   // FIXME: Register allocation hints need to be added to the PassManager,
@@ -83,10 +88,10 @@
 
   // Compile LLVM Code down to machine code in the intermediate representation
   Target->getJITInfo ()->addPassesToJITCompile (PM);
-  PM.run (*TF);
+  PM.run (*TF->TraceFn);
   
-  MachineFunction &MF = MachineFunction::get (TF);
-  DEBUG(std::cerr << "Generated machine code: ";  MF.print (std::cerr));
+  MachineFunction &MF = MachineFunction::get (TF->TraceFn);
+  DEBUG(std::cerr << "Generated machine code: "; MF.print (std::cerr));
 }
 
 } // end namespace llvm





More information about the llvm-commits mailing list