diff options
author | Chris Lattner <sabre@nondot.org> | 2010-02-03 00:22:02 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-02-03 00:22:02 +0000 |
commit | be2e76bbb358ba58aecc05c94fb98cf5c2981bd2 (patch) | |
tree | f4189010ce851064a45e854cdf9aa3b7b9e38177 /lib/CodeGen/LLVMTargetMachine.cpp | |
parent | 0c6a8f9eda4651e0f54a7edf171525d16b1ff3fa (diff) |
make any use of the "O" stream in asmprinter print to
stderr if in filetype=obj mode. This is a hack, and will
live until dwarf emission and other random stuff that is
not yet going through MCStreamer is upgraded. It only
impacts filetype=obj mode.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95166 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/LLVMTargetMachine.cpp')
-rw-r--r-- | lib/CodeGen/LLVMTargetMachine.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/CodeGen/LLVMTargetMachine.cpp b/lib/CodeGen/LLVMTargetMachine.cpp index af33776c3a..a53fdcc2a0 100644 --- a/lib/CodeGen/LLVMTargetMachine.cpp +++ b/lib/CodeGen/LLVMTargetMachine.cpp @@ -123,6 +123,7 @@ LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM, OwningPtr<MCContext> Context(new MCContext()); OwningPtr<MCStreamer> AsmStreamer; + formatted_raw_ostream *LegacyOutput; switch (FileType) { default: return CGFT_ErrorOccurred; case CGFT_AssemblyFile: @@ -130,6 +131,8 @@ LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM, getTargetData()->isLittleEndian(), getVerboseAsm(), /*instprinter*/0, /*codeemitter*/0)); + // Set the AsmPrinter's "O" to the output file. + LegacyOutput = &Out; break; case CGFT_ObjectFile: { // Create the code emitter for the target if it exists. If not, .o file @@ -139,6 +142,12 @@ LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM, return CGFT_ErrorOccurred; AsmStreamer.reset(createMachOStreamer(*Context, Out, MCE)); + + // Any output to the asmprinter's "O" stream is bad and needs to be fixed, + // force it to come out stderr. + // FIXME: this is horrible and leaks, eventually remove the raw_ostream from + // asmprinter. + LegacyOutput = new formatted_raw_ostream(errs()); break; } } @@ -146,7 +155,7 @@ LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM, // Create the AsmPrinter, which takes ownership of Context and AsmStreamer // if successful. FunctionPass *Printer = - getTarget().createAsmPrinter(Out, *this, *Context, *AsmStreamer, + getTarget().createAsmPrinter(*LegacyOutput, *this, *Context, *AsmStreamer, getMCAsmInfo()); if (Printer == 0) return CGFT_ErrorOccurred; |