IR: Use SubclassData32 directly, NFC

Simplify some logic by accessing `SubclassData32` directly instead of
relying on API.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225653 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan P. N. Exon Smith 2015-01-12 19:12:37 +00:00
parent 095ca8f493
commit b8e8faf480
2 changed files with 11 additions and 11 deletions

View File

@ -761,9 +761,6 @@ public:
private: private:
void handleChangedOperand(void *Ref, Metadata *New); void handleChangedOperand(void *Ref, Metadata *New);
bool hasUnresolvedOperands() const { return SubclassData32; }
void incrementUnresolvedOperands() { ++SubclassData32; }
void decrementUnresolvedOperands() { --SubclassData32; }
void resolve(); void resolve();
}; };

View File

@ -228,8 +228,7 @@ void ReplaceableMetadataImpl::resolveAllUses(bool ResolveUsers) {
continue; continue;
if (OwnerMD->isResolved()) if (OwnerMD->isResolved())
continue; continue;
OwnerMD->decrementUnresolvedOperands(); if (!--OwnerMD->SubclassData32)
if (!OwnerMD->hasUnresolvedOperands())
OwnerMD->resolve(); OwnerMD->resolve();
} }
} }
@ -418,12 +417,15 @@ GenericMDNode::GenericMDNode(LLVMContext &C, ArrayRef<Metadata *> Vals,
return; return;
// Check whether any operands are unresolved, requiring re-uniquing. // Check whether any operands are unresolved, requiring re-uniquing.
unsigned NumUnresolved = 0;
for (const auto &Op : operands()) for (const auto &Op : operands())
if (isOperandUnresolved(Op)) NumUnresolved += unsigned(isOperandUnresolved(Op));
incrementUnresolvedOperands();
if (hasUnresolvedOperands()) if (!NumUnresolved)
ReplaceableUses.reset(new ReplaceableMetadataImpl); return;
ReplaceableUses.reset(new ReplaceableMetadataImpl);
SubclassData32 = NumUnresolved;
} }
GenericMDNode::~GenericMDNode() { GenericMDNode::~GenericMDNode() {
@ -545,12 +547,13 @@ void GenericMDNode::handleChangedOperand(void *Ref, Metadata *New) {
Store.insert(this); Store.insert(this);
if (!isResolved()) { if (!isResolved()) {
assert(SubclassData32 != 0 && "Expected unresolved operands");
// Check if the last unresolved operand has just been resolved; if so, // Check if the last unresolved operand has just been resolved; if so,
// resolve this as well. // resolve this as well.
if (isOperandUnresolved(Old)) { if (isOperandUnresolved(Old)) {
if (!isOperandUnresolved(New)) { if (!isOperandUnresolved(New)) {
decrementUnresolvedOperands(); if (!--SubclassData32)
if (!hasUnresolvedOperands())
resolve(); resolve();
} }
} else { } else {