summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/Metadata.cpp
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-01-12 19:36:35 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-01-12 19:36:35 +0000
commitd9e6eb710822c6f51ccdff1e303220d4dd423885 (patch)
tree1c716bd3a16f23760cd8fe9a5a1f912a9c4e1200 /llvm/lib/IR/Metadata.cpp
parentcf2c96b0f69ae4f00985761c89fd10a1fd8d3468 (diff)
downloadbcm5719-llvm-d9e6eb710822c6f51ccdff1e303220d4dd423885.tar.gz
bcm5719-llvm-d9e6eb710822c6f51ccdff1e303220d4dd423885.zip
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 ;). llvm-svn: 225665
Diffstat (limited to 'llvm/lib/IR/Metadata.cpp')
-rw-r--r--llvm/lib/IR/Metadata.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/llvm/lib/IR/Metadata.cpp b/llvm/lib/IR/Metadata.cpp
index baa0b78762c..ec9b8801b81 100644
--- a/llvm/lib/IR/Metadata.cpp
+++ b/llvm/lib/IR/Metadata.cpp
@@ -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();
}
OpenPOWER on IntegriCloud