From 17ab16a248fc1724b30a963aee91bb4f52997f1a Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 18 Dec 2013 21:29:44 +0000 Subject: [PATCH] Correctly handle the degenerated triple "thumb". 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 | 9 +++------ test/CodeGen/Thumb/triple.ll | 7 +++++++ 2 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 test/CodeGen/Thumb/triple.ll diff --git a/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp b/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp index 903b5d39497..400dab71486 100644 --- a/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp +++ b/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp @@ -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 index 00000000000..0a1759f081b --- /dev/null +++ b/test/CodeGen/Thumb/triple.ll @@ -0,0 +1,7 @@ +; RUN: llc < %s -mtriple=thumb | FileCheck %s + +; CHECK: .code 16 + +define void @f() { + ret void +}