diff options
| author | Chris Lattner <sabre@nondot.org> | 2008-03-01 09:01:57 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2008-03-01 09:01:57 +0000 |
| commit | ffe0da0eb2160281222a4f8862f435d333792dd2 (patch) | |
| tree | e1eef17e19057fb416bd7a18d737fb4aa341a45e | |
| parent | 903ee68639f77598c9b58821080900234e3d03b4 (diff) | |
| download | bcm5719-llvm-ffe0da0eb2160281222a4f8862f435d333792dd2.tar.gz bcm5719-llvm-ffe0da0eb2160281222a4f8862f435d333792dd2.zip | |
Fix PR2113 by verifying allocations.
llvm-svn: 47792
| -rw-r--r-- | llvm/lib/VMCore/Verifier.cpp | 9 | ||||
| -rw-r--r-- | llvm/test/Verifier/2008-03-01-AllocaSized.ll | 8 |
2 files changed, 14 insertions, 3 deletions
diff --git a/llvm/lib/VMCore/Verifier.cpp b/llvm/lib/VMCore/Verifier.cpp index e86c89bfa82..575bb82df75 100644 --- a/llvm/lib/VMCore/Verifier.cpp +++ b/llvm/lib/VMCore/Verifier.cpp @@ -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/llvm/test/Verifier/2008-03-01-AllocaSized.ll b/llvm/test/Verifier/2008-03-01-AllocaSized.ll new file mode 100644 index 00000000000..eb96ced7882 --- /dev/null +++ b/llvm/test/Verifier/2008-03-01-AllocaSized.ll @@ -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 +} + |

