mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-15 21:24:00 +00:00
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225474 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -1106,6 +1106,7 @@ std::error_code BitcodeReader::ParseMetadata() {
|
||||
// Read a record.
|
||||
Record.clear();
|
||||
unsigned Code = Stream.readRecord(Entry.ID, Record);
|
||||
bool IsDistinct = false;
|
||||
switch (Code) {
|
||||
default: // Default behavior: ignore.
|
||||
break;
|
||||
@ -1196,12 +1197,17 @@ std::error_code BitcodeReader::ParseMetadata() {
|
||||
NextMDValueNo++);
|
||||
break;
|
||||
}
|
||||
case bitc::METADATA_DISTINCT_NODE:
|
||||
IsDistinct = true;
|
||||
// fallthrough...
|
||||
case bitc::METADATA_NODE: {
|
||||
SmallVector<Metadata *, 8> Elts;
|
||||
Elts.reserve(Record.size());
|
||||
for (unsigned ID : Record)
|
||||
Elts.push_back(ID ? MDValueList.getValueFwdRef(ID - 1) : nullptr);
|
||||
MDValueList.AssignValue(MDNode::get(Context, Elts), NextMDValueNo++);
|
||||
MDValueList.AssignValue(IsDistinct ? MDNode::getDistinct(Context, Elts)
|
||||
: MDNode::get(Context, Elts),
|
||||
NextMDValueNo++);
|
||||
break;
|
||||
}
|
||||
case bitc::METADATA_STRING: {
|
||||
|
@ -773,7 +773,9 @@ static void WriteMDNode(const MDNode *N,
|
||||
assert(!isa<LocalAsMetadata>(MD) && "Unexpected function-local metadata");
|
||||
Record.push_back(VE.getMetadataID(MD) + 1);
|
||||
}
|
||||
Stream.EmitRecord(bitc::METADATA_NODE, Record);
|
||||
Stream.EmitRecord(N->isDistinct() ? bitc::METADATA_DISTINCT_NODE
|
||||
: bitc::METADATA_NODE,
|
||||
Record);
|
||||
Record.clear();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user