[llvm] r226489 - IR: Assert that resolve() is only called on uniqued nodes, NFC

Duncan P. N. Exon Smith dexonsmith at apple.com
Mon Jan 19 11:25:34 PST 2015


Author: dexonsmith
Date: Mon Jan 19 13:25:33 2015
New Revision: 226489

URL: http://llvm.org/viewvc/llvm-project?rev=226489&view=rev
Log:
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.

Modified:
    llvm/trunk/lib/IR/Metadata.cpp

Modified: llvm/trunk/lib/IR/Metadata.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Metadata.cpp?rev=226489&r1=226488&r2=226489&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Metadata.cpp (original)
+++ llvm/trunk/lib/IR/Metadata.cpp Mon Jan 19 13:25:33 2015
@@ -432,6 +432,7 @@ UniquableMDNode::UniquableMDNode(LLVMCon
 }
 
 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::handleChangedOpera
 
   // Drop uniquing for self-reference cycles.
   if (New == this) {
-    storeDistinctInContext();
     if (!isResolved())
       resolve();
+    storeDistinctInContext();
     return;
   }
 
@@ -738,6 +739,7 @@ MDNodeFwdDecl *MDNode::getTemporary(LLVM
 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);





More information about the llvm-commits mailing list