IR: Assert that resolve() is only called on uniqued nodes, NFC

Add an assertion in `UniquableMDNode::resolve()` to prevent temporaries
from being resolved (once they're merged back in).  Needed to shuffle
order of `resolve()` and `storeDistinctInContext()` to prevent it from
firing.

llvm-svn: 226489
This commit is contained in:
Duncan P. N. Exon Smith 2015-01-19 19:25:33 +00:00
parent 105acf7885
commit f08b8b4be6
1 changed files with 3 additions and 1 deletions

View File

@ -432,6 +432,7 @@ UniquableMDNode::UniquableMDNode(LLVMContext &C, unsigned ID,
}
void UniquableMDNode::resolve() {
assert(Storage == Uniqued && "Expected this to be uniqued");
assert(!isResolved() && "Expected this to be unresolved");
// Move the map, so that this immediately looks resolved.
@ -539,9 +540,9 @@ void UniquableMDNode::handleChangedOperand(void *Ref, Metadata *New) {
// Drop uniquing for self-reference cycles.
if (New == this) {
storeDistinctInContext();
if (!isResolved())
resolve();
storeDistinctInContext();
return;
}
@ -738,6 +739,7 @@ MDNodeFwdDecl *MDNode::getTemporary(LLVMContext &Context,
void MDNode::deleteTemporary(MDNode *N) { delete cast<MDNodeFwdDecl>(N); }
void UniquableMDNode::storeDistinctInContext() {
assert(isResolved() && "Expected resolved nodes");
Storage = Distinct;
if (auto *T = dyn_cast<MDTuple>(this))
T->setHash(0);