Fix assertion failure in LLParser::ConvertValIDToValue
authorKarl Schimpf <kschimpf@google.com>
Thu, 3 Sep 2015 16:18:32 +0000 (16:18 +0000)
committerKarl Schimpf <kschimpf@google.com>
Thu, 3 Sep 2015 16:18:32 +0000 (16:18 +0000)
Summary:
Fixes bug 24645. Problem appears to be that the type may be undefined
when ConvertValIDToValue is called.

Reviewers: kcc

Subscribers: llvm-commits

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@246779 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AsmParser/LLParser.cpp
lib/AsmParser/LLParser.h
test/Assembler/invalid-untyped-metadata.ll [new file with mode: 0644]

index df34ba8697faee42ca4c0da9c25582057d88f886..ac7207f99c4f3417d0549ce0d199cb72e7b1235c 100644 (file)
@@ -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,
index e161f95248ce7a6cb65a387846672dd242c8662d..51ba7dec919cb12919a4c1be45952d6328334084 100644 (file)
@@ -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/test/Assembler/invalid-untyped-metadata.ll b/test/Assembler/invalid-untyped-metadata.ll
new file mode 100644 (file)
index 0000000..5a97ae6
--- /dev/null
@@ -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" ,""