[ObjCARC] Remove legacy PM versions of optimization passes

This doesn't touch objc-arc-contract because that's in the codegen pipeline.
However, this does move its corresponding initialize function into initializeCodegen().

Reviewed By: asbirlea

Differential Revision: https://reviews.llvm.org/D135041
This commit is contained in:
Arthur Eubanks 2022-10-02 13:20:21 -07:00
parent dc63ca78f7
commit 4153f989ba
19 changed files with 3 additions and 192 deletions

View File

@ -458,9 +458,6 @@ def register_library(library):
library.LLVMInitializeScalarOpts.argtypes = [PassRegistry]
library.LLVMInitializeScalarOpts.restype = None
library.LLVMInitializeObjCARCOpts.argtypes = [PassRegistry]
library.LLVMInitializeObjCARCOpts.restype = None
library.LLVMInitializeVectorization.argtypes = [PassRegistry]
library.LLVMInitializeVectorization.restype = None
@ -626,7 +623,6 @@ def initialize_llvm():
lib.LLVMInitializeCore(p)
lib.LLVMInitializeTransformUtils(p)
lib.LLVMInitializeScalarOpts(p)
lib.LLVMInitializeObjCARCOpts(p)
lib.LLVMInitializeVectorization(p)
lib.LLVMInitializeInstCombine(p)
lib.LLVMInitializeIPO(p)

View File

@ -33,7 +33,6 @@ LLVM_C_EXTERN_C_BEGIN
void LLVMInitializeCore(LLVMPassRegistryRef R);
void LLVMInitializeTransformUtils(LLVMPassRegistryRef R);
void LLVMInitializeScalarOpts(LLVMPassRegistryRef R);
void LLVMInitializeObjCARCOpts(LLVMPassRegistryRef R);
void LLVMInitializeVectorization(LLVMPassRegistryRef R);
void LLVMInitializeInstCombine(LLVMPassRegistryRef R);
void LLVMInitializeAggressiveInstCombiner(LLVMPassRegistryRef R);

View File

@ -74,23 +74,6 @@ public:
ObjCARCAAResult run(Function &F, FunctionAnalysisManager &AM);
};
/// Legacy wrapper pass to provide the ObjCARCAAResult object.
class ObjCARCAAWrapperPass : public ImmutablePass {
std::unique_ptr<ObjCARCAAResult> Result;
public:
static char ID;
ObjCARCAAWrapperPass();
ObjCARCAAResult &getResult() { return *Result; }
const ObjCARCAAResult &getResult() const { return *Result; }
bool doInitialization(Module &M) override;
bool doFinalization(Module &M) override;
void getAnalysisUsage(AnalysisUsage &AU) const override;
};
} // namespace objcarc
} // namespace llvm

View File

@ -19,13 +19,6 @@ namespace llvm {
class ImmutablePass;
class ModulePass;
//===--------------------------------------------------------------------===//
//
// createObjCARCAAWrapperPass - This pass implements ObjC-ARC-based
// alias analysis.
//
ImmutablePass *createObjCARCAAWrapperPass();
//===--------------------------------------------------------------------===//
//
/// createLazyValueInfoPass - This creates an instance of the LazyValueInfo

View File

@ -27,9 +27,6 @@ void initializeTransformUtils(PassRegistry&);
/// Initialize all passes linked into the ScalarOpts library.
void initializeScalarOpts(PassRegistry&);
/// Initialize all passes linked into the ObjCARCOpts library.
void initializeObjCARCOpts(PassRegistry&);
/// Initialize all passes linked into the Vectorize library.
void initializeVectorization(PassRegistry&);
@ -317,11 +314,7 @@ void initializeMustExecutePrinterPass(PassRegistry&);
void initializeMustBeExecutedContextPrinterPass(PassRegistry&);
void initializeNaryReassociateLegacyPassPass(PassRegistry&);
void initializeNewGVNLegacyPassPass(PassRegistry&);
void initializeObjCARCAAWrapperPassPass(PassRegistry&);
void initializeObjCARCAPElimPass(PassRegistry&);
void initializeObjCARCContractLegacyPassPass(PassRegistry &);
void initializeObjCARCExpandPass(PassRegistry&);
void initializeObjCARCOptLegacyPassPass(PassRegistry &);
void initializeOptimizationRemarkEmitterWrapperPassPass(PassRegistry&);
void initializeOptimizePHIsPass(PassRegistry&);
void initializePEIPass(PassRegistry&);

View File

@ -138,11 +138,7 @@ namespace {
(void) llvm::createLowerInvokePass();
(void) llvm::createLowerSwitchPass();
(void) llvm::createNaryReassociatePass();
(void) llvm::createObjCARCAAWrapperPass();
(void) llvm::createObjCARCAPElimPass();
(void) llvm::createObjCARCExpandPass();
(void) llvm::createObjCARCContractPass();
(void) llvm::createObjCARCOptPass();
(void) llvm::createPromoteMemoryToRegisterPass();
(void) llvm::createDemoteRegisterToMemoryPass();
(void)llvm::createPostDomOnlyPrinterWrapperPassPass();

View File

@ -815,7 +815,6 @@ INITIALIZE_PASS_DEPENDENCY(CFLAndersAAWrapperPass)
INITIALIZE_PASS_DEPENDENCY(CFLSteensAAWrapperPass)
INITIALIZE_PASS_DEPENDENCY(ExternalAAWrapperPass)
INITIALIZE_PASS_DEPENDENCY(GlobalsAAWrapperPass)
INITIALIZE_PASS_DEPENDENCY(ObjCARCAAWrapperPass)
INITIALIZE_PASS_DEPENDENCY(SCEVAAWrapperPass)
INITIALIZE_PASS_DEPENDENCY(ScopedNoAliasAAWrapperPass)
INITIALIZE_PASS_DEPENDENCY(TypeBasedAAWrapperPass)
@ -856,9 +855,6 @@ bool AAResultsWrapperPass::runOnFunction(Function &F) {
AAR->addAAResult(WrapperPass->getResult());
if (auto *WrapperPass = getAnalysisIfAvailable<TypeBasedAAWrapperPass>())
AAR->addAAResult(WrapperPass->getResult());
if (auto *WrapperPass =
getAnalysisIfAvailable<objcarc::ObjCARCAAWrapperPass>())
AAR->addAAResult(WrapperPass->getResult());
if (auto *WrapperPass = getAnalysisIfAvailable<GlobalsAAWrapperPass>())
AAR->addAAResult(WrapperPass->getResult());
if (auto *WrapperPass = getAnalysisIfAvailable<SCEVAAWrapperPass>())
@ -889,7 +885,6 @@ void AAResultsWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const {
// the legacy pass manager.
AU.addUsedIfAvailable<ScopedNoAliasAAWrapperPass>();
AU.addUsedIfAvailable<TypeBasedAAWrapperPass>();
AU.addUsedIfAvailable<objcarc::ObjCARCAAWrapperPass>();
AU.addUsedIfAvailable<GlobalsAAWrapperPass>();
AU.addUsedIfAvailable<SCEVAAWrapperPass>();
AU.addUsedIfAvailable<CFLAndersAAWrapperPass>();
@ -918,9 +913,6 @@ AAResults llvm::createLegacyPMAAResults(Pass &P, Function &F,
AAR.addAAResult(WrapperPass->getResult());
if (auto *WrapperPass = P.getAnalysisIfAvailable<TypeBasedAAWrapperPass>())
AAR.addAAResult(WrapperPass->getResult());
if (auto *WrapperPass =
P.getAnalysisIfAvailable<objcarc::ObjCARCAAWrapperPass>())
AAR.addAAResult(WrapperPass->getResult());
if (auto *WrapperPass = P.getAnalysisIfAvailable<GlobalsAAWrapperPass>())
AAR.addAAResult(WrapperPass->getResult());
if (auto *WrapperPass = P.getAnalysisIfAvailable<CFLAndersAAWrapperPass>())
@ -1014,7 +1006,6 @@ void llvm::getAAResultsAnalysisUsage(AnalysisUsage &AU) {
AU.addRequired<TargetLibraryInfoWrapperPass>();
AU.addUsedIfAvailable<ScopedNoAliasAAWrapperPass>();
AU.addUsedIfAvailable<TypeBasedAAWrapperPass>();
AU.addUsedIfAvailable<objcarc::ObjCARCAAWrapperPass>();
AU.addUsedIfAvailable<GlobalsAAWrapperPass>();
AU.addUsedIfAvailable<CFLAndersAAWrapperPass>();
AU.addUsedIfAvailable<CFLSteensAAWrapperPass>();

View File

@ -68,7 +68,6 @@ void llvm::initializeAnalysis(PassRegistry &Registry) {
initializeModuleSummaryIndexWrapperPassPass(Registry);
initializeMustExecutePrinterPass(Registry);
initializeMustBeExecutedContextPrinterPass(Registry);
initializeObjCARCAAWrapperPassPass(Registry);
initializeOptimizationRemarkEmitterWrapperPassPass(Registry);
initializePhiValuesWrapperPassPass(Registry);
initializePostDominatorTreeWrapperPassPass(Registry);

View File

@ -137,29 +137,3 @@ AnalysisKey ObjCARCAA::Key;
ObjCARCAAResult ObjCARCAA::run(Function &F, FunctionAnalysisManager &AM) {
return ObjCARCAAResult(F.getParent()->getDataLayout());
}
char ObjCARCAAWrapperPass::ID = 0;
INITIALIZE_PASS(ObjCARCAAWrapperPass, "objc-arc-aa",
"ObjC-ARC-Based Alias Analysis", false, true)
ImmutablePass *llvm::createObjCARCAAWrapperPass() {
return new ObjCARCAAWrapperPass();
}
ObjCARCAAWrapperPass::ObjCARCAAWrapperPass() : ImmutablePass(ID) {
initializeObjCARCAAWrapperPassPass(*PassRegistry::getPassRegistry());
}
bool ObjCARCAAWrapperPass::doInitialization(Module &M) {
Result.reset(new ObjCARCAAResult(M.getDataLayout()));
return false;
}
bool ObjCARCAAWrapperPass::doFinalization(Module &M) {
Result.reset();
return false;
}
void ObjCARCAAWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesAll();
}

View File

@ -255,6 +255,7 @@ add_llvm_component_library(LLVMCodeGen
BitWriter
Core
MC
ObjCARC
ProfileData
Scalar
Support

View File

@ -89,6 +89,7 @@ void llvm::initializeCodeGen(PassRegistry &Registry) {
initializeMachineSchedulerPass(Registry);
initializeMachineSinkingPass(Registry);
initializeMachineVerifierPassPass(Registry);
initializeObjCARCContractLegacyPassPass(Registry);
initializeOptimizePHIsPass(Registry);
initializePEIPass(Registry);
initializePHIEliminationPass(Registry);

View File

@ -13,34 +13,14 @@
//===----------------------------------------------------------------------===//
#include "ObjCARC.h"
#include "llvm-c/Initialization.h"
#include "llvm/Analysis/ObjCARCUtil.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Instructions.h"
#include "llvm/InitializePasses.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
namespace llvm {
class PassRegistry;
}
using namespace llvm;
using namespace llvm::objcarc;
/// initializeObjCARCOptsPasses - Initialize all passes linked into the
/// ObjCARCOpts library.
void llvm::initializeObjCARCOpts(PassRegistry &Registry) {
initializeObjCARCAAWrapperPassPass(Registry);
initializeObjCARCAPElimPass(Registry);
initializeObjCARCExpandPass(Registry);
initializeObjCARCContractLegacyPassPass(Registry);
initializeObjCARCOptLegacyPassPass(Registry);
}
void LLVMInitializeObjCARCOpts(LLVMPassRegistryRef R) {
initializeObjCARCOpts(*unwrap(R));
}
CallInst *objcarc::createCallInstWithColors(
FunctionCallee Func, ArrayRef<Value *> Args, const Twine &NameStr,
Instruction *InsertBefore,

View File

@ -29,8 +29,6 @@
#include "llvm/IR/Constants.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/PassManager.h"
#include "llvm/InitializePasses.h"
#include "llvm/Pass.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/ObjCARC.h"
@ -147,35 +145,8 @@ bool runImpl(Module &M) {
return Changed;
}
/// Autorelease pool elimination.
class ObjCARCAPElim : public ModulePass {
void getAnalysisUsage(AnalysisUsage &AU) const override;
bool runOnModule(Module &M) override;
public:
static char ID;
ObjCARCAPElim() : ModulePass(ID) {
initializeObjCARCAPElimPass(*PassRegistry::getPassRegistry());
}
};
} // namespace
char ObjCARCAPElim::ID = 0;
INITIALIZE_PASS(ObjCARCAPElim, "objc-arc-apelim",
"ObjC ARC autorelease pool elimination", false, false)
Pass *llvm::createObjCARCAPElimPass() { return new ObjCARCAPElim(); }
void ObjCARCAPElim::getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesCFG();
}
bool ObjCARCAPElim::runOnModule(Module &M) {
if (skipModule(M))
return false;
return runImpl(M);
}
PreservedAnalyses ObjCARCAPElimPass::run(Module &M, ModuleAnalysisManager &AM) {
if (!runImpl(M))
return PreservedAnalyses::all();

View File

@ -29,9 +29,6 @@
#include "llvm/IR/Instructions.h"
#include "llvm/IR/PassManager.h"
#include "llvm/IR/Value.h"
#include "llvm/InitializePasses.h"
#include "llvm/Pass.h"
#include "llvm/PassRegistry.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
@ -89,31 +86,8 @@ static bool runImpl(Function &F) {
return Changed;
}
/// Early ARC transformations.
class ObjCARCExpand : public FunctionPass {
void getAnalysisUsage(AnalysisUsage &AU) const override;
bool runOnFunction(Function &F) override;
public:
static char ID;
ObjCARCExpand() : FunctionPass(ID) {
initializeObjCARCExpandPass(*PassRegistry::getPassRegistry());
}
};
} // namespace
char ObjCARCExpand::ID = 0;
INITIALIZE_PASS(ObjCARCExpand, "objc-arc-expand", "ObjC ARC expansion", false,
false)
Pass *llvm::createObjCARCExpandPass() { return new ObjCARCExpand(); }
void ObjCARCExpand::getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesCFG();
}
bool ObjCARCExpand::runOnFunction(Function &F) { return runImpl(F); }
PreservedAnalyses ObjCARCExpandPass::run(Function &F,
FunctionAnalysisManager &AM) {
if (!runImpl(F))

View File

@ -58,8 +58,6 @@
#include "llvm/IR/Type.h"
#include "llvm/IR/User.h"
#include "llvm/IR/Value.h"
#include "llvm/InitializePasses.h"
#include "llvm/Pass.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
@ -579,44 +577,8 @@ class ObjCARCOpt {
void releaseMemory();
bool hasCFGChanged() const { return CFGChanged; }
};
/// The main ARC optimization pass.
class ObjCARCOptLegacyPass : public FunctionPass {
public:
ObjCARCOptLegacyPass() : FunctionPass(ID) {
initializeObjCARCOptLegacyPassPass(*PassRegistry::getPassRegistry());
}
void getAnalysisUsage(AnalysisUsage &AU) const override;
bool doInitialization(Module &M) override {
OCAO.init(M);
return false;
}
bool runOnFunction(Function &F) override {
return OCAO.run(F, getAnalysis<AAResultsWrapperPass>().getAAResults());
}
void releaseMemory() override { OCAO.releaseMemory(); }
static char ID;
private:
ObjCARCOpt OCAO;
};
} // end anonymous namespace
char ObjCARCOptLegacyPass::ID = 0;
INITIALIZE_PASS_BEGIN(ObjCARCOptLegacyPass, "objc-arc", "ObjC ARC optimization",
false, false)
INITIALIZE_PASS_DEPENDENCY(ObjCARCAAWrapperPass)
INITIALIZE_PASS_END(ObjCARCOptLegacyPass, "objc-arc", "ObjC ARC optimization",
false, false)
Pass *llvm::createObjCARCOptPass() { return new ObjCARCOptLegacyPass(); }
void ObjCARCOptLegacyPass::getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequired<ObjCARCAAWrapperPass>();
AU.addRequired<AAResultsWrapperPass>();
}
/// Turn objc_retainAutoreleasedReturnValue into objc_retain if the operand is
/// not a return value.
bool

View File

@ -143,7 +143,6 @@ int main(int argc, char **argv) {
PassRegistry &Registry = *PassRegistry::getPassRegistry();
initializeCore(Registry);
initializeScalarOpts(Registry);
initializeObjCARCOpts(Registry);
initializeVectorization(Registry);
initializeIPO(Registry);
initializeAnalysis(Registry);

View File

@ -192,7 +192,6 @@ extern "C" LLVM_ATTRIBUTE_USED int LLVMFuzzerInitialize(
PassRegistry &Registry = *PassRegistry::getPassRegistry();
initializeCore(Registry);
initializeScalarOpts(Registry);
initializeObjCARCOpts(Registry);
initializeVectorization(Registry);
initializeIPO(Registry);
initializeAnalysis(Registry);

View File

@ -494,7 +494,6 @@ int main(int argc, char **argv) {
PassRegistry &Registry = *PassRegistry::getPassRegistry();
initializeCore(Registry);
initializeScalarOpts(Registry);
initializeObjCARCOpts(Registry);
initializeVectorization(Registry);
initializeIPO(Registry);
initializeAnalysis(Registry);

View File

@ -13,6 +13,7 @@ static_library("CodeGen") {
"//llvm/lib/ProfileData",
"//llvm/lib/Support",
"//llvm/lib/Target",
"//llvm/lib/Transforms/ObjCARC",
"//llvm/lib/Transforms/Scalar",
"//llvm/lib/Transforms/Utils",
]