Trace code should always be exported just before code generation;
authorVikram S. Adve <vadve@cs.uiuc.edu>
Thu, 18 Oct 2001 13:51:20 +0000 (13:51 +0000)
committerVikram S. Adve <vadve@cs.uiuc.edu>
Thu, 18 Oct 2001 13:51:20 +0000 (13:51 +0000)
this is not a debugging option.  But we can export it as assembly
instead of bytecode if -debugtrace is specified.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@889 91177308-0d34-0410-b5e6-96231b3b80d8

tools/llc/Makefile
tools/llc/llc.cpp

index 3df1a7716664d6bafb9230eead86988345f092db..73efe6526096429df5bbe88e98b79a4fa332a991 100644 (file)
@@ -1,6 +1,6 @@
 LEVEL = ../..
 TOOLNAME = llc
-USEDLIBS = sparc regalloc sched select sparc regalloc sched select target opt instrument livevar bcreader vmcore asmwriter analysis support transforms
+USEDLIBS = sparc regalloc sched select sparc regalloc sched select target opt instrument livevar bcreader bcwriter vmcore asmwriter analysis support transforms
 
 include $(LEVEL)/Makefile.common
 
index 297e95c111bda14e929ae6abe1120ae3e0683a85..358f95b43a89f9031bb1082c8fd767a75f6aa412 100644 (file)
@@ -27,9 +27,8 @@ cl::Flag   DoNotEmitAssembly("noasm", "Do not emit assembly code", cl::Hidden);
 cl::Flag   TraceBBValues ("trace",
                           "Trace values at basic block and method exits");
 cl::Flag   TraceMethodValues("tracem", "Trace values only at method exits");
-cl::Flag   DebugTrace    ("dumptrace",
-                          "output trace code to a <fn>.trace.ll file",
-                          cl::Hidden);
+cl::Flag   DebugTrace    ("debugtrace",
+                          "output trace code as assembly instead of bytecode");
 
 
 // GetFileNameRoot - Helper function to get the basename of a filename...
@@ -104,6 +103,7 @@ public:
 //===---------------------------------------------------------------------===//
 
 int main(int argc, char **argv) {
+  int retCode = 0;
   cl::ParseCommandLineOptions(argc, argv, " llvm system compiler\n");
   
   // Allocate a target... in the future this will be controllable on the
@@ -130,30 +130,33 @@ int main(int argc, char **argv) {
   Passes.push_back(new HoistPHIConstants());
 
   if (TraceBBValues || TraceMethodValues)    // If tracing enabled...
-    // Insert trace code in all methods in the module
-    Passes.push_back(new InsertTraceCode(TraceBBValues, 
-                                         TraceBBValues || TraceMethodValues));
-
-
-  if (DebugTrace) {                          // If Trace Debugging is enabled...
-    // Then write the module with tracing code out in assembly form
-    assert(InputFilename != "-" && "files on stdin not supported with tracing");
-    string traceFileName = GetFileNameRoot(InputFilename) + ".trace.ll";
-
-    ostream *os = new ofstream(traceFileName.c_str(), 
-                               (Force ? 0 : ios::noreplace)|ios::out);
-    if (!os->good()) {
-      cerr << "Error opening " << traceFileName << "!\n";
-      delete os;
-      return 1;
+    {
+      // Insert trace code in all methods in the module
+      Passes.push_back(new InsertTraceCode(TraceBBValues, 
+                                           TraceBBValues ||TraceMethodValues));
+      
+      // Then write out the module with tracing code before code generation 
+      assert(InputFilename != "-" &&
+             "files on stdin not supported with tracing");
+      string traceFileName = GetFileNameRoot(InputFilename)
+                             + (DebugTrace? ".trace.ll" : ".trace.bc");
+      ostream *os = new ofstream(traceFileName.c_str(), 
+                                 (Force ? 0 : ios::noreplace)|ios::out);
+      if (!os->good()) {
+        cerr << "Error opening " << traceFileName
+             << "! SKIPPING OUTPUT OF TRACE CODE\n";
+        delete os;
+        retCode = 1;
+      }
+      
+      Passes.push_back(new PrintModulePass("", os,
+                                           /*deleteStream*/ true,
+                                           /*printAsBytecode*/ ! DebugTrace));
     }
-
-    Passes.push_back(new PrintModulePass("", os, true));
-  }
-
+  
   // If LLVM dumping after transformations is requested, add it to the pipeline
   if (DumpAsm)
-    Passes.push_back(new PrintModulePass("Method after xformations: \n",&cerr));
+    Passes.push_back(new PrintModulePass("Code after xformations: \n",&cerr));
 
   // Generate Target code...
   Passes.push_back(new GenerateCodeForTarget(Target));
@@ -189,7 +192,7 @@ int main(int argc, char **argv) {
   // runAllPasses frees the Pass objects after runAllPasses completes.
   Pass::runAllPassesAndFree(M.get(), Passes);
 
-  return 0;
+  return retCode;
 }