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

Brian Gaeke gaeke at cs.uiuc.edu
Wed May 19 15:17:02 PDT 2004


Changes in directory reopt/lib/LightWtProfiling:

TraceWriter.cpp added (r1.1)
RuntimeOptimizations.cpp updated: 1.34 -> 1.35

---
Log message:

Must resist the urge to entangle trace writer with runtime trace optimizer!


---
Diffs of the changes:  (+64 -37)

Index: reopt/lib/LightWtProfiling/TraceWriter.cpp
diff -c /dev/null reopt/lib/LightWtProfiling/TraceWriter.cpp:1.1
*** /dev/null	Wed May 19 15:16:23 2004
--- reopt/lib/LightWtProfiling/TraceWriter.cpp	Wed May 19 15:16:12 2004
***************
*** 0 ****
--- 1,63 ----
+ //===-- LightWtProfiling/TraceWriter.cpp -------------------------*- C++ -*--=//
+ // 
+ //                     The LLVM Compiler Infrastructure
+ //
+ // This file was developed by the LLVM research group and is distributed under
+ // the University of Illinois Open Source License. See LICENSE.TXT for details.
+ // 
+ //===----------------------------------------------------------------------===//
+ //
+ // This file exports a method which can be used to save a trace to
+ // disk, along with the module it refers to.
+ //
+ //===----------------------------------------------------------------------===//
+ 
+ #include "llvm/Analysis/Trace.h"
+ #include "llvm/Bytecode/Writer.h"
+ #include "llvm/Function.h"
+ #include "Support/FileUtilities.h"
+ #include "Support/StringExtras.h"
+ #include <fstream>
+ using namespace llvm;
+ 
+ namespace llvm {
+ 
+ /// getBasicBlockIndex - Returns the index of BB in its parent function.
+ ///
+ static inline int getBasicBlockIndex (BasicBlock *BB) {
+   int bbNum = 0;
+   Function *F = BB->getParent ();
+   Function::iterator block = F->begin();
+   while (&*block != BB) {
+     ++block;              
+     ++bbNum;
+   }
+   return bbNum;
+ }     
+ 
+ void WriteTraceToFile (Trace &T) {
+   // Get unique filename for trace & corresponding module.
+   std::string traceFileName, bytecodeFileName;
+   Function *F = T.getFunction ();
+   unsigned count = 0;
+   do {
+     ++count;
+     traceFileName = F->getName () + ".trace" + utostr (count) + ".txt";
+     bytecodeFileName = F->getName () + ".trace" + utostr (count) + ".bc";
+   } while (FileOpenable(traceFileName) || FileOpenable(bytecodeFileName));
+ 
+   // Write out trace.
+   std::ofstream out (traceFileName.c_str ());
+   out << F->getName () << "\n";
+   for (Trace::iterator i = T.begin (), e = T.end (); i != e; ++i)
+     out << getBasicBlockIndex (*i) << " ";
+   out << "\n";
+   out.close ();
+ 
+   // Write out bytecode.
+   std::ofstream bout (bytecodeFileName.c_str ());
+   WriteBytecodeToFile(F->getParent (), bout);
+   bout.close ();
+ }
+ 
+ } // end namespace llvm


Index: reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp
diff -u reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp:1.34 reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp:1.35
--- reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp:1.34	Wed May 19 03:48:36 2004
+++ reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp	Wed May 19 15:16:11 2004
@@ -68,43 +68,7 @@
 
 ///==----------------------------------------------------------------------==///
 
-/// getBasicBlockIndex - Returns the index of BB in its parent function.
-///
-int getBasicBlockIndex (BasicBlock *BB) {
-  int bbNum = 0;
-  Function *F = BB->getParent ();
-  Function::iterator block = F->begin();
-  while (&*block != BB) {
-    ++block;              
-    ++bbNum;
-  }
-  return bbNum;
-}     
-                
-void WriteTraceToFile (Trace &T) {
-  // Get unique filename for trace & corresponding module.
-  std::string traceFileName, bytecodeFileName;
-  Function *F = T.getFunction ();
-  unsigned count = 0;
-  do {
-    ++count;
-    traceFileName = F->getName () + ".trace" + utostr (count) + ".txt";
-    bytecodeFileName = F->getName () + ".trace" + utostr (count) + ".bc";
-  } while (FileOpenable(traceFileName) || FileOpenable(bytecodeFileName));
-
-  // Write out trace.
-  std::ofstream out (traceFileName.c_str ());
-  out << F->getName () << "\n";
-  for (Trace::iterator i = T.begin (), e = T.end (); i != e; ++i)
-    out << getBasicBlockIndex (*i) << " ";
-  out << "\n";
-  out.close ();
-
-  // Write out bytecode.
-  std::ofstream bout (bytecodeFileName.c_str ());
-  WriteBytecodeToFile(F->getParent (), bout);
-  bout.close ();
-}
+extern void WriteTraceToFile (Trace &T);
 
 /// This method is called when we have finally constructed a
 /// trace. The first parameter is the vector of basic blocks that form





More information about the llvm-commits mailing list