aboutsummaryrefslogtreecommitdiff
path: root/tools/opt/opt.cpp
diff options
context:
space:
mode:
authorNadav Rotem <nrotem@apple.com>2013-01-01 08:00:32 +0000
committerNadav Rotem <nrotem@apple.com>2013-01-01 08:00:32 +0000
commitb338d897f9063ed6f02ed52527722c61ef827d5a (patch)
tree593f02c99f705e140daad5fa8bcf7a192d302fd7 /tools/opt/opt.cpp
parent117e4d2e190fe2e6427e5ec0b633048d9a744018 (diff)
Make opt grab the triple from the module and use it to initialize the target machine.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171341 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/opt/opt.cpp')
-rw-r--r--tools/opt/opt.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp
index 1bbe4e3623..af37e5e8c2 100644
--- a/tools/opt/opt.cpp
+++ b/tools/opt/opt.cpp
@@ -524,16 +524,11 @@ CodeGenOpt::Level GetCodeGenOptLevel() {
}
// Returns the TargetMachine instance or zero if no triple is provided.
-static TargetMachine* GetTargetMachine(std::string TripleStr) {
- if (TripleStr.empty())
- return 0;
-
- // Get the target specific parser.
+static TargetMachine* GetTargetMachine(Triple TheTriple) {
std::string Error;
- Triple TheTriple(Triple::normalize(TargetTriple));
-
const Target *TheTarget = TargetRegistry::lookupTarget(MArch, TheTriple,
Error);
+ // Some modules don't specify a triple, and this is okay.
if (!TheTarget) {
return 0;
}
@@ -656,7 +651,12 @@ int main(int argc, char **argv) {
if (TD)
Passes.add(TD);
- std::auto_ptr<TargetMachine> TM(GetTargetMachine(TargetTriple));
+ Triple ModuleTriple(M->getTargetTriple());
+ TargetMachine *Machine = 0;
+ if (ModuleTriple.getArch())
+ Machine = GetTargetMachine(Triple(ModuleTriple));
+ std::auto_ptr<TargetMachine> TM(Machine);
+
if (TM.get()) {
Passes.add(new TargetTransformInfo(TM->getScalarTargetTransformInfo(),
TM->getVectorTargetTransformInfo()));