diff options
author | Tobias Edler von Koch <tobias@codeaurora.org> | 2015-11-19 23:59:24 +0000 |
---|---|---|
committer | Tobias Edler von Koch <tobias@codeaurora.org> | 2015-11-19 23:59:24 +0000 |
commit | 4d45090659f669f91de8aef88f67d790d86a5fe0 (patch) | |
tree | b6f3f567baa56aaf1e2e7f1bb48fcb1500bdb653 /llvm/lib/CodeGen | |
parent | 8c3dbcab1d84d5590379ac3dafbd1765238db98f (diff) | |
download | bcm5719-llvm-4d45090659f669f91de8aef88f67d790d86a5fe0.tar.gz bcm5719-llvm-4d45090659f669f91de8aef88f67d790d86a5fe0.zip |
[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
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/ParallelCG.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
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<TargetMachine> 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<Module> llvm::splitCodeGen(std::unique_ptr<Module> M, ArrayRef<llvm::raw_pwrite_stream *> 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<Module> 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<Module> 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<char, 0> &BC) { LLVMContext Ctx; ErrorOr<std::unique_ptr<Module>> MOrErr = @@ -81,7 +82,7 @@ llvm::splitCodeGen(std::unique_ptr<Module> M, std::unique_ptr<Module> 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. |