]> granicus.if.org Git - clang/commitdiff
fix fallout of the LLVM codegen switching to formatted_raw_ostream.
authorChris Lattner <sabre@nondot.org>
Tue, 14 Jul 2009 20:39:15 +0000 (20:39 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 14 Jul 2009 20:39:15 +0000 (20:39 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75675 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/Backend.cpp

index 1c536b07cee2b413d1428058820df2c76e6c047a..fe95243d3df1802cfaf21cf631664b82ec3ca223 100644 (file)
@@ -24,8 +24,8 @@
 #include "llvm/Bitcode/ReaderWriter.h"
 #include "llvm/CodeGen/RegAllocRegistry.h"
 #include "llvm/CodeGen/SchedulerRegistry.h"
-#include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/Compiler.h"
+#include "llvm/Support/FormattedStream.h"
 #include "llvm/Support/StandardPasses.h"
 #include "llvm/Support/Timer.h"
 #include "llvm/System/Path.h"
@@ -42,6 +42,7 @@ namespace {
     BackendAction Action;
     CompileOptions CompileOpts;
     llvm::raw_ostream *AsmOutStream;
+    llvm::formatted_raw_ostream FormattedOutStream;
     ASTContext *Context;
 
     Timer LLVMIRGeneration;
@@ -79,13 +80,17 @@ namespace {
                     LLVMContext& C) :
       Action(action), 
       CompileOpts(compopts),
-      AsmOutStream(OS), 
+      AsmOutStream(OS),
       LLVMIRGeneration("LLVM IR Generation Time"),
       CodeGenerationTime("Code Generation Time"),
       Gen(CreateLLVMCodeGen(Diags, infile, compopts, C)),
       TheModule(0), TheTargetData(0), ModuleProvider(0),
       CodeGenPasses(0), PerModulePasses(0), PerFunctionPasses(0) {
       
+      if (AsmOutStream)
+        FormattedOutStream.setStream(*AsmOutStream,
+                                     formatted_raw_ostream::PRESERVE_STREAM);
+        
       // Enable -time-passes if -ftime-report is enabled.
       llvm::TimePassesIsEnabled = CompileOpts.TimePasses;
     }
@@ -145,7 +150,7 @@ namespace {
       
       // Force a flush here in case we never get released.
       if (AsmOutStream)
-        AsmOutStream->flush();
+        FormattedOutStream.flush();
     }
     
     virtual void HandleTagDeclDefinition(TagDecl *D) {
@@ -193,9 +198,9 @@ bool BackendConsumer::AddEmitPasses(std::string &Error) {
     return true;
 
   if (Action == Backend_EmitBC) {
-    getPerModulePasses()->add(createBitcodeWriterPass(*AsmOutStream));
+    getPerModulePasses()->add(createBitcodeWriterPass(FormattedOutStream));
   } else if (Action == Backend_EmitLL) {
-    getPerModulePasses()->add(createPrintModulePass(AsmOutStream));
+    getPerModulePasses()->add(createPrintModulePass(&FormattedOutStream));
   } else {
     bool Fast = CompileOpts.OptimizationLevel == 0;
 
@@ -240,7 +245,7 @@ bool BackendConsumer::AddEmitPasses(std::string &Error) {
 
     // Normal mode, emit a .s file by running the code generator.
     // Note, this also adds codegenerator level optimization passes.
-    switch (TM->addPassesToEmitFile(*PM, *AsmOutStream,
+    switch (TM->addPassesToEmitFile(*PM, FormattedOutStream,
                                     TargetMachine::AssemblyFile, OptLevel)) {
     default:
     case FileModel::Error: