diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-12-06 01:26:49 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-12-06 01:26:49 +0000 |
commit | da41af9e9423eeb435bbf64f94649726569ae45b (patch) | |
tree | 83c921701ee73320f6a6f0dfc313639105f22797 /llvm/lib/AsmParser | |
parent | 597dcc7a8deb329037175f79bd0bd406a2aa880b (diff) | |
download | bcm5719-llvm-da41af9e9423eeb435bbf64f94649726569ae45b.tar.gz bcm5719-llvm-da41af9e9423eeb435bbf64f94649726569ae45b.zip |
IR: Disallow complicated function-local metadata
Disallow complex types of function-local metadata. The only valid
function-local metadata is an `MDNode` whose sole argument is a
non-metadata function-local value.
Part of PR21532.
llvm-svn: 223564
Diffstat (limited to 'llvm/lib/AsmParser')
-rw-r--r-- | llvm/lib/AsmParser/LLParser.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index 3e56c8dc051..93eb490619f 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -4668,7 +4668,11 @@ bool LLParser::ParseMDNodeVector(SmallVectorImpl<Value*> &Elts, if (Lex.getKind() == lltok::rbrace) return false; + bool IsLocal = false; do { + if (IsLocal) + return TokError("unexpected operand after function-local metadata"); + // Null is a special case since it is typeless. if (EatIfPresent(lltok::kw_null)) { Elts.push_back(nullptr); @@ -4678,6 +4682,15 @@ bool LLParser::ParseMDNodeVector(SmallVectorImpl<Value*> &Elts, Value *V = nullptr; if (ParseTypeAndValue(V, PFS)) return true; Elts.push_back(V); + + if (isa<MDNode>(V) && cast<MDNode>(V)->isFunctionLocal()) + return TokError("unexpected nested function-local metadata"); + if (!V->getType()->isMetadataTy() && !isa<Constant>(V)) { + assert(PFS && "Unexpected function-local metadata without PFS"); + if (Elts.size() > 1) + return TokError("unexpected function-local metadata"); + IsLocal = true; + } } while (EatIfPresent(lltok::comma)); return false; |