Index: include/llvm/LTO/Config.h =================================================================== --- include/llvm/LTO/Config.h +++ include/llvm/LTO/Config.h @@ -17,6 +17,7 @@ #include "llvm/IR/DiagnosticInfo.h" #include "llvm/Support/CodeGen.h" +#include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetOptions.h" #include @@ -41,6 +42,7 @@ Reloc::Model RelocModel = Reloc::PIC_; CodeModel::Model CodeModel = CodeModel::Default; CodeGenOpt::Level CGOptLevel = CodeGenOpt::Default; + TargetMachine::CodeGenFileType CGFileType = TargetMachine::CGFT_ObjectFile; unsigned OptLevel = 2; bool DisableVerify = false; Index: lib/LTO/LTO.cpp =================================================================== --- lib/LTO/LTO.cpp +++ lib/LTO/LTO.cpp @@ -94,6 +94,7 @@ AddUnsigned(Conf.RelocModel); AddUnsigned(Conf.CodeModel); AddUnsigned(Conf.CGOptLevel); + AddUnsigned(Conf.CGFileType); AddUnsigned(Conf.OptLevel); AddString(Conf.OptPipeline); AddString(Conf.AAPipeline); Index: lib/LTO/LTOBackend.cpp =================================================================== --- lib/LTO/LTOBackend.cpp +++ lib/LTO/LTOBackend.cpp @@ -271,8 +271,7 @@ auto Stream = AddStream(Task); legacy::PassManager CodeGenPasses; - if (TM->addPassesToEmitFile(CodeGenPasses, *Stream->OS, - TargetMachine::CGFT_ObjectFile)) + if (TM->addPassesToEmitFile(CodeGenPasses, *Stream->OS, Conf.CGFileType)) report_fatal_error("Failed to setup codegen"); CodeGenPasses.run(Mod); } Index: test/LTO/Resolution/X86/asm-output.ll =================================================================== --- /dev/null +++ test/LTO/Resolution/X86/asm-output.ll @@ -0,0 +1,19 @@ +; Test the ability to emit assembly code from the resolution-based LTO API +; +; RUN: llvm-as < %s > %t1.bc +; +; RUN: llvm-lto2 -filetype=asm -r %t1.bc,main,px -o %t2 %t1.bc +; RUN: FileCheck --check-prefix=ASM %s < %t2.0 +; RUN: llvm-lto2 -filetype=obj -r %t1.bc,main,px -o %t2 %t1.bc +; RUN: llvm-objdump -d %t2.0 | FileCheck --check-prefix=ASM %s +; +; ASM: main: + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +define i32 @main() { +entry: + ret i32 23 +} + Index: tools/llvm-lto2/llvm-lto2.cpp =================================================================== --- tools/llvm-lto2/llvm-lto2.cpp +++ tools/llvm-lto2/llvm-lto2.cpp @@ -199,6 +199,9 @@ return 1; } + if (FileType.getNumOccurrences()) + Conf.CGFileType = FileType; + Conf.OverrideTriple = OverrideTriple; Conf.DefaultTriple = DefaultTriple;