Fix PR2113 by verifying allocations.
authorChris Lattner <sabre@nondot.org>
Sat, 1 Mar 2008 09:01:57 +0000 (09:01 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 1 Mar 2008 09:01:57 +0000 (09:01 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47792 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/Verifier.cpp
test/Verifier/2008-03-01-AllocaSized.ll [new file with mode: 0644]

index e86c89bfa82766e6a794d75ec8c98e5ab9a3064f..575bb82df756cd411a67061d0440292fc814bc0b 100644 (file)
@@ -1041,9 +1041,12 @@ void Verifier::visitStoreInst(StoreInst &SI) {
 }
 
 void Verifier::visitAllocationInst(AllocationInst &AI) {
-  const PointerType *Ptr = AI.getType();
-  Assert(Ptr->getAddressSpace() == 0, 
-    "Allocation instruction pointer not in the generic address space!");
+  const PointerType *PTy = AI.getType();
+  Assert1(PTy->getAddressSpace() == 0, 
+          "Allocation instruction pointer not in the generic address space!",
+          &AI);
+  Assert1(PTy->getElementType()->isSized(), "Cannot allocate unsized type",
+          &AI);
   visitInstruction(AI);
 }
 
diff --git a/test/Verifier/2008-03-01-AllocaSized.ll b/test/Verifier/2008-03-01-AllocaSized.ll
new file mode 100644 (file)
index 0000000..eb96ced
--- /dev/null
@@ -0,0 +1,8 @@
+; RUN: not llvm-as -f %s -o /dev/null |& grep {Cannot allocate unsized type}
+; PR2113
+
+define void @test() {
+       %A = alloca void()
+       ret void
+}
+