[llvm-commits] [llvm] r171341 - in /llvm/trunk: test/Analysis/CostModel/no_info.ll test/Transforms/BBVectorize/loop1.ll tools/opt/opt.cpp

Nadav Rotem nrotem at apple.com
Tue Jan 1 00:00:32 PST 2013


Author: nadav
Date: Tue Jan  1 02:00:32 2013
New Revision: 171341

URL: http://llvm.org/viewvc/llvm-project?rev=171341&view=rev
Log:
Make opt grab the triple from the module and use it to initialize the target machine.

Modified:
    llvm/trunk/test/Analysis/CostModel/no_info.ll
    llvm/trunk/test/Transforms/BBVectorize/loop1.ll
    llvm/trunk/tools/opt/opt.cpp

Modified: llvm/trunk/test/Analysis/CostModel/no_info.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/CostModel/no_info.ll?rev=171341&r1=171340&r2=171341&view=diff
==============================================================================
--- llvm/trunk/test/Analysis/CostModel/no_info.ll (original)
+++ llvm/trunk/test/Analysis/CostModel/no_info.ll Tue Jan  1 02:00:32 2013
@@ -1,11 +1,8 @@
 ; RUN: opt < %s -cost-model -analyze | FileCheck %s
 
 ; The cost model does not have any target information so it can't make a decision.
-; Notice that OPT does not read the triple information from the module itself, only through the command line.
 
-; This info ignored:
-target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
-target triple = "x86_64-apple-macosx10.8.0"
+; -- No triple in this module --
 
 ;CHECK: Unknown cost {{.*}} add
 ;CHECK: Unknown cost {{.*}} ret

Modified: llvm/trunk/test/Transforms/BBVectorize/loop1.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/BBVectorize/loop1.ll?rev=171341&r1=171340&r2=171341&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/BBVectorize/loop1.ll (original)
+++ llvm/trunk/test/Transforms/BBVectorize/loop1.ll Tue Jan  1 02:00:32 2013
@@ -1,6 +1,6 @@
 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
-; RUN: opt < %s -bb-vectorize -bb-vectorize-req-chain-depth=3 -instcombine -gvn -S | FileCheck %s
+; RUN: opt < %s -bb-vectorize -bb-vectorize-req-chain-depth=3 -instcombine -gvn -S -mtriple=unknown | FileCheck %s
 ; RUN: opt < %s -basicaa -loop-unroll -unroll-threshold=45 -unroll-allow-partial -bb-vectorize -bb-vectorize-req-chain-depth=3 -instcombine -gvn -S | FileCheck %s -check-prefix=CHECK-UNRL
 ; The second check covers the use of alias analysis (with loop unrolling).
 

Modified: llvm/trunk/tools/opt/opt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/opt.cpp?rev=171341&r1=171340&r2=171341&view=diff
==============================================================================
--- llvm/trunk/tools/opt/opt.cpp (original)
+++ llvm/trunk/tools/opt/opt.cpp Tue Jan  1 02:00:32 2013
@@ -524,16 +524,11 @@
 }
 
 // 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 @@
   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()));





More information about the llvm-commits mailing list