protected:
/// \brief Storage flag for non-uniqued, otherwise unowned, metadata.
bool IsDistinctInContext : 1;
+ bool InRAUW : 1;
// TODO: expose remaining bits to subclasses.
unsigned short SubclassData16;
protected:
Metadata(unsigned ID)
- : SubclassID(ID), IsDistinctInContext(false), SubclassData16(0),
- SubclassData32(0) {}
+ : SubclassID(ID), IsDistinctInContext(false), InRAUW(false),
+ SubclassData16(0), SubclassData32(0) {}
~Metadata() {}
/// \brief Store this in a big non-uniqued untyped bucket.
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.
+ //
+ // FIXME: Can this cycle really happen?
+ setOperand(Op, New);
+ return;
+ }
auto &Store = getContext().pImpl->MDNodeSet;
Store.erase(this);
// Collision.
if (!isResolved()) {
// Still unresolved, so RAUW.
+ InRAUW = true;
ReplaceableUses->replaceAllUsesWith(*I);
delete this;
return;