From 5fb0ae1a5b5849cddeaf2f3e3fe64f45282d74d4 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 26 Jun 2025 09:04:07 +0200 Subject: [PATCH] [LegacyPM] Remove unused getAdjustedAnalysisPointer() method (NFC) (#145738) This never actually gets overridden and always returns this, so drop it. Noticed this looking into why the pass vtables are so huge. --- 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 7afe0e277bd4..1830cca91504 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 58c45e75b3f0..34f4f7f804a3 100644 --- a/llvm/include/llvm/Pass.h +++ b/llvm/include/llvm/Pass.h @@ -175,11 +175,6 @@ public: /// 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 02abb00b66b5..e81c0c4642d2 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() - 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() - 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 b1b33a517f0f..f3ae2e631442 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; }