[llvm] r266536 - ValueMapper: Only put cyclic nodes into CyclicNodes, NFCI

Duncan P. N. Exon Smith via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 16 14:09:54 PDT 2016


Author: dexonsmith
Date: Sat Apr 16 16:09:53 2016
New Revision: 266536

URL: http://llvm.org/viewvc/llvm-project?rev=266536&view=rev
Log:
ValueMapper: Only put cyclic nodes into CyclicNodes, NFCI

As a minor fixup to r266258, only track nodes that needed a placeholder
in CyclicNodes in MDNodeMapper::mapUniquedNodes.  There should be no
observable functionality change, just some local memory savings because
CyclicNodes only needs to grow to accommodate nodes that are actually
involved in cycles.  (This was the original intent of r266258, or else
the vector would have been called "ChangedNodes".)

Modified:
    llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp

Modified: llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp?rev=266536&r1=266535&r2=266536&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp Sat Apr 16 16:09:53 2016
@@ -686,10 +686,19 @@ void MDNodeMapper::mapUniquedNodes() {
       continue;
     }
 
+    // Remember whether this node had a placeholder.
+    bool HadPlaceholder(D.Placeholder);
+
+    // Clone the uniqued node and remap the operands.
     TempMDNode ClonedN = D.Placeholder ? std::move(D.Placeholder) : N->clone();
     remapOperands(D, *ClonedN);
-    CyclicNodes.push_back(MDNode::replaceWithUniqued(std::move(ClonedN)));
-    M.mapToMetadata(N, CyclicNodes.back());
+    auto *NewN = MDNode::replaceWithUniqued(std::move(ClonedN));
+    M.mapToMetadata(N, NewN);
+
+    // Nodes that were referenced out of order in the POT are involved in a
+    // uniquing cycle.
+    if (HadPlaceholder)
+      CyclicNodes.push_back(NewN);
   }
 
   // Resolve cycles.




More information about the llvm-commits mailing list