[llvm-commits] [llvm] r95166 - /llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp
Chris Lattner
sabre at nondot.org
Tue Feb 2 16:22:03 PST 2010
Author: lattner
Date: Tue Feb 2 18:22:02 2010
New Revision: 95166
URL: http://llvm.org/viewvc/llvm-project?rev=95166&view=rev
Log:
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.
Modified:
llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp
Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp?rev=95166&r1=95165&r2=95166&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp (original)
+++ llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Tue Feb 2 18:22:02 2010
@@ -123,6 +123,7 @@
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 @@
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 @@
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 @@
// 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;
More information about the llvm-commits
mailing list