[PATCH] D35287: llc: Require an explicit -mtriple=default to target default triple

Matthias Braun via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 11 18:41:38 PDT 2017


MatzeB created this revision.
Herald added subscribers: nemanjai, mcrosier.

Putting this up for discussion with a single test adapted. (Before landing I have to add explicit -mtriple to hundreds of tests):

We have a huge number of tests that just specify -march=xxx or -mcpu=yyy
hence have no OS specified and target the default OS which differs
between machines resulting in nondeterministic tests.

This changes llc to refuse tests that have no target triple specified.
The default can still be targeted with -mtriple=default.


Repository:
  rL LLVM

https://reviews.llvm.org/D35287

Files:
  test/CodeGen/PowerPC/vector.ll
  tools/llc/llc.cpp


Index: tools/llc/llc.cpp
===================================================================
--- tools/llc/llc.cpp
+++ tools/llc/llc.cpp
@@ -413,6 +413,9 @@
   bool SkipModule = MCPU == "help" ||
                     (!MAttrs.empty() && MAttrs.front() == "help");
 
+  if (TargetTriple == "default")
+    TargetTriple = sys::getDefaultTargetTriple();
+
   // If user just wants to list available options, skip module loading
   if (!SkipModule) {
     if (InputLanguage == "mir" ||
@@ -443,8 +446,11 @@
     TheTriple = Triple(Triple::normalize(TargetTriple));
   }
 
-  if (TheTriple.getTriple().empty())
-    TheTriple.setTriple(sys::getDefaultTargetTriple());
+  if (TheTriple.getTriple().empty()) {
+    errs() << argv[0] << ": No target triple specified.\n";
+    errs() << "Note: You may specify -mtriple=default for the default.\n";
+    return 1;
+  }
 
   // Get the target specific parser.
   std::string Error;
Index: test/CodeGen/PowerPC/vector.ll
===================================================================
--- test/CodeGen/PowerPC/vector.ll
+++ test/CodeGen/PowerPC/vector.ll
@@ -1,6 +1,6 @@
 ; Test that vectors are scalarized/lowered correctly.
-; RUN: llc -verify-machineinstrs < %s -march=ppc32 -mcpu=g5 > %t
-; RUN: llc -verify-machineinstrs < %s -march=ppc32 -mcpu=g3 >> %t
+; RUN: llc -verify-machineinstrs < %s -mtriple=ppc32-- -mcpu=g5 > %t
+; RUN: llc -verify-machineinstrs < %s -mtriple=ppc32-- -mcpu=g3 >> %t
 
 %d8 = type <8 x double>
 %f1 = type <1 x float>


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35287.106133.patch
Type: text/x-patch
Size: 1494 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170712/d0e1c951/attachment.bin>


More information about the llvm-commits mailing list