Teach ARM isLegalAddressingMode to handle unknown type without crashing. This fixes...
authorEvan Cheng <evan.cheng@apple.com>
Fri, 25 Jul 2008 00:55:17 +0000 (00:55 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Fri, 25 Jul 2008 00:55:17 +0000 (00:55 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54004 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/ARMISelLowering.cpp
test/CodeGen/ARM/2008-07-24-CodeGenPrepCrash.ll [new file with mode: 0644]

index 15c225aebe7be592cfc038046b67381622d7caaf..afc7ebc4c91f25f229efa025319775cbc24f4be0 100644 (file)
@@ -1598,7 +1598,7 @@ static bool isLegalAddressImmediate(int64_t V, MVT VT,
 /// by AM is legal for this target, for a load/store of the specified type.
 bool ARMTargetLowering::isLegalAddressingMode(const AddrMode &AM, 
                                               const Type *Ty) const {
-  if (!isLegalAddressImmediate(AM.BaseOffs, getValueType(Ty), Subtarget))
+  if (!isLegalAddressImmediate(AM.BaseOffs, getValueType(Ty, true), Subtarget))
     return false;
   
   // Can never fold addr of global into load/store.
diff --git a/test/CodeGen/ARM/2008-07-24-CodeGenPrepCrash.ll b/test/CodeGen/ARM/2008-07-24-CodeGenPrepCrash.ll
new file mode 100644 (file)
index 0000000..6ea75eb
--- /dev/null
@@ -0,0 +1,9 @@
+; RUN: llvm-as < %s | llc -march=arm
+; PR2589
+
+define void @main({ i32 }*) {
+entry:
+       %sret1 = alloca { i32 }         ; <{ i32 }*> [#uses=1]
+       load { i32 }* %sret1            ; <{ i32 }>:1 [#uses=0]
+       ret void
+}