From 2c22f8dc09b638a375f671b81027f242a9775558 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Mon, 19 Jan 2015 19:25:33 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226489 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/IR/Metadata.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/IR/Metadata.cpp b/lib/IR/Metadata.cpp index fe6ad34e162..8a4710444f3 100644 --- a/lib/IR/Metadata.cpp +++ b/lib/IR/Metadata.cpp @@ -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(N); } void UniquableMDNode::storeDistinctInContext() { + assert(isResolved() && "Expected resolved nodes"); Storage = Distinct; if (auto *T = dyn_cast(this)) T->setHash(0);