mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-24 23:28:41 +00:00
IR: Prevent handleChangedOperand() recursion
Instead of returning early on `handleChangedOperand()` recursion (finally identified (and test added) in r225657), prevent it upfront by releasing operands before RAUW. Aside from massively different program flow, there should be no functionality change ;). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225665 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -534,12 +534,6 @@ void GenericMDNode::handleChangedOperand(void *Ref, Metadata *New) {
|
||||
setOperand(Op, New);
|
||||
return;
|
||||
}
|
||||
if (InRAUW) {
|
||||
// We just hit a recursion due to RAUW. Set the operand and move on, since
|
||||
// we're about to be deleted.
|
||||
setOperand(Op, New);
|
||||
return;
|
||||
}
|
||||
|
||||
auto &Store = getContext().pImpl->MDNodeSet;
|
||||
Store.erase(this);
|
||||
@@ -571,13 +565,17 @@ void GenericMDNode::handleChangedOperand(void *Ref, Metadata *New) {
|
||||
// Collision.
|
||||
if (!isResolved()) {
|
||||
// Still unresolved, so RAUW.
|
||||
InRAUW = true;
|
||||
//
|
||||
// First, clear out all operands to prevent any recursion (similar to
|
||||
// dropAllReferences(), but we still need the use-list).
|
||||
for (unsigned O = 0, E = getNumOperands(); O != E; ++O)
|
||||
setOperand(O, nullptr);
|
||||
ReplaceableUses->replaceAllUsesWith(*I);
|
||||
delete this;
|
||||
return;
|
||||
}
|
||||
|
||||
// Store in non-uniqued form if this node has already been resolved.
|
||||
// Store in non-uniqued form if RAUW isn't possible.
|
||||
storeDistinctInContext();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user