From 4d45090659f669f91de8aef88f67d790d86a5fe0 Mon Sep 17 00:00:00 2001 From: Tobias Edler von Koch Date: Thu, 19 Nov 2015 23:59:24 +0000 Subject: [LTO] Add option to emit assembly from LTOCodeGenerator This adds a new API, LTOCodeGenerator::setFileType, to choose the output file format for LTO CodeGen. A corresponding change to use this new API from llvm-lto and a test case is coming in a separate commit. Differential Revision: http://reviews.llvm.org/D14554 llvm-svn: 253622 --- llvm/lib/CodeGen/ParallelCG.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'llvm/lib/CodeGen/ParallelCG.cpp') diff --git a/llvm/lib/CodeGen/ParallelCG.cpp b/llvm/lib/CodeGen/ParallelCG.cpp index 748d3883ea1..e73ba029604 100644 --- a/llvm/lib/CodeGen/ParallelCG.cpp +++ b/llvm/lib/CodeGen/ParallelCG.cpp @@ -28,13 +28,13 @@ using namespace llvm; static void codegen(Module *M, llvm::raw_pwrite_stream &OS, const Target *TheTarget, StringRef CPU, StringRef Features, const TargetOptions &Options, Reloc::Model RM, - CodeModel::Model CM, CodeGenOpt::Level OL) { + CodeModel::Model CM, CodeGenOpt::Level OL, + TargetMachine::CodeGenFileType FileType) { std::unique_ptr TM(TheTarget->createTargetMachine( M->getTargetTriple(), CPU, Features, Options, RM, CM, OL)); legacy::PassManager CodeGenPasses; - if (TM->addPassesToEmitFile(CodeGenPasses, OS, - TargetMachine::CGFT_ObjectFile)) + if (TM->addPassesToEmitFile(CodeGenPasses, OS, FileType)) report_fatal_error("Failed to setup codegen"); CodeGenPasses.run(*M); } @@ -43,7 +43,8 @@ std::unique_ptr llvm::splitCodeGen(std::unique_ptr M, ArrayRef OSs, StringRef CPU, StringRef Features, const TargetOptions &Options, - Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL) { + Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL, + TargetMachine::CodeGenFileType FileType) { StringRef TripleStr = M->getTargetTriple(); std::string ErrMsg; const Target *TheTarget = TargetRegistry::lookupTarget(TripleStr, ErrMsg); @@ -52,7 +53,7 @@ llvm::splitCodeGen(std::unique_ptr M, if (OSs.size() == 1) { codegen(M.get(), *OSs[0], TheTarget, CPU, Features, Options, RM, CM, - OL); + OL, FileType); return M; } @@ -69,7 +70,7 @@ llvm::splitCodeGen(std::unique_ptr M, llvm::raw_pwrite_stream *ThreadOS = OSs[Threads.size()]; Threads.emplace_back( - [TheTarget, CPU, Features, Options, RM, CM, OL, + [TheTarget, CPU, Features, Options, RM, CM, OL, FileType, ThreadOS](const SmallVector &BC) { LLVMContext Ctx; ErrorOr> MOrErr = @@ -81,7 +82,7 @@ llvm::splitCodeGen(std::unique_ptr M, std::unique_ptr MPartInCtx = std::move(MOrErr.get()); codegen(MPartInCtx.get(), *ThreadOS, TheTarget, CPU, Features, - Options, RM, CM, OL); + Options, RM, CM, OL, FileType); }, // Pass BC using std::move to ensure that it get moved rather than // copied into the thread's context. -- cgit v1.2.3