diff options
author | Kirill Stoimenov <kstoimenov@google.com> | 2025-05-07 00:00:28 +0000 |
---|---|---|
committer | Kirill Stoimenov <kstoimenov@google.com> | 2025-05-07 00:07:55 +0000 |
commit | 0274232b87177779e5c985eca06df22bf140f6cb (patch) | |
tree | 52aa44dcb66dfe321ed968eedd27b5b4d1a0e8f1 /llvm/lib/IR/Value.cpp | |
parent | 189702326a3a4c9072e346a8197913a4d968cbe3 (diff) | |
download | llvm-0274232b87177779e5c985eca06df22bf140f6cb.zip llvm-0274232b87177779e5c985eca06df22bf140f6cb.tar.gz llvm-0274232b87177779e5c985eca06df22bf140f6cb.tar.bz2 |
Revert "IR: Remove reference counts from ConstantData (#137314)"
This reverts commit 51a3bd919d68a8fb1b026377d6e86b1523d37433.
Possible breaks the build: https://lab.llvm.org/buildbot/#/builders/24/builds/8119/steps/9/logs/stdio
Diffstat (limited to 'llvm/lib/IR/Value.cpp')
-rw-r--r-- | llvm/lib/IR/Value.cpp | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/llvm/lib/IR/Value.cpp b/llvm/lib/IR/Value.cpp index d6cb65d..74a9605 100644 --- a/llvm/lib/IR/Value.cpp +++ b/llvm/lib/IR/Value.cpp @@ -148,18 +148,14 @@ void Value::destroyValueName() { } bool Value::hasNUses(unsigned N) const { - if (!UseList) - return N == 0; - - // TODO: Disallow for ConstantData and remove !UseList check? + if (!hasUseList()) + return Uses.Count == N; return hasNItems(use_begin(), use_end(), N); } bool Value::hasNUsesOrMore(unsigned N) const { - // TODO: Disallow for ConstantData and remove !UseList check? - if (!UseList) - return N == 0; - + if (!hasUseList()) + return Uses.Count >= N; return hasNItemsOrMore(use_begin(), use_end(), N); } @@ -263,9 +259,9 @@ bool Value::isUsedInBasicBlock(const BasicBlock *BB) const { } unsigned Value::getNumUses() const { - // TODO: Disallow for ConstantData and remove !UseList check? - if (!UseList) - return 0; + if (!hasUseList()) + return Uses.Count; + return (unsigned)std::distance(use_begin(), use_end()); } @@ -526,7 +522,7 @@ void Value::doRAUW(Value *New, ReplaceMetadataUses ReplaceMetaUses) { ValueAsMetadata::handleRAUW(this, New); while (!materialized_use_empty()) { - Use &U = *UseList; + Use &U = *Uses.List; // Must handle Constants specially, we cannot call replaceUsesOfWith on a // constant because they are uniqued. if (auto *C = dyn_cast<Constant>(U.getUser())) { @@ -1106,12 +1102,12 @@ const Value *Value::DoPHITranslation(const BasicBlock *CurBB, LLVMContext &Value::getContext() const { return VTy->getContext(); } void Value::reverseUseList() { - if (!UseList || !UseList->Next) + if (!Uses.List || !Uses.List->Next || !hasUseList()) // No need to reverse 0 or 1 uses. return; - Use *Head = UseList; - Use *Current = UseList->Next; + Use *Head = Uses.List; + Use *Current = Uses.List->Next; Head->Next = nullptr; while (Current) { Use *Next = Current->Next; @@ -1120,8 +1116,8 @@ void Value::reverseUseList() { Head = Current; Current = Next; } - UseList = Head; - Head->Prev = &UseList; + Uses.List = Head; + Head->Prev = &Uses.List; } bool Value::isSwiftError() const { |