diff options
| -rw-r--r-- | llvm/lib/AsmParser/LLParser.cpp | 3 | ||||
| -rw-r--r-- | llvm/lib/AsmParser/LLParser.h | 2 | ||||
| -rw-r--r-- | llvm/test/Assembler/invalid-untyped-metadata.ll | 6 |
3 files changed, 8 insertions, 3 deletions
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index df34ba8697f..ac7207f99c4 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -4128,8 +4128,7 @@ bool LLParser::ConvertValIDToValue(Type *Ty, ValID &ID, Value *&V, V = PFS->GetVal(ID.StrVal, Ty, ID.Loc, OC); return V == nullptr; case ValID::t_InlineAsm: { - assert(ID.FTy); - if (!InlineAsm::Verify(ID.FTy, ID.StrVal2)) + if (!ID.FTy || !InlineAsm::Verify(ID.FTy, ID.StrVal2)) return Error(ID.Loc, "invalid type for inline asm constraint string"); V = InlineAsm::get(ID.FTy, ID.StrVal, ID.StrVal2, ID.UIntVal & 1, (ID.UIntVal >> 1) & 1, diff --git a/llvm/lib/AsmParser/LLParser.h b/llvm/lib/AsmParser/LLParser.h index e161f95248c..51ba7dec919 100644 --- a/llvm/lib/AsmParser/LLParser.h +++ b/llvm/lib/AsmParser/LLParser.h @@ -59,7 +59,7 @@ namespace llvm { LLLexer::LocTy Loc; unsigned UIntVal; - FunctionType *FTy; + FunctionType *FTy = nullptr; std::string StrVal, StrVal2; APSInt APSIntVal; APFloat APFloatVal{0.0}; diff --git a/llvm/test/Assembler/invalid-untyped-metadata.ll b/llvm/test/Assembler/invalid-untyped-metadata.ll new file mode 100644 index 00000000000..5a97ae65964 --- /dev/null +++ b/llvm/test/Assembler/invalid-untyped-metadata.ll @@ -0,0 +1,6 @@ +; RUN: not llvm-as < %s 2>&1 | FileCheck %s + +; Tests bug: https://llvm.org/bugs/show_bug.cgi?id=24645 +; CHECK: error: invalid type for inline asm constraint string + + !3=! {%..d04 *asm" !6!={!H)4" ,"" |

