[llvm-commits] CVS: reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp
Brian Gaeke
gaeke at cs.uiuc.edu
Wed May 19 03:49:00 PDT 2004
Changes in directory reopt/lib/LightWtProfiling:
RuntimeOptimizations.cpp updated: 1.33 -> 1.34
---
Log message:
When writing out a trace, also write out the module into a separate file.
This allows us to test trace-based optimizations based on exactly what the
trace optimizer would get as input.
---
Diffs of the changes: (+17 -7)
Index: reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp
diff -u reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp:1.33 reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp:1.34
--- reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp:1.33 Tue May 18 11:51:28 2004
+++ reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp Wed May 19 03:48:36 2004
@@ -22,6 +22,7 @@
#include "Support/FileUtilities.h"
#include "llvm/Analysis/Verifier.h"
#include "llvm/Assembly/PrintModulePass.h"
+#include "llvm/Bytecode/Writer.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/CodeGen/MachineCodeEmitter.h"
@@ -81,20 +82,29 @@
}
void WriteTraceToFile (Trace &T) {
- std::string filename;
+ // Get unique filename for trace & corresponding module.
+ std::string traceFileName, bytecodeFileName;
+ Function *F = T.getFunction ();
unsigned count = 0;
do {
++count;
- filename = T.getFunction ()->getName () + ".trace" + utostr (count)
- + ".txt";
- } while (FileOpenable(filename));
- std::ofstream out (filename.c_str ());
- out << T.getFunction ()->getName () << "\n";
+ 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 ();
+}
/// 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