From: Hao Liu Date: Fri, 31 Oct 2014 02:35:34 +0000 (+0000) Subject: PR20557: Fix the bug that bogus cpu parameter crashes llc on AArch64 backend. X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=80021c5cf86168f049137e60ef9501f97bf2e52f PR20557: Fix the bug that bogus cpu parameter crashes llc on AArch64 backend. Initial patch by Oleg Ranevskyy. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220945 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/TargetLoweringBase.cpp b/lib/CodeGen/TargetLoweringBase.cpp index a5889db9104..d0acf0e6913 100644 --- a/lib/CodeGen/TargetLoweringBase.cpp +++ b/lib/CodeGen/TargetLoweringBase.cpp @@ -1200,8 +1200,12 @@ void TargetLoweringBase::computeRegisterProperties() { TransformToType[i] = MVT::Other; if (PreferredAction == TypeScalarizeVector) ValueTypeActions.setTypeAction(VT, TypeScalarizeVector); - else + else if (PreferredAction == TypeSplitVector) ValueTypeActions.setTypeAction(VT, TypeSplitVector); + else + // Set type action according to the number of elements. + ValueTypeActions.setTypeAction(VT, NElts == 1 ? TypeScalarizeVector + : TypeSplitVector); } else { TransformToType[i] = NVT; ValueTypeActions.setTypeAction(VT, TypeWidenVector); diff --git a/test/CodeGen/AArch64/legalize-bug-bogus-cpu.ll b/test/CodeGen/AArch64/legalize-bug-bogus-cpu.ll new file mode 100644 index 00000000000..b785a8f045f --- /dev/null +++ b/test/CodeGen/AArch64/legalize-bug-bogus-cpu.ll @@ -0,0 +1,8 @@ +; RUN: llc -march=aarch64 -mcpu=bogus -o - %s + +; Fix the bug in PR20557. Set mcpu to a bogus name, llc will crash in type +; legalization. +define <4 x float> @fneg4(<4 x float> %x) { + %sub = fsub <4 x float> zeroinitializer, %x + ret <4 x float> %sub +}