IR: Split out countUnresolvedOperands(), NFC
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Mon, 19 Jan 2015 22:18:29 +0000 (22:18 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Mon, 19 Jan 2015 22:18:29 +0000 (22:18 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226508 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/IR/Metadata.h
lib/IR/Metadata.cpp

index a9e54fd84c904cfa548b1df47060b7f9ea2ac620..47d5939c4c1a05d0d7a31cca70f247f9a923e24e 100644 (file)
@@ -843,6 +843,7 @@ private:
   void resolve();
   void resolveAfterOperandChange(Metadata *Old, Metadata *New);
   void decrementUnresolvedOperandCount();
+  unsigned countUnresolvedOperands() const;
 
   void deleteAsSubclass();
   UniquableMDNode *uniquify();
index 01394137e8ed61f726c99f1afc75a6645a052ebd..0e2586233681c314c3d31e95b8020f3929258cf0 100644 (file)
@@ -421,10 +421,7 @@ UniquableMDNode::UniquableMDNode(LLVMContext &C, unsigned ID,
     return;
 
   // Check whether any operands are unresolved, requiring re-uniquing.
-  unsigned NumUnresolved = 0;
-  for (const auto &Op : operands())
-    NumUnresolved += unsigned(isOperandUnresolved(Op));
-
+  unsigned NumUnresolved = countUnresolvedOperands();
   if (!NumUnresolved)
     return;
 
@@ -432,6 +429,13 @@ UniquableMDNode::UniquableMDNode(LLVMContext &C, unsigned ID,
   SubclassData32 = NumUnresolved;
 }
 
+unsigned UniquableMDNode::countUnresolvedOperands() const {
+  unsigned NumUnresolved = 0;
+  for (const auto &Op : operands())
+    NumUnresolved += unsigned(isOperandUnresolved(Op));
+  return NumUnresolved;
+}
+
 void UniquableMDNode::resolve() {
   assert(isUniqued() && "Expected this to be uniqued");
   assert(!isResolved() && "Expected this to be unresolved");