[llvm] r265507 - AsmParser: Don't crash on unresolved !tbaa
Duncan P. N. Exon Smith via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 5 19:06:40 PDT 2016
Author: dexonsmith
Date: Tue Apr 5 21:06:40 2016
New Revision: 265507
URL: http://llvm.org/viewvc/llvm-project?rev=265507&view=rev
Log:
AsmParser: Don't crash on unresolved !tbaa
Instead of crashing, give a nice error. As a drive-by, fix the location
associated with the errors for unresolved metadata (the location was off
by one token).
Added:
llvm/trunk/test/Assembler/missing-tbaa.ll
Modified:
llvm/trunk/lib/AsmParser/LLParser.cpp
llvm/trunk/test/Assembler/invalid-mdnode-badref.ll
Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=265507&r1=265506&r2=265507&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Tue Apr 5 21:06:40 2016
@@ -100,9 +100,6 @@ void LLParser::restoreParsingState(const
/// ValidateEndOfModule - Do final validity and sanity checks at the end of the
/// module.
bool LLParser::ValidateEndOfModule() {
- for (unsigned I = 0, E = InstsWithTBAATag.size(); I < E; I++)
- UpgradeInstWithTBAATag(InstsWithTBAATag[I]);
-
// Handle any function attribute group forward references.
for (std::map<Value*, std::vector<unsigned> >::iterator
I = ForwardRefAttrGroups.begin(), E = ForwardRefAttrGroups.end();
@@ -205,6 +202,9 @@ bool LLParser::ValidateEndOfModule() {
N.second->resolveCycles();
}
+ for (unsigned I = 0, E = InstsWithTBAATag.size(); I < E; I++)
+ UpgradeInstWithTBAATag(InstsWithTBAATag[I]);
+
// Look for intrinsic functions and CallInst that need to be upgraded
for (Module::iterator FI = M->begin(), FE = M->end(); FI != FE; )
UpgradeCallsToIntrinsic(&*FI++); // must be post-increment, as we remove
@@ -601,6 +601,7 @@ bool LLParser::ParseMDString(MDString *&
// ::= '!' MDNodeNumber
bool LLParser::ParseMDNodeID(MDNode *&Result) {
// !{ ..., !42, ... }
+ LocTy IDLoc = Lex.getLoc();
unsigned MID = 0;
if (ParseUInt32(MID))
return true;
@@ -613,7 +614,7 @@ bool LLParser::ParseMDNodeID(MDNode *&Re
// Otherwise, create MDNode forward reference.
auto &FwdRef = ForwardRefMDNodes[MID];
- FwdRef = std::make_pair(MDTuple::getTemporary(Context, None), Lex.getLoc());
+ FwdRef = std::make_pair(MDTuple::getTemporary(Context, None), IDLoc);
Result = FwdRef.first.get();
NumberedMetadata[MID].reset(Result);
Modified: llvm/trunk/test/Assembler/invalid-mdnode-badref.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/invalid-mdnode-badref.ll?rev=265507&r1=265506&r2=265507&view=diff
==============================================================================
--- llvm/trunk/test/Assembler/invalid-mdnode-badref.ll (original)
+++ llvm/trunk/test/Assembler/invalid-mdnode-badref.ll Tue Apr 5 21:06:40 2016
@@ -1,5 +1,5 @@
; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
!named = !{!0}
-; CHECK: [[@LINE+1]]:14: error: use of undefined metadata '!1'
+; CHECK: [[@LINE+1]]:13: error: use of undefined metadata '!1'
!0 = !{!0, !1}
Added: llvm/trunk/test/Assembler/missing-tbaa.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/missing-tbaa.ll?rev=265507&view=auto
==============================================================================
--- llvm/trunk/test/Assembler/missing-tbaa.ll (added)
+++ llvm/trunk/test/Assembler/missing-tbaa.ll Tue Apr 5 21:06:40 2016
@@ -0,0 +1,11 @@
+; RUN: not llvm-as < %s 2>&1 | FileCheck %s
+; Check that !tbaa upgrade doesn't crash on undefined metadata (it should give
+; an error).
+
+define void @foo() {
+entry:
+ store i8 undef, i8* undef,
+; CHECK: :[[@LINE+1]]:10: error: use of undefined metadata '!1'
+ !tbaa !1
+ unreachable
+}
More information about the llvm-commits
mailing list