Correctly handle the degenerated triple "thumb".
authorRafael Espindola <rafael.espindola@gmail.com>
Wed, 18 Dec 2013 21:29:44 +0000 (21:29 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Wed, 18 Dec 2013 21:29:44 +0000 (21:29 +0000)
Fixes a crash in llc where some parts think the target is thumb and others think
it is ARM.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197607 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp
test/CodeGen/Thumb/triple.ll [new file with mode: 0644]

index 903b5d39497f5a5d9fa05276a07b80e672bb8efb..400dab71486f6995ab2ac108ddbed9b6a1b7ced6 100644 (file)
@@ -89,14 +89,11 @@ std::string ARM_MC::ParseARMTriple(StringRef TT, StringRef CPU) {
   unsigned Idx = 0;
 
   // FIXME: Enhance Triple helper class to extract ARM version.
-  bool isThumb = false;
+  bool isThumb = triple.getArch() == Triple::thumb;
   if (Len >= 5 && TT.substr(0, 4) == "armv")
     Idx = 4;
-  else if (Len >= 6 && TT.substr(0, 5) == "thumb") {
-    isThumb = true;
-    if (Len >= 7 && TT[5] == 'v')
-      Idx = 6;
-  }
+  else if (Len >= 7 && TT.substr(0, 6) == "thumbv")
+    Idx = 6;
 
   bool NoCPU = CPU == "generic" || CPU.empty();
   std::string ARMArchFeature;
diff --git a/test/CodeGen/Thumb/triple.ll b/test/CodeGen/Thumb/triple.ll
new file mode 100644 (file)
index 0000000..0a1759f
--- /dev/null
@@ -0,0 +1,7 @@
+; RUN: llc < %s -mtriple=thumb | FileCheck %s
+
+; CHECK: .code 16
+
+define void @f() {
+  ret void
+}