From b8e8faf480a95e4ed9ac86f3722eed2c68d388a7 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Mon, 12 Jan 2015 19:12:37 +0000 Subject: [PATCH] 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 --- include/llvm/IR/Metadata.h | 3 --- lib/IR/Metadata.cpp | 19 +++++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/llvm/IR/Metadata.h b/include/llvm/IR/Metadata.h index 4d0a04ea623..81dcef984f5 100644 --- a/include/llvm/IR/Metadata.h +++ b/include/llvm/IR/Metadata.h @@ -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(); }; diff --git a/lib/IR/Metadata.cpp b/lib/IR/Metadata.cpp index 34ecf3dfc2d..9cc258771db 100644 --- a/lib/IR/Metadata.cpp +++ b/lib/IR/Metadata.cpp @@ -228,8 +228,7 @@ void ReplaceableMetadataImpl::resolveAllUses(bool ResolveUsers) { continue; if (OwnerMD->isResolved()) continue; - OwnerMD->decrementUnresolvedOperands(); - if (!OwnerMD->hasUnresolvedOperands()) + if (!--OwnerMD->SubclassData32) OwnerMD->resolve(); } } @@ -418,12 +417,15 @@ GenericMDNode::GenericMDNode(LLVMContext &C, ArrayRef Vals, 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(void *Ref, Metadata *New) { 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 {