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

Brian Gaeke gaeke at cs.uiuc.edu
Fri Jan 16 13:17:02 PST 2004


Changes in directory reopt/lib/LightWtProfiling:

RuntimeOptimizations.cpp updated: 1.18 -> 1.19

---
Log message:

Get rid of some ancient debug stuff here and trim #includes; other cleanups.
Use the shiny FunctionPassManager for everything.


---
Diffs of the changes:  (+23 -43)

Index: reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp
diff -u reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp:1.18 reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp:1.19
--- reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp:1.18	Thu Jan 15 13:40:23 2004
+++ reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp	Fri Jan 16 13:16:04 2004
@@ -19,15 +19,15 @@
 #include "Support/Debug.h"
 #include "Support/StringExtras.h"
 #include "llvm/Analysis/Verifier.h"
-#include "llvm/Assembly/CachedWriter.h"
+#include "llvm/Assembly/PrintModulePass.h"
 #include "llvm/CodeGen/MachineFunction.h"
+#include "llvm/CodeGen/Passes.h"
 #include "llvm/IntrinsicLowering.h"
 #include "llvm/ModuleProvider.h"
 #include "llvm/PassManager.h"
 #include "llvm/Target/TargetJITInfo.h"
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/TargetMachineImpls.h"
-#include <fstream>
 
 namespace llvm {
 
@@ -41,57 +41,37 @@
 ///
 void optimizeTrace (std::vector<BasicBlock *> &vBB, uint64_t a) {
   static std::set<uint64_t> alreadyDone;
-  if (alreadyDone.find (a) != alreadyDone.end ()) {
+  if (alreadyDone.find (a) != alreadyDone.end ())
     // Used to have debug msg here, but it generated megabytes of spam.
     return;
-  } else {
-    alreadyDone.insert(a);
-  }
-
-  // Ensure module has been read in (very likely, but you never know...)
-  if (!MP)
-    initModules ();
-
-  // Dump the basic blocks to the standard error stream if we are in debug mode.
-  DEBUG(std::cerr << "In optimizeTrace; a = " << a << "\n"
-	<< "Trace for function " << vBB[0]->getParent ()->getName ()
-	<< ", blocks:\n");
-#ifndef NDEBUG
-  {
-    CachedWriter CW (M, std::cerr);
-    for (unsigned i = 0; i < vBB.size (); ++i)
-      DEBUG(CW << *vBB[i]);
-  }
-#endif // NDEBUG
+  else
+    alreadyDone.insert (a);
 
-  // Turn vector of basic blocks into a Trace object.
-  Trace T (vBB);
+  // Initialization stuff: ensure module has been read in, and allocate a
+  // target machine, if there isn't one already.
+  if (!MP) initModules ();
+  if (!IL) IL = new DefaultIntrinsicLowering ();
+  if (!Target) Target = allocateSparcTargetMachine (*MP->getModule (), IL);
 
-  // Turn the Trace object into a function.
+  // Turn the vector of basic blocks into a Trace, and then turn the Trace into
+  // a TraceFunction.
+  Trace T (vBB);
   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, 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,
+  // Verify that the generated function's bytecode is good, then compile it
+  // down to machine code. Then, "unpack" it back into its matrix function.
+  // FIXME: Register allocation hints also need to be added to the PassManager,
   // so that we do not get clobbered by the overhead of adding copies in
   // UnpackTraceFunction.
-
-  // Compile LLVM Code down to machine code in the intermediate representation
+  FunctionPassManager PM (MP);
+  PM.add (new PrintFunctionPass ("Function created from trace for "
+                                 + T.getFunction ()->getName ()));
+  PM.add (createVerifierPass ());
   Target->getJITInfo ()->addPassesToJITCompile (PM);
+  PM.add (createMachineFunctionPrinterPass ());
+  PM.add (createUnpackTraceFunctionPass (Target, TF));
+  PM.add (createMachineFunctionPrinterPass ());
   PM.run (*TF->TraceFn);
-  
-  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