diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index adf4c9073ab8..7af85b5846cd 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -4633,6 +4633,9 @@ int LLParser::ParseAlloc(Instruction *&Inst, PerFunctionState &PFS) { if (ParseType(Ty)) return true; + if (!PointerType::isValidElementType(Ty)) + return TokError("pointer to this type is invalid"); + bool AteExtraComma = false; if (EatIfPresent(lltok::comma)) { if (Lex.getKind() == lltok::kw_align) { diff --git a/llvm/test/Assembler/alloca-invalid-type.ll b/llvm/test/Assembler/alloca-invalid-type.ll new file mode 100644 index 000000000000..fb2c05cc35af --- /dev/null +++ b/llvm/test/Assembler/alloca-invalid-type.ll @@ -0,0 +1,9 @@ +; RUN: not llvm-as < %s 2>&1 | FileCheck %s + +; CHECK: pointer to this type is invalid + +define void @test() { +entry: + alloca metadata !{null} + ret void +}