- // 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));