diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-01-08 22:38:29 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-01-08 22:38:29 +0000 |
commit | 090a19bd3cab8b4247bb41eecf20e9f0f211332b (patch) | |
tree | 3c7d1b2041a30c42072457ae7adc70ef5d873bd3 /llvm/lib/AsmParser/LLParser.cpp | |
parent | 22ffa9b291e17a45ddc553817bbfee9d575e5600 (diff) | |
download | bcm5719-llvm-090a19bd3cab8b4247bb41eecf20e9f0f211332b.tar.gz bcm5719-llvm-090a19bd3cab8b4247bb41eecf20e9f0f211332b.zip |
IR: Add 'distinct' MDNodes to bitcode and assembly
Propagate whether `MDNode`s are 'distinct' through the other types of IR
(assembly and bitcode). This adds the `distinct` keyword to assembly.
Currently, no one actually calls `MDNode::getDistinct()`, so these nodes
only get created for:
- self-references, which are never uniqued, and
- nodes whose operands are replaced that hit a uniquing collision.
The concept of distinct nodes is still not quite first-class, since
distinct-ness doesn't yet survive across `MapMetadata()`.
Part of PR22111.
llvm-svn: 225474
Diffstat (limited to 'llvm/lib/AsmParser/LLParser.cpp')
-rw-r--r-- | llvm/lib/AsmParser/LLParser.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index 232c580b88f..bcb314dfbd7 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -618,8 +618,9 @@ bool LLParser::ParseStandaloneMetadata() { if (Lex.getKind() == lltok::Type) return TokError("unexpected type in metadata definition"); + bool IsDistinct = EatIfPresent(lltok::kw_distinct); if (ParseToken(lltok::exclaim, "Expected '!' here") || - ParseMDNode(Init)) + ParseMDNode(Init, IsDistinct)) return true; // See if this was forward referenced, if so, handle it. @@ -2945,12 +2946,15 @@ bool LLParser::ParseGlobalValueVector(SmallVectorImpl<Constant *> &Elts) { return false; } -bool LLParser::ParseMDNode(MDNode *&MD) { +bool LLParser::ParseMDNode(MDNode *&MD, bool IsDistinct) { SmallVector<Metadata *, 16> Elts; if (ParseMDNodeVector(Elts)) return true; - MD = MDNode::get(Context, Elts); + if (IsDistinct) + MD = MDNode::getDistinct(Context, Elts); + else + MD = MDNode::get(Context, Elts); return false; } |