[llvm-commits] CVS: reopt/tools/ttftest/ttftest.cpp

Brian Gaeke gaeke at cs.uiuc.edu
Mon Jun 14 01:43:02 PDT 2004


Changes in directory reopt/tools/ttftest:

ttftest.cpp updated: 1.4 -> 1.5

---
Log message:

Add code and a command-line option for printing out trace live-in/live-out
sets. Fold a few long lines.


---
Diffs of the changes:  (+46 -3)

Index: reopt/tools/ttftest/ttftest.cpp
diff -u reopt/tools/ttftest/ttftest.cpp:1.4 reopt/tools/ttftest/ttftest.cpp:1.5
--- reopt/tools/ttftest/ttftest.cpp:1.4	Sat May 22 01:56:41 2004
+++ reopt/tools/ttftest/ttftest.cpp	Mon Jun 14 01:42:38 2004
@@ -16,6 +16,7 @@
 
 #include "llvm/Analysis/Trace.h"
 #include "llvm/Analysis/Verifier.h"
+#include "llvm/Assembly/Writer.h"
 #include "llvm/Bytecode/Reader.h"
 #include "reopt/TraceToFunction.h"
 #include "llvm/Module.h"
@@ -30,10 +31,14 @@
 
 namespace {
   cl::opt<std::string> TraceFile("trace",
-    cl::desc("Name of file containing trace"), cl::value_desc("traceFileName"));
+    cl::desc("Name of file containing trace"),
+    cl::value_desc("traceFileName"));
   cl::opt<std::string> BytecodeFile("bc",
-    cl::desc("Name of file containing module"), cl::value_desc("bytecodeFileName"));
+    cl::desc("Name of file containing module"),
+    cl::value_desc("bytecodeFileName"));
   cl::opt<bool> Quiet("q", cl::desc("Be quiet"), cl::init(false));
+  cl::opt<bool> PrintLiveSets("print-live",
+    cl::desc("Print live-in/out sets to stdout"), cl::init(false));
 };
 
 /// getBasicBlockByNum - Returns the basic block in F whose index is
@@ -96,6 +101,40 @@
   return bbNum;
 }
 
+void printLiveSet (std::ostream &OS, const std::string Banner,
+                   LiveVariableSet &S, TraceFunction *TF,
+                   bool printCorrespondingValues = true) {
+  OS << Banner;
+  unsigned Count = 0;
+  assert (TF->MatrixFn->getParent () == TF->TraceFn->getParent ());
+  Module *M = TF->MatrixFn->getParent ();
+  if (S.begin () == S.end ()) {
+    OS << "Set is empty\n\n";
+    return;
+  }
+  for (LiveVariableSet::iterator i = S.begin (), e = S.end (); i != e; ++i) {
+    Value *MV = *i;
+    OS << Count << ": ";
+    WriteAsOperand (OS, MV, true, true, M);
+    if (printCorrespondingValues) {
+      OS << "  --->  ";
+      WriteAsOperand (OS, TF->getCorrespondingValue (MV, true), true,
+                      true, M);
+      OS << ", ";
+      WriteAsOperand (OS, TF->getCorrespondingValue (MV, false), true,
+                      true, M);
+    }
+    OS << "\n";
+    ++Count;
+  }
+  OS << "\n\n";
+}
+
+void printLiveSets (TraceFunction *TF) {
+  printLiveSet (std::cout, "Live-in set:\n", TF->LiveInSet, TF);
+  printLiveSet (std::cout, "Live-out set:\n", TF->LiveOutSet, TF);
+}
+
 int main (int argc, char **argv) {
   // Get command line arguments.
   cl::ParseCommandLineOptions(argc, argv, " trace-to-function tester\n");
@@ -128,6 +167,10 @@
     exit (1);
   } else {
     if (!Quiet) { std::cerr << "Verifier passes.\n"; }
-    exit (0);
   }
+
+  if (PrintLiveSets)
+    printLiveSets (TF);
+
+  return 0;
 }





More information about the llvm-commits mailing list