summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/MC/MCStreamer.h2
-rw-r--r--llvm/lib/CodeGen/LLVMTargetMachine.cpp19
-rw-r--r--llvm/tools/llc/llc.cpp1
3 files changed, 15 insertions, 7 deletions
diff --git a/llvm/include/llvm/MC/MCStreamer.h b/llvm/include/llvm/MC/MCStreamer.h
index be10947969a..cfd457261ff 100644
--- a/llvm/include/llvm/MC/MCStreamer.h
+++ b/llvm/include/llvm/MC/MCStreamer.h
@@ -282,7 +282,7 @@ namespace llvm {
/// createMachOStream - Create a machine code streamer which will generative
/// Mach-O format object files.
MCStreamer *createMachOStreamer(MCContext &Ctx, raw_ostream &OS,
- MCCodeEmitter *CE = 0);
+ MCCodeEmitter *CE);
/// createELFStreamer - Create a machine code streamer which will generative
/// ELF format object files.
diff --git a/llvm/lib/CodeGen/LLVMTargetMachine.cpp b/llvm/lib/CodeGen/LLVMTargetMachine.cpp
index d255492ef8f..af33776c3a6 100644
--- a/llvm/lib/CodeGen/LLVMTargetMachine.cpp
+++ b/llvm/lib/CodeGen/LLVMTargetMachine.cpp
@@ -124,23 +124,30 @@ LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
OwningPtr<MCStreamer> AsmStreamer;
switch (FileType) {
- default:
- case CGFT_ObjectFile:
- return CGFT_ErrorOccurred;
- case CGFT_AssemblyFile: {
+ default: return CGFT_ErrorOccurred;
+ case CGFT_AssemblyFile:
AsmStreamer.reset(createAsmStreamer(*Context, Out, *getMCAsmInfo(),
getTargetData()->isLittleEndian(),
getVerboseAsm(), /*instprinter*/0,
/*codeemitter*/0));
break;
+ case CGFT_ObjectFile: {
+ // Create the code emitter for the target if it exists. If not, .o file
+ // emission fails.
+ MCCodeEmitter *MCE = getTarget().createCodeEmitter(*this);
+ if (MCE == 0)
+ return CGFT_ErrorOccurred;
+
+ AsmStreamer.reset(createMachOStreamer(*Context, Out, MCE));
+ break;
}
}
// Create the AsmPrinter, which takes ownership of Context and AsmStreamer
// if successful.
FunctionPass *Printer =
- getTarget().createAsmPrinter(Out, *this, *Context, *AsmStreamer,
- getMCAsmInfo());
+ getTarget().createAsmPrinter(Out, *this, *Context, *AsmStreamer,
+ getMCAsmInfo());
if (Printer == 0)
return CGFT_ErrorOccurred;
diff --git a/llvm/tools/llc/llc.cpp b/llvm/tools/llc/llc.cpp
index eebd20846ca..c7bd1c67067 100644
--- a/llvm/tools/llc/llc.cpp
+++ b/llvm/tools/llc/llc.cpp
@@ -360,6 +360,7 @@ int main(int argc, char **argv) {
sys::Path(OutputFilename).eraseFromDisk();
return 1;
case TargetMachine::CGFT_AssemblyFile:
+ case TargetMachine::CGFT_ObjectFile:
break;
}
OpenPOWER on IntegriCloud