[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.
This commit is contained in:
Nikita Popov
2025-06-26 09:04:07 +02:00
committed by GitHub
parent 9ccf613b34
commit 5fb0ae1a5b
4 changed files with 3 additions and 44 deletions

View File

@@ -256,20 +256,6 @@ analysis run method (``run`` for a ``Pass``, ``runOnFunction`` for a
return false; 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 Interfaces which may be specified
--------------------------------- ---------------------------------

View File

@@ -175,11 +175,6 @@ public:
/// longer used. /// longer used.
virtual void releaseMemory(); 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 ImmutablePass *getAsImmutablePass();
virtual PMDataManager *getAsPMDataManager(); virtual PMDataManager *getAsPMDataManager();

View File

@@ -214,15 +214,7 @@ AnalysisType *Pass::getAnalysisIfAvailable() const {
assert(Resolver && "Pass not resident in a PassManager object!"); assert(Resolver && "Pass not resident in a PassManager object!");
const void *PI = &AnalysisType::ID; const void *PI = &AnalysisType::ID;
return (AnalysisType *)Resolver->getAnalysisIfAvailable(PI);
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);
} }
/// getAnalysis<AnalysisType>() - This function is used by subclasses to get /// getAnalysis<AnalysisType>() - This function is used by subclasses to get
@@ -245,12 +237,7 @@ AnalysisType &Pass::getAnalysisID(AnalysisID PI) const {
assert(ResultPass && assert(ResultPass &&
"getAnalysis*() called on an analysis that was not " "getAnalysis*() called on an analysis that was not "
"'required' by pass!"); "'required' by pass!");
return *(AnalysisType *)ResultPass;
// 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);
} }
/// getAnalysis<AnalysisType>() - This function is used by subclasses to get /// getAnalysis<AnalysisType>() - This function is used by subclasses to get
@@ -282,12 +269,7 @@ AnalysisType &Pass::getAnalysisID(AnalysisID PI, Function &F, bool *Changed) {
else else
assert(!LocalChanged && assert(!LocalChanged &&
"A pass trigged a code update but the update status is lost"); "A pass trigged a code update but the update status is lost");
return *(AnalysisType *)ResultPass;
// 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);
} }
} // end namespace llvm } // end namespace llvm

View File

@@ -107,10 +107,6 @@ void Pass::verifyAnalysis() const {
// By default, don't do anything. // By default, don't do anything.
} }
void *Pass::getAdjustedAnalysisPointer(AnalysisID AID) {
return this;
}
ImmutablePass *Pass::getAsImmutablePass() { ImmutablePass *Pass::getAsImmutablePass() {
return nullptr; return nullptr;
} }