mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-24 23:28:41 +00:00
IR: Allow temporary nodes to become uniqued or distinct
Add `MDNode::replaceWithUniqued()` and `MDNode::replaceWithDistinct()`, which mutate temporary nodes to become uniqued or distinct. On uniquing collisions, the unique version is returned and the node is deleted. This takes advantage of temporary nodes being folded back in, and should let me clean up some awkward logic in `MapMetadata()`. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226510 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -436,6 +436,33 @@ unsigned UniquableMDNode::countUnresolvedOperands() const {
|
||||
return NumUnresolved;
|
||||
}
|
||||
|
||||
void UniquableMDNode::makeUniqued() {
|
||||
assert(isTemporary() && "Expected this to be temporary");
|
||||
assert(!isResolved() && "Expected this to be unresolved");
|
||||
|
||||
// Make this 'uniqued'.
|
||||
Storage = Uniqued;
|
||||
if (unsigned NumUnresolved = countUnresolvedOperands())
|
||||
SubclassData32 = NumUnresolved;
|
||||
else
|
||||
resolve();
|
||||
|
||||
assert(isUniqued() && "Expected this to be uniqued");
|
||||
}
|
||||
|
||||
void UniquableMDNode::makeDistinct() {
|
||||
assert(isTemporary() && "Expected this to be temporary");
|
||||
assert(!isResolved() && "Expected this to be unresolved");
|
||||
|
||||
// Pretend to be uniqued, resolve the node, and then store in distinct table.
|
||||
Storage = Uniqued;
|
||||
resolve();
|
||||
storeDistinctInContext();
|
||||
|
||||
assert(isDistinct() && "Expected this to be distinct");
|
||||
assert(isResolved() && "Expected this to be resolved");
|
||||
}
|
||||
|
||||
void UniquableMDNode::resolve() {
|
||||
assert(isUniqued() && "Expected this to be uniqued");
|
||||
assert(!isResolved() && "Expected this to be unresolved");
|
||||
|
Reference in New Issue
Block a user