[llvm] [LegacyPM] Remove unused getAdjustedAnalysisPointer() method (NFC) (PR #145738)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 25 09:42:25 PDT 2025
https://github.com/nikic created https://github.com/llvm/llvm-project/pull/145738
This never actually gets overridden and always returns this, so drop it.
Noticed this looking into why the pass vtables are so huge.
>From 32f41296a2173f02624ab0d2eb92fe60b9cfa500 Mon Sep 17 00:00:00 2001
From: Nikita Popov <npopov at redhat.com>
Date: Wed, 25 Jun 2025 18:35:12 +0200
Subject: [PATCH] [LegacyPM] Remove unused getAdjustedAnalysisPointer() method
This never actually gets overridden, so drop it.
---
llvm/docs/AliasAnalysis.rst | 14 --------------
llvm/include/llvm/Pass.h | 5 -----
llvm/include/llvm/PassAnalysisSupport.h | 24 +++---------------------
llvm/lib/IR/Pass.cpp | 4 ----
4 files changed, 3 insertions(+), 44 deletions(-)
diff --git a/llvm/docs/AliasAnalysis.rst b/llvm/docs/AliasAnalysis.rst
index 7afe0e277bd4f..1830cca915049 100644
--- a/llvm/docs/AliasAnalysis.rst
+++ b/llvm/docs/AliasAnalysis.rst
@@ -256,20 +256,6 @@ analysis run method (``run`` for a ``Pass``, ``runOnFunction`` for a
return false;
}
-Required methods to override
-----------------------------
-
-You must override the ``getAdjustedAnalysisPointer`` method on all subclasses
-of ``AliasAnalysis``. An example implementation of this method would look like:
-
-.. code-block:: c++
-
- void *getAdjustedAnalysisPointer(const void* ID) override {
- if (ID == &AliasAnalysis::ID)
- return (AliasAnalysis*)this;
- return this;
- }
-
Interfaces which may be specified
---------------------------------
diff --git a/llvm/include/llvm/Pass.h b/llvm/include/llvm/Pass.h
index 58c45e75b3f0a..34f4f7f804a38 100644
--- a/llvm/include/llvm/Pass.h
+++ b/llvm/include/llvm/Pass.h
@@ -175,11 +175,6 @@ class LLVM_ABI Pass {
/// longer used.
virtual void releaseMemory();
- /// getAdjustedAnalysisPointer - This method is used when a pass implements
- /// an analysis interface through multiple inheritance. If needed, it should
- /// override this to adjust the this pointer as needed for the specified pass
- /// info.
- virtual void *getAdjustedAnalysisPointer(AnalysisID ID);
virtual ImmutablePass *getAsImmutablePass();
virtual PMDataManager *getAsPMDataManager();
diff --git a/llvm/include/llvm/PassAnalysisSupport.h b/llvm/include/llvm/PassAnalysisSupport.h
index 02abb00b66b52..bf3a9c90d94bf 100644
--- a/llvm/include/llvm/PassAnalysisSupport.h
+++ b/llvm/include/llvm/PassAnalysisSupport.h
@@ -214,15 +214,7 @@ AnalysisType *Pass::getAnalysisIfAvailable() const {
assert(Resolver && "Pass not resident in a PassManager object!");
const void *PI = &AnalysisType::ID;
-
- Pass *ResultPass = Resolver->getAnalysisIfAvailable(PI);
- if (!ResultPass) return nullptr;
-
- // Because the AnalysisType may not be a subclass of pass (for
- // AnalysisGroups), we use getAdjustedAnalysisPointer here to potentially
- // adjust the return pointer (because the class may multiply inherit, once
- // from pass, once from AnalysisType).
- return (AnalysisType*)ResultPass->getAdjustedAnalysisPointer(PI);
+ return (AnalysisType *)Resolver->getAnalysisIfAvailable(PI);
}
/// getAnalysis<AnalysisType>() - This function is used by subclasses to get
@@ -245,12 +237,7 @@ AnalysisType &Pass::getAnalysisID(AnalysisID PI) const {
assert(ResultPass &&
"getAnalysis*() called on an analysis that was not "
"'required' by pass!");
-
- // Because the AnalysisType may not be a subclass of pass (for
- // AnalysisGroups), we use getAdjustedAnalysisPointer here to potentially
- // adjust the return pointer (because the class may multiply inherit, once
- // from pass, once from AnalysisType).
- return *(AnalysisType*)ResultPass->getAdjustedAnalysisPointer(PI);
+ return *(AnalysisType *)ResultPass;
}
/// getAnalysis<AnalysisType>() - This function is used by subclasses to get
@@ -282,12 +269,7 @@ AnalysisType &Pass::getAnalysisID(AnalysisID PI, Function &F, bool *Changed) {
else
assert(!LocalChanged &&
"A pass trigged a code update but the update status is lost");
-
- // Because the AnalysisType may not be a subclass of pass (for
- // AnalysisGroups), we use getAdjustedAnalysisPointer here to potentially
- // adjust the return pointer (because the class may multiply inherit, once
- // from pass, once from AnalysisType).
- return *(AnalysisType*)ResultPass->getAdjustedAnalysisPointer(PI);
+ return *(AnalysisType *) ResultPass;
}
} // end namespace llvm
diff --git a/llvm/lib/IR/Pass.cpp b/llvm/lib/IR/Pass.cpp
index b1b33a517f0ff..f3ae2e6314429 100644
--- a/llvm/lib/IR/Pass.cpp
+++ b/llvm/lib/IR/Pass.cpp
@@ -107,10 +107,6 @@ void Pass::verifyAnalysis() const {
// By default, don't do anything.
}
-void *Pass::getAdjustedAnalysisPointer(AnalysisID AID) {
- return this;
-}
-
ImmutablePass *Pass::getAsImmutablePass() {
return nullptr;
}
More information about the llvm-commits
mailing list