diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2016-04-17 18:42:27 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2016-04-17 18:42:27 +0000 |
| commit | 3c1c9875b9749e4e644b7fd783993a1c74a006f9 (patch) | |
| tree | b8f44deca31fc0651ba6ea4f1f7f7a9f91c22d09 /llvm/tools | |
| parent | d7c560e16675ccbd115df501b982f1d317b79861 (diff) | |
| download | bcm5719-llvm-3c1c9875b9749e4e644b7fd783993a1c74a006f9.tar.gz bcm5719-llvm-3c1c9875b9749e4e644b7fd783993a1c74a006f9.zip | |
Keep only the splitCodegen version that takes a factory.
This makes it much easier to see that all created TargetMachines are
equivalent.
llvm-svn: 266564
Diffstat (limited to 'llvm/tools')
| -rw-r--r-- | llvm/tools/gold/gold-plugin.cpp | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/llvm/tools/gold/gold-plugin.cpp b/llvm/tools/gold/gold-plugin.cpp index 15a70a22dc6..a93fc930d58 100644 --- a/llvm/tools/gold/gold-plugin.cpp +++ b/llvm/tools/gold/gold-plugin.cpp @@ -879,10 +879,16 @@ public: void runCodegenPasses(); private: + const Target *TheTarget; + std::string FeaturesString; + TargetOptions Options; + /// Create a target machine for the module. Must be unique for each /// module/task. void initTargetMachine(); + std::unique_ptr<TargetMachine> createTargetMachine(); + /// Run all LTO passes on the module. void runLTOPasses(); @@ -921,16 +927,23 @@ void CodeGen::initTargetMachine() { Triple TheTriple(TripleStr); std::string ErrMsg; - const Target *TheTarget = TargetRegistry::lookupTarget(TripleStr, ErrMsg); + TheTarget = TargetRegistry::lookupTarget(TripleStr, ErrMsg); if (!TheTarget) message(LDPL_FATAL, "Target not found: %s", ErrMsg.c_str()); SubtargetFeatures Features = getFeatures(TheTriple); - TargetOptions Options = InitTargetOptionsFromCodeGenFlags(); + FeaturesString = Features.getString(); + Options = InitTargetOptionsFromCodeGenFlags(); + + TM = createTargetMachine(); +} + +std::unique_ptr<TargetMachine> CodeGen::createTargetMachine() { + const std::string &TripleStr = M->getTargetTriple(); CodeGenOpt::Level CGOptLevel = getCGOptLevel(); - TM.reset(TheTarget->createTargetMachine( - TripleStr, options::mcpu, Features.getString(), Options, RelocationModel, + return std::unique_ptr<TargetMachine>(TheTarget->createTargetMachine( + TripleStr, options::mcpu, FeaturesString, Options, RelocationModel, CodeModel::Default, CGOptLevel)); } @@ -990,14 +1003,6 @@ void CodeGen::runCodegenPasses() { } void CodeGen::runSplitCodeGen(const SmallString<128> &BCFilename) { - const std::string &TripleStr = M->getTargetTriple(); - Triple TheTriple(TripleStr); - - SubtargetFeatures Features = getFeatures(TheTriple); - - TargetOptions Options = InitTargetOptionsFromCodeGenFlags(); - CodeGenOpt::Level CGOptLevel = getCGOptLevel(); - SmallString<128> Filename; // Note that openOutputFile will append a unique ID for each task if (!options::obj_path.empty()) @@ -1038,8 +1043,8 @@ void CodeGen::runSplitCodeGen(const SmallString<128> &BCFilename) { } // Run backend tasks. - splitCodeGen(std::move(M), OSPtrs, BCOSPtrs, options::mcpu, Features.getString(), - Options, RelocationModel, CodeModel::Default, CGOptLevel); + splitCodeGen(std::move(M), OSPtrs, BCOSPtrs, + [&]() { return createTargetMachine(); }); } for (auto &Filename : Filenames) |

