[llvm] r229363 - AsmParser: Reject alloca with function type
David Majnemer
david.majnemer at gmail.com
Mon Feb 16 00:38:08 PST 2015
Author: majnemer
Date: Mon Feb 16 02:38:03 2015
New Revision: 229363
URL: http://llvm.org/viewvc/llvm-project?rev=229363&view=rev
Log:
AsmParser: Reject alloca with function type
Added:
llvm/trunk/test/Assembler/alloca-invalid-type-2.ll
- copied, changed from r229361, llvm/trunk/test/Assembler/alloca-invalid-type.ll
Modified:
llvm/trunk/lib/AsmParser/LLParser.cpp
llvm/trunk/test/Assembler/alloca-invalid-type.ll
llvm/trunk/test/Verifier/2008-03-01-AllocaSized.ll
Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=229363&r1=229362&r2=229363&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Mon Feb 16 02:38:03 2015
@@ -5109,16 +5109,16 @@ bool LLParser::ParseCall(Instruction *&I
/// ::= 'alloca' 'inalloca'? Type (',' TypeAndValue)? (',' 'align' i32)?
int LLParser::ParseAlloc(Instruction *&Inst, PerFunctionState &PFS) {
Value *Size = nullptr;
- LocTy SizeLoc;
+ LocTy SizeLoc, TyLoc;
unsigned Alignment = 0;
Type *Ty = nullptr;
bool IsInAlloca = EatIfPresent(lltok::kw_inalloca);
- if (ParseType(Ty)) return true;
+ if (ParseType(Ty, TyLoc)) return true;
- if (!PointerType::isValidElementType(Ty))
- return TokError("pointer to this type is invalid");
+ if (Ty->isFunctionTy() || !PointerType::isValidElementType(Ty))
+ return Error(TyLoc, "invalid type for alloca");
bool AteExtraComma = false;
if (EatIfPresent(lltok::comma)) {
Copied: llvm/trunk/test/Assembler/alloca-invalid-type-2.ll (from r229361, llvm/trunk/test/Assembler/alloca-invalid-type.ll)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/alloca-invalid-type-2.ll?p2=llvm/trunk/test/Assembler/alloca-invalid-type-2.ll&p1=llvm/trunk/test/Assembler/alloca-invalid-type.ll&r1=229361&r2=229363&rev=229363&view=diff
==============================================================================
--- llvm/trunk/test/Assembler/alloca-invalid-type.ll (original)
+++ llvm/trunk/test/Assembler/alloca-invalid-type-2.ll Mon Feb 16 02:38:03 2015
@@ -1,9 +1,9 @@
; RUN: not llvm-as < %s 2>&1 | FileCheck %s
-; CHECK: pointer to this type is invalid
+; CHECK: invalid type for alloca
define void @test() {
entry:
- alloca metadata !{null}
+ alloca i32 (i32)
ret void
}
Modified: llvm/trunk/test/Assembler/alloca-invalid-type.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/alloca-invalid-type.ll?rev=229363&r1=229362&r2=229363&view=diff
==============================================================================
--- llvm/trunk/test/Assembler/alloca-invalid-type.ll (original)
+++ llvm/trunk/test/Assembler/alloca-invalid-type.ll Mon Feb 16 02:38:03 2015
@@ -1,6 +1,6 @@
; RUN: not llvm-as < %s 2>&1 | FileCheck %s
-; CHECK: pointer to this type is invalid
+; CHECK: invalid type for alloca
define void @test() {
entry:
Modified: llvm/trunk/test/Verifier/2008-03-01-AllocaSized.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Verifier/2008-03-01-AllocaSized.ll?rev=229363&r1=229362&r2=229363&view=diff
==============================================================================
--- llvm/trunk/test/Verifier/2008-03-01-AllocaSized.ll (original)
+++ llvm/trunk/test/Verifier/2008-03-01-AllocaSized.ll Mon Feb 16 02:38:03 2015
@@ -1,5 +1,5 @@
; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck %s
-; CHECK: Cannot allocate unsized type
+; CHECK: invalid type for alloca
; PR2113
define void @test() {
More information about the llvm-commits
mailing list