diff options
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/CodeGen/ParallelCG.cpp | 19 | ||||
-rw-r--r-- | llvm/lib/LTO/LTOCodeGenerator.cpp | 22 |
2 files changed, 13 insertions, 28 deletions
diff --git a/llvm/lib/CodeGen/ParallelCG.cpp b/llvm/lib/CodeGen/ParallelCG.cpp index e431acd6400..42096f06fe2 100644 --- a/llvm/lib/CodeGen/ParallelCG.cpp +++ b/llvm/lib/CodeGen/ParallelCG.cpp @@ -36,25 +36,6 @@ codegen(Module *M, llvm::raw_pwrite_stream &OS, CodeGenPasses.run(*M); } -std::unique_ptr<Module> -llvm::splitCodeGen(std::unique_ptr<Module> M, ArrayRef<raw_pwrite_stream *> OSs, - ArrayRef<llvm::raw_pwrite_stream *> BCOSs, StringRef CPU, - StringRef Features, const TargetOptions &Options, - Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL, - TargetMachine::CodeGenFileType FileType, - bool PreserveLocals) { - std::string TripleStr = M->getTargetTriple(); - std::string ErrMsg; - - const Target *TheTarget = TargetRegistry::lookupTarget(TripleStr, ErrMsg); - if (!TheTarget) - report_fatal_error(Twine("Target not found: ") + ErrMsg); - return splitCodeGen(std::move(M), OSs, BCOSs, [&]() { - return std::unique_ptr<TargetMachine>(TheTarget->createTargetMachine( - TripleStr, CPU, Features, Options, RM, CM, OL)); - }, FileType, PreserveLocals); -} - std::unique_ptr<Module> llvm::splitCodeGen( std::unique_ptr<Module> M, ArrayRef<llvm::raw_pwrite_stream *> OSs, ArrayRef<llvm::raw_pwrite_stream *> BCOSs, diff --git a/llvm/lib/LTO/LTOCodeGenerator.cpp b/llvm/lib/LTO/LTOCodeGenerator.cpp index 4f779d4390b..a1d4d7bd101 100644 --- a/llvm/lib/LTO/LTOCodeGenerator.cpp +++ b/llvm/lib/LTO/LTOCodeGenerator.cpp @@ -299,7 +299,7 @@ bool LTOCodeGenerator::determineTarget() { if (TargetMach) return true; - std::string TripleStr = MergedModule->getTargetTriple(); + TripleStr = MergedModule->getTargetTriple(); if (TripleStr.empty()) { TripleStr = sys::getDefaultTargetTriple(); MergedModule->setTargetTriple(TripleStr); @@ -308,8 +308,8 @@ bool LTOCodeGenerator::determineTarget() { // create target machine from info for merged modules std::string ErrMsg; - const Target *march = TargetRegistry::lookupTarget(TripleStr, ErrMsg); - if (!march) { + MArch = TargetRegistry::lookupTarget(TripleStr, ErrMsg); + if (!MArch) { emitError(ErrMsg); return false; } @@ -329,12 +329,16 @@ bool LTOCodeGenerator::determineTarget() { MCpu = "cyclone"; } - TargetMach.reset(march->createTargetMachine(TripleStr, MCpu, FeatureStr, - Options, RelocModel, - CodeModel::Default, CGOptLevel)); + TargetMach = createTargetMachine(); return true; } +std::unique_ptr<TargetMachine> LTOCodeGenerator::createTargetMachine() { + return std::unique_ptr<TargetMachine>( + MArch->createTargetMachine(TripleStr, MCpu, FeatureStr, Options, + RelocModel, CodeModel::Default, CGOptLevel)); +} + void LTOCodeGenerator::applyScopeRestrictions() { if (ScopeRestrictionsDone || !ShouldInternalize) return; @@ -473,9 +477,9 @@ bool LTOCodeGenerator::compileOptimized(ArrayRef<raw_pwrite_stream *> Out) { // parallelism level 1. This is achieved by having splitCodeGen return the // original module at parallelism level 1 which we then assign back to // MergedModule. - MergedModule = splitCodeGen( - std::move(MergedModule), Out, {}, MCpu, FeatureStr, Options, RelocModel, - CodeModel::Default, CGOptLevel, FileType, ShouldRestoreGlobalsLinkage); + MergedModule = splitCodeGen(std::move(MergedModule), Out, {}, + [&]() { return createTargetMachine(); }, FileType, + ShouldRestoreGlobalsLinkage); // If statistics were requested, print them out after codegen. if (llvm::AreStatisticsEnabled()) |