[llvm] r225653 - IR: Use SubclassData32 directly, NFC
Duncan P. N. Exon Smith
dexonsmith at apple.com
Mon Jan 12 11:12:37 PST 2015
Author: dexonsmith
Date: Mon Jan 12 13:12:37 2015
New Revision: 225653
URL: http://llvm.org/viewvc/llvm-project?rev=225653&view=rev
Log:
IR: Use SubclassData32 directly, NFC
Simplify some logic by accessing `SubclassData32` directly instead of
relying on API.
Modified:
llvm/trunk/include/llvm/IR/Metadata.h
llvm/trunk/lib/IR/Metadata.cpp
Modified: llvm/trunk/include/llvm/IR/Metadata.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Metadata.h?rev=225653&r1=225652&r2=225653&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Metadata.h (original)
+++ llvm/trunk/include/llvm/IR/Metadata.h Mon Jan 12 13:12:37 2015
@@ -761,9 +761,6 @@ public:
private:
void handleChangedOperand(void *Ref, Metadata *New);
- bool hasUnresolvedOperands() const { return SubclassData32; }
- void incrementUnresolvedOperands() { ++SubclassData32; }
- void decrementUnresolvedOperands() { --SubclassData32; }
void resolve();
};
Modified: llvm/trunk/lib/IR/Metadata.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Metadata.cpp?rev=225653&r1=225652&r2=225653&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Metadata.cpp (original)
+++ llvm/trunk/lib/IR/Metadata.cpp Mon Jan 12 13:12:37 2015
@@ -228,8 +228,7 @@ void ReplaceableMetadataImpl::resolveAll
continue;
if (OwnerMD->isResolved())
continue;
- OwnerMD->decrementUnresolvedOperands();
- if (!OwnerMD->hasUnresolvedOperands())
+ if (!--OwnerMD->SubclassData32)
OwnerMD->resolve();
}
}
@@ -418,12 +417,15 @@ GenericMDNode::GenericMDNode(LLVMContext
return;
// Check whether any operands are unresolved, requiring re-uniquing.
+ unsigned NumUnresolved = 0;
for (const auto &Op : operands())
- if (isOperandUnresolved(Op))
- incrementUnresolvedOperands();
+ NumUnresolved += unsigned(isOperandUnresolved(Op));
- if (hasUnresolvedOperands())
- ReplaceableUses.reset(new ReplaceableMetadataImpl);
+ if (!NumUnresolved)
+ return;
+
+ ReplaceableUses.reset(new ReplaceableMetadataImpl);
+ SubclassData32 = NumUnresolved;
}
GenericMDNode::~GenericMDNode() {
@@ -545,12 +547,13 @@ void GenericMDNode::handleChangedOperand
Store.insert(this);
if (!isResolved()) {
+ assert(SubclassData32 != 0 && "Expected unresolved operands");
+
// Check if the last unresolved operand has just been resolved; if so,
// resolve this as well.
if (isOperandUnresolved(Old)) {
if (!isOperandUnresolved(New)) {
- decrementUnresolvedOperands();
- if (!hasUnresolvedOperands())
+ if (!--SubclassData32)
resolve();
}
} else {
More information about the llvm-commits
mailing list