From c9a780aec561a69ef5defed831ddc0ed81aa1bc9 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Mon, 19 Jan 2015 19:03:18 +0000 Subject: [PATCH] IR: Unify code for MDNode::isResolved(), NFC Unify the definitions of `MDNode::isResolved()` and `UniquableMDNode::isResolved()`. Previously, `UniquableMDNode` could answer this question more efficiently, but now that RAUW support has been unified with `MDNodeFwdDecl`, `MDNode` doesn't need any casts to figure out the answer. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226485 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/Metadata.h | 22 +++++++++++----------- lib/IR/Metadata.cpp | 6 ------ 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/include/llvm/IR/Metadata.h b/include/llvm/IR/Metadata.h index f6a3b7a9b79..27cacc157c0 100644 --- a/include/llvm/IR/Metadata.h +++ b/include/llvm/IR/Metadata.h @@ -721,7 +721,17 @@ public: void replaceOperandWith(unsigned I, Metadata *New); /// \brief Check if node is fully resolved. - bool isResolved() const; + /// + /// If \a isTemporary(), this always returns \c false; if \a isDistinct(), + /// this always returns \c true. + /// + /// If \a isUniqued(), returns \c true if this has already dropped RAUW + /// support (because all operands are resolved). + /// + /// As forward declarations are resolved, their containers should get + /// resolved automatically. However, if this (or one of its operands) is + /// involved in a cycle, \a resolveCycles() needs to be called explicitly. + bool isResolved() const { return !Context.hasReplaceableUses(); } bool isUniqued() const { return Storage == Uniqued; } bool isDistinct() const { return Storage == Distinct; } @@ -811,16 +821,6 @@ public: MD->getMetadataID() == MDLocationKind; } - /// \brief Check whether any operands are forward declarations. - /// - /// Returns \c true as long as any operands (or their operands, etc.) are \a - /// MDNodeFwdDecl. - /// - /// As forward declarations are resolved, their containers should get - /// resolved automatically. However, if this (or one of its operands) is - /// involved in a cycle, \a resolveCycles() needs to be called explicitly. - bool isResolved() const { return !Context.hasReplaceableUses(); } - /// \brief Resolve cycles. /// /// Once all forward declarations have been resolved, force cycles to be diff --git a/lib/IR/Metadata.cpp b/lib/IR/Metadata.cpp index 5b196388fc4..fe6ad34e162 100644 --- a/lib/IR/Metadata.cpp +++ b/lib/IR/Metadata.cpp @@ -407,12 +407,6 @@ MDNode::MDNode(LLVMContext &Context, unsigned ID, StorageType Storage, make_unique(Context)); } -bool MDNode::isResolved() const { - if (isa(this)) - return false; - return cast(this)->isResolved(); -} - static bool isOperandUnresolved(Metadata *Op) { if (auto *N = dyn_cast_or_null(Op)) return !N->isResolved();