diff options
| author | Bob Wilson <bob.wilson@apple.com> | 2012-10-12 17:39:25 +0000 |
|---|---|---|
| committer | Bob Wilson <bob.wilson@apple.com> | 2012-10-12 17:39:25 +0000 |
| commit | 3f7e7c061c9ef9c3452c25da2ac7ea1bb4079509 (patch) | |
| tree | fd13fafa15340ad47781b6c382f442bbbb98f990 /llvm/tools/lto/LTOCodeGenerator.cpp | |
| parent | 28eb57114d05dd100d9b4a56e0a00be85cd09e3b (diff) | |
| download | bcm5719-llvm-3f7e7c061c9ef9c3452c25da2ac7ea1bb4079509.tar.gz bcm5719-llvm-3f7e7c061c9ef9c3452c25da2ac7ea1bb4079509.zip | |
Set default CPU for Darwin targets with LTO. <rdar://problem/12457841>
This is a temporary hack until Bill's project to record command line options
in the LLVM IR is ready. Clang currently sets a default CPU but that isn't
recorded anywhere and it doesn't get used in the final LTO compilation.
llvm-svn: 165809
Diffstat (limited to 'llvm/tools/lto/LTOCodeGenerator.cpp')
| -rw-r--r-- | llvm/tools/lto/LTOCodeGenerator.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/llvm/tools/lto/LTOCodeGenerator.cpp b/llvm/tools/lto/LTOCodeGenerator.cpp index f1814ab9aab..dd74ddde13d 100644 --- a/llvm/tools/lto/LTOCodeGenerator.cpp +++ b/llvm/tools/lto/LTOCodeGenerator.cpp @@ -218,12 +218,13 @@ bool LTOCodeGenerator::determineTarget(std::string& errMsg) { if (_target != NULL) return false; - std::string Triple = _linker.getModule()->getTargetTriple(); - if (Triple.empty()) - Triple = sys::getDefaultTargetTriple(); + std::string TripleStr = _linker.getModule()->getTargetTriple(); + if (TripleStr.empty()) + TripleStr = sys::getDefaultTargetTriple(); + llvm::Triple Triple(TripleStr); // create target machine from info for merged modules - const Target *march = TargetRegistry::lookupTarget(Triple, errMsg); + const Target *march = TargetRegistry::lookupTarget(TripleStr, errMsg); if (march == NULL) return true; @@ -244,11 +245,18 @@ bool LTOCodeGenerator::determineTarget(std::string& errMsg) { // construct LTOModule, hand over ownership of module and target SubtargetFeatures Features; - Features.getDefaultSubtargetFeatures(llvm::Triple(Triple)); + Features.getDefaultSubtargetFeatures(Triple); std::string FeatureStr = Features.getString(); + // Set a default CPU for Darwin triples. + if (_mCpu.empty() && Triple.isOSDarwin()) { + if (Triple.getArch() == llvm::Triple::x86_64) + _mCpu = "core2"; + else if (Triple.getArch() == llvm::Triple::x86) + _mCpu = "yonah"; + } TargetOptions Options; LTOModule::getTargetOptions(Options); - _target = march->createTargetMachine(Triple, _mCpu, FeatureStr, Options, + _target = march->createTargetMachine(TripleStr, _mCpu, FeatureStr, Options, RelocModel, CodeModel::Default, CodeGenOpt::Aggressive); return false; |

