[llvm] [Attributor] Remove unused functions (NFC) (PR #226906)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 28 00:38:31 PDT 2026
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/226906
AA::isGPUGenericAddressSpace, AA::isGPUGlobalAddressSpace:
Introduced on April 27, 2026 in commit
97dc0fcbceea0871ab86ecf6d534be42b42bc7d3 without any callers.
AADepGraphNode::getDeps:
Introduced on July 28, 2020 in commit
5ee07dc53fcaaad35d33478e8702e443ac1cb058 without any callers.
IRPosition::getNumArgs, IRPosition::getArg:
Introduced on June 19, 2023 in commit
5186c2f9f83131f87ee3dc308ac5f18c019998c5 without any callers.
IRPosition::isReturnPosition (0-argument overload):
Introduced on April 17, 2020 in commit
8228153f87707e9760a648608806cdba5e58141c without any callers.
Attributor::ArgumentReplacementInfo::getReplacementTypes:
Introduced on October 10, 2019 in commit
751336340dabc58f178a24f7b169f33366316f70 without any callers.
BooleanState::setAssumed:
Introduced on October 20, 2019 in commit
1a74645a70b38b48ff93251f7e7e51b2ab2ab403 without any callers.
AAUndefinedBehavior::isAssumedToCauseUB,
AAUndefinedBehavior::isKnownToCauseUB (0-argument overloads):
Introduced on December 24, 2019 in commit
58f324a468ffc66398199f1a55218e10b718e495 without any callers.
AAIsDead::isLiveInstSet:
The last callers were removed on August 14, 2019 in commit
def9928204e76b33cac8a98d54e995b7a6bb145d.
AAInstanceInfo::isKnownUniqueForAnalysis:
Introduced on March 16, 2022 in commit
af30de7788e121ec626d412abb5bddebd7701aee without any callers.
AAPrivatizablePtr::isKnownPrivatizablePtr:
Introduced on October 30, 2019 in commit
89c2e733e80ee35921ad4aff8058c3ff9d933c54 without any callers.
PotentialValuesState::contains:
Introduced on June 21, 2022 in commit
bf789b1957efd2482e1dbd164d91a6612a450fe3 without any callers.
PotentialValuesState::intersectWith:
Introduced on August 7, 2020 in commit
c575ba28de2f24cb2fd602780029bdaa8e0ce4a5 without any callers.
AAPointerInfo::Access::setWrittenValueUnknown:
The last caller was removed on December 12, 2022 in commit
6a2305484e8726da026790f803edfe4dd2abf6ae.
AAPointerInfo::Access::getUniqueRange, AAPointerInfo::Access::addRange:
Introduced on December 12, 2022 in commit
6a2305484e8726da026790f803edfe4dd2abf6ae without any callers, leaving
AAPointerInfo::RangeList::insert (1-argument overload) and
AAPointerInfo::RangeList::getUnique without any callers.
AAPointerInfo::Access::hasUniqueRange:
The last caller was removed on January 22, 2023 in commit
538cd2e8833eccc47179add268609b5adc558465, leaving
AAPointerInfo::RangeList::isUnique without any callers.
Assisted-by: Antigravity
>From 2ff981e3dcf13d246a456d3297f0a57d3671e53d Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 27 Sep 2026 09:08:29 -0700
Subject: [PATCH] [Attributor] Remove unused functions (NFC)
AA::isGPUGenericAddressSpace, AA::isGPUGlobalAddressSpace:
Introduced on April 27, 2026 in commit
97dc0fcbceea0871ab86ecf6d534be42b42bc7d3 without any callers.
AADepGraphNode::getDeps:
Introduced on July 28, 2020 in commit
5ee07dc53fcaaad35d33478e8702e443ac1cb058 without any callers.
IRPosition::getNumArgs, IRPosition::getArg:
Introduced on June 19, 2023 in commit
5186c2f9f83131f87ee3dc308ac5f18c019998c5 without any callers.
IRPosition::isReturnPosition (0-argument overload):
Introduced on April 17, 2020 in commit
8228153f87707e9760a648608806cdba5e58141c without any callers.
Attributor::ArgumentReplacementInfo::getReplacementTypes:
Introduced on October 10, 2019 in commit
751336340dabc58f178a24f7b169f33366316f70 without any callers.
BooleanState::setAssumed:
Introduced on October 20, 2019 in commit
1a74645a70b38b48ff93251f7e7e51b2ab2ab403 without any callers.
AAUndefinedBehavior::isAssumedToCauseUB,
AAUndefinedBehavior::isKnownToCauseUB (0-argument overloads):
Introduced on December 24, 2019 in commit
58f324a468ffc66398199f1a55218e10b718e495 without any callers.
AAIsDead::isLiveInstSet:
The last callers were removed on August 14, 2019 in commit
def9928204e76b33cac8a98d54e995b7a6bb145d.
AAInstanceInfo::isKnownUniqueForAnalysis:
Introduced on March 16, 2022 in commit
af30de7788e121ec626d412abb5bddebd7701aee without any callers.
AAPrivatizablePtr::isKnownPrivatizablePtr:
Introduced on October 30, 2019 in commit
89c2e733e80ee35921ad4aff8058c3ff9d933c54 without any callers.
PotentialValuesState::contains:
Introduced on June 21, 2022 in commit
bf789b1957efd2482e1dbd164d91a6612a450fe3 without any callers.
PotentialValuesState::intersectWith:
Introduced on August 7, 2020 in commit
c575ba28de2f24cb2fd602780029bdaa8e0ce4a5 without any callers.
AAPointerInfo::Access::setWrittenValueUnknown:
The last caller was removed on December 12, 2022 in commit
6a2305484e8726da026790f803edfe4dd2abf6ae.
AAPointerInfo::Access::getUniqueRange, AAPointerInfo::Access::addRange:
Introduced on December 12, 2022 in commit
6a2305484e8726da026790f803edfe4dd2abf6ae without any callers, leaving
AAPointerInfo::RangeList::insert (1-argument overload) and
AAPointerInfo::RangeList::getUnique without any callers.
AAPointerInfo::Access::hasUniqueRange:
The last caller was removed on January 22, 2023 in commit
538cd2e8833eccc47179add268609b5adc558465, leaving
AAPointerInfo::RangeList::isUnique without any callers.
Assisted-by: Antigravity
---
llvm/include/llvm/Transforms/IPO/Attributor.h | 129 ------------------
llvm/lib/Transforms/IPO/Attributor.cpp | 20 ---
2 files changed, 149 deletions(-)
diff --git a/llvm/include/llvm/Transforms/IPO/Attributor.h b/llvm/include/llvm/Transforms/IPO/Attributor.h
index 066883afafb95..61ecb0a5a087f 100644
--- a/llvm/include/llvm/Transforms/IPO/Attributor.h
+++ b/llvm/include/llvm/Transforms/IPO/Attributor.h
@@ -168,14 +168,6 @@ using InstExclusionSetTy = SmallPtrSet<Instruction *, 4>;
/// Return true iff \p M target a GPU (and we can use GPU AS reasoning).
LLVM_ABI bool isGPU(const Module &M);
-/// Check if the given address space \p AS corresponds to a GPU generic
-/// address space for the target triple in module \p M.
-LLVM_ABI bool isGPUGenericAddressSpace(const Module &M, unsigned AS);
-
-/// Check if the given address space \p AS corresponds to a GPU global
-/// address space for the target triple in module \p M.
-LLVM_ABI bool isGPUGlobalAddressSpace(const Module &M, unsigned AS);
-
/// Check if the given address space \p AS corresponds to a GPU shared
/// address space for the target triple in module \p M.
LLVM_ABI bool isGPUSharedAddressSpace(const Module &M, unsigned AS);
@@ -532,7 +524,6 @@ struct AADepGraphNode {
virtual void print(Attributor *, raw_ostream &OS) const {
OS << "AADepNode Impl\n";
}
- DepSetTy &getDeps() { return Deps; }
friend struct Attributor;
friend struct AADepGraph;
@@ -852,28 +843,6 @@ struct IRPosition {
return getAssociatedFunction()->setAttributes(AttrList);
}
- /// Return the number of arguments associated with this function or call site
- /// scope.
- unsigned getNumArgs() const {
- assert((getPositionKind() == IRP_CALL_SITE ||
- getPositionKind() == IRP_FUNCTION) &&
- "Only valid for function/call site positions!");
- if (auto *CB = dyn_cast<CallBase>(&getAnchorValue()))
- return CB->arg_size();
- return getAssociatedFunction()->arg_size();
- }
-
- /// Return theargument \p ArgNo associated with this function or call site
- /// scope.
- Value *getArg(unsigned ArgNo) const {
- assert((getPositionKind() == IRP_CALL_SITE ||
- getPositionKind() == IRP_FUNCTION) &&
- "Only valid for function/call site positions!");
- if (auto *CB = dyn_cast<CallBase>(&getAnchorValue()))
- return CB->getArgOperand(ArgNo);
- return getAssociatedFunction()->getArg(ArgNo);
- }
-
/// Return the associated position kind.
Kind getPositionKind() const {
char EncodingBits = getEncodingBits();
@@ -1028,10 +997,6 @@ struct IRPosition {
return EncodingBits == ENC_RETURNED_VALUE;
}
- /// Return true if the encoding bits describe a returned or call site returned
- /// position.
- bool isReturnPosition() const { return isReturnPosition(getEncodingBits()); }
-
/// The encoding of the IRPosition is a combination of a pointer and two
/// encoding bits. The values of the encoding bits are defined in the enum
/// below. The pointer is either a Value* (for the first three encoding bit
@@ -2259,9 +2224,6 @@ struct Attributor {
const Function &getReplacedFn() const { return ReplacedFn; }
const Argument &getReplacedArg() const { return ReplacedArg; }
unsigned getNumReplacementArgs() const { return ReplacementTypes.size(); }
- const SmallVectorImpl<Type *> &getReplacementTypes() const {
- return ReplacementTypes;
- }
///}
@@ -2915,9 +2877,6 @@ struct BooleanState : public IntegerStateBase<bool, true, false> {
BooleanState() = default;
BooleanState(base_t Assumed) : super(Assumed) {}
- /// Set the assumed value to \p Value but never below the known one.
- void setAssumed(bool Value) { Assumed &= (Known | Value); }
-
/// Set the known and asssumed value to \p Value.
void setKnown(bool Value) {
Known |= Value;
@@ -3808,15 +3767,9 @@ struct AAUndefinedBehavior
using Base = StateWrapper<BooleanState, AbstractAttribute>;
AAUndefinedBehavior(const IRPosition &IRP, Attributor &A) : Base(IRP) {}
- /// Return true if "undefined behavior" is assumed.
- bool isAssumedToCauseUB() const { return getAssumed(); }
-
/// Return true if "undefined behavior" is assumed for a specific instruction.
virtual bool isAssumedToCauseUB(Instruction *I) const = 0;
- /// Return true if "undefined behavior" is known.
- bool isKnownToCauseUB() const { return getKnown(); }
-
/// Return true if "undefined behavior" is known for a specific instruction.
virtual bool isKnownToCauseUB(Instruction *I) const = 0;
@@ -4051,20 +4004,6 @@ struct AAIsDead
/// is propagated which allows us to remove the store in turn.
virtual bool isRemovableStore() const { return false; }
- /// This method is used to check if at least one instruction in a collection
- /// of instructions is live.
- template <typename T> bool isLiveInstSet(T begin, T end) const {
- for (const auto &I : llvm::make_range(begin, end)) {
- assert(I->getFunction() == getIRPosition().getAssociatedFunction() &&
- "Instruction must be in the same anchor scope function.");
-
- if (!isAssumedDead(I))
- return true;
- }
-
- return false;
- }
-
public:
/// Create an abstract attribute view for the position \p IRP.
LLVM_ABI static AAIsDead &createForPosition(const IRPosition &IRP,
@@ -4345,12 +4284,6 @@ struct AAInstanceInfo : public StateWrapper<BooleanState, AbstractAttribute> {
AAInstanceInfo(const IRPosition &IRP, Attributor &A)
: StateWrapper<BooleanState, AbstractAttribute>(IRP) {}
- /// Return true if we know that the underlying value is unique in its scope
- /// wrt. the Attributor analysis. That means it might not be unique but we can
- /// still use pointer equality without risking to represent two instances with
- /// one `llvm::Value`.
- bool isKnownUniqueForAnalysis() const { return isKnown(); }
-
/// Return true if we assume that the underlying value is unique in its scope
/// wrt. the Attributor analysis. That means it might not be unique but we can
/// still use pointer equality without risking to represent two instances with
@@ -4626,9 +4559,6 @@ struct AAPrivatizablePtr
/// Returns true if pointer privatization is assumed to be possible.
bool isAssumedPrivatizablePtr() const { return getAssumed(); }
- /// Returns true if pointer privatization is known to be possible.
- bool isKnownPrivatizablePtr() const { return getKnown(); }
-
/// See AbstractAttribute::requiresCallersForArgOrFunction
static bool requiresCallersForArgOrFunction() { return true; }
@@ -5077,10 +5007,6 @@ template <typename MemberTy> struct PotentialValuesState : AbstractState {
return *this;
}
- bool contains(const MemberTy &V) const {
- return !isValidState() ? true : Set.contains(V);
- }
-
protected:
SetTy &getAssumedSet() {
assert(isValidState() && "This set shoud not be used when it is invalid!");
@@ -5130,26 +5056,6 @@ template <typename MemberTy> struct PotentialValuesState : AbstractState {
reduceUndefValue();
}
- /// Take intersection with R.
- void intersectWith(const PotentialValuesState &R) {
- /// If R is a full set, do nothing.
- if (!R.isValidState())
- return;
- /// If this is a full set, change this to R.
- if (!isValidState()) {
- *this = R;
- return;
- }
- SetTy IntersectSet;
- for (const MemberTy &C : Set) {
- if (R.Set.count(C))
- IntersectSet.insert(C);
- }
- Set = IntersectSet;
- UndefIsContained &= R.undefIsContained();
- reduceUndefValue();
- }
-
/// A helper state which indicate whether this state is valid or not.
BooleanState IsValidState;
@@ -5969,13 +5875,6 @@ struct AAPointerInfo : public AbstractAttribute {
return std::make_pair(LB, Changed);
}
- /// Insert the given range \p R, maintaining sorted order.
- ///
- /// \return The place of insertion and true iff anything changed.
- std::pair<iterator, bool> insert(const RangeTy &R) {
- return insert(Ranges.begin(), R);
- }
-
/// Add the increment \p Inc to the offset of every range.
void addToAllOffsets(int64_t Inc) {
assert(!isUnassigned() &&
@@ -5987,17 +5886,6 @@ struct AAPointerInfo : public AbstractAttribute {
}
}
- /// Return true iff there is exactly one range and it is known.
- bool isUnique() const {
- return Ranges.size() == 1 && !Ranges.front().offsetOrSizeAreUnknown();
- }
-
- /// Return the unique range, assuming it exists.
- const RangeTy &getUnique() const {
- assert(isUnique() && "No unique range to return!");
- return Ranges.front();
- }
-
/// Return true iff the list contains an unknown range.
bool isUnknown() const {
if (isUnassigned())
@@ -6131,9 +6019,6 @@ struct AAPointerInfo : public AbstractAttribute {
return Content.has_value() && !*Content;
}
- /// Set the value written to nullptr, i.e., unknown.
- void setWrittenValueUnknown() { Content = nullptr; }
-
/// Return the type associated with the access, if known.
Type *getType() const { return Ty; }
@@ -6148,20 +6033,6 @@ struct AAPointerInfo : public AbstractAttribute {
/// determined.
std::optional<Value *> getContent() const { return Content; }
- bool hasUniqueRange() const { return Ranges.isUnique(); }
- const AA::RangeTy &getUniqueRange() const { return Ranges.getUnique(); }
-
- /// Add a range accessed by this Access.
- ///
- /// If there are multiple ranges, then this is a "may access".
- void addRange(int64_t Offset, int64_t Size) {
- Ranges.insert({Offset, Size});
- if (!hasUniqueRange()) {
- Kind = AccessKind(Kind | AK_MAY);
- Kind = AccessKind(Kind & ~AK_MUST);
- }
- }
-
const RangeList &getRanges() const { return Ranges; }
using const_iterator = RangeList::const_iterator;
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index 338240b2f8087..388f0c36185d8 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -222,26 +222,6 @@ bool AA::isGPU(const Module &M) {
return T.isGPU();
}
-bool AA::isGPUGenericAddressSpace(const Module &M, unsigned AS) {
- assert(AA::isGPU(M) && "Only callable on GPU targets");
- Triple T(M.getTargetTriple());
-
- if (T.isSPIRV())
- return AS == static_cast<unsigned>(SPIRVAddressSpace::Generic);
-
- return AS == static_cast<unsigned>(NVPTXAMDGPUAddressSpace::Generic);
-}
-
-bool AA::isGPUGlobalAddressSpace(const Module &M, unsigned AS) {
- assert(AA::isGPU(M) && "Only callable on GPU targets");
- Triple T(M.getTargetTriple());
-
- if (T.isSPIRV())
- return AS == static_cast<unsigned>(SPIRVAddressSpace::Global);
-
- return AS == static_cast<unsigned>(NVPTXAMDGPUAddressSpace::Global);
-}
-
bool AA::isGPUSharedAddressSpace(const Module &M, unsigned AS) {
assert(AA::isGPU(M) && "Only callable on GPU targets");
Triple T(M.getTargetTriple());
More information about the llvm-commits
mailing list