diff --git a/llvm/bindings/python/llvm/core.py b/llvm/bindings/python/llvm/core.py index 4d90f8652de1..a9ec107faab7 100644 --- a/llvm/bindings/python/llvm/core.py +++ b/llvm/bindings/python/llvm/core.py @@ -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) diff --git a/llvm/include/llvm-c/Initialization.h b/llvm/include/llvm-c/Initialization.h index 0d59de8728c8..2f3f0f890d78 100644 --- a/llvm/include/llvm-c/Initialization.h +++ b/llvm/include/llvm-c/Initialization.h @@ -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); diff --git a/llvm/include/llvm/Analysis/ObjCARCAliasAnalysis.h b/llvm/include/llvm/Analysis/ObjCARCAliasAnalysis.h index f99fce707b93..ba8b28a5adda 100644 --- a/llvm/include/llvm/Analysis/ObjCARCAliasAnalysis.h +++ b/llvm/include/llvm/Analysis/ObjCARCAliasAnalysis.h @@ -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 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 diff --git a/llvm/include/llvm/Analysis/Passes.h b/llvm/include/llvm/Analysis/Passes.h index 612aca2501f7..343c239dede6 100644 --- a/llvm/include/llvm/Analysis/Passes.h +++ b/llvm/include/llvm/Analysis/Passes.h @@ -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 diff --git a/llvm/include/llvm/InitializePasses.h b/llvm/include/llvm/InitializePasses.h index 3dd8195b8319..fa5a432750dd 100644 --- a/llvm/include/llvm/InitializePasses.h +++ b/llvm/include/llvm/InitializePasses.h @@ -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&); diff --git a/llvm/include/llvm/LinkAllPasses.h b/llvm/include/llvm/LinkAllPasses.h index 7a11a8f98642..a2cf1f06e88e 100644 --- a/llvm/include/llvm/LinkAllPasses.h +++ b/llvm/include/llvm/LinkAllPasses.h @@ -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(); diff --git a/llvm/lib/Analysis/AliasAnalysis.cpp b/llvm/lib/Analysis/AliasAnalysis.cpp index 09d33cfe1475..e686ff75a302 100644 --- a/llvm/lib/Analysis/AliasAnalysis.cpp +++ b/llvm/lib/Analysis/AliasAnalysis.cpp @@ -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()) AAR->addAAResult(WrapperPass->getResult()); - if (auto *WrapperPass = - getAnalysisIfAvailable()) - AAR->addAAResult(WrapperPass->getResult()); if (auto *WrapperPass = getAnalysisIfAvailable()) AAR->addAAResult(WrapperPass->getResult()); if (auto *WrapperPass = getAnalysisIfAvailable()) @@ -889,7 +885,6 @@ void AAResultsWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const { // the legacy pass manager. AU.addUsedIfAvailable(); AU.addUsedIfAvailable(); - AU.addUsedIfAvailable(); AU.addUsedIfAvailable(); AU.addUsedIfAvailable(); AU.addUsedIfAvailable(); @@ -918,9 +913,6 @@ AAResults llvm::createLegacyPMAAResults(Pass &P, Function &F, AAR.addAAResult(WrapperPass->getResult()); if (auto *WrapperPass = P.getAnalysisIfAvailable()) AAR.addAAResult(WrapperPass->getResult()); - if (auto *WrapperPass = - P.getAnalysisIfAvailable()) - AAR.addAAResult(WrapperPass->getResult()); if (auto *WrapperPass = P.getAnalysisIfAvailable()) AAR.addAAResult(WrapperPass->getResult()); if (auto *WrapperPass = P.getAnalysisIfAvailable()) @@ -1014,7 +1006,6 @@ void llvm::getAAResultsAnalysisUsage(AnalysisUsage &AU) { AU.addRequired(); AU.addUsedIfAvailable(); AU.addUsedIfAvailable(); - AU.addUsedIfAvailable(); AU.addUsedIfAvailable(); AU.addUsedIfAvailable(); AU.addUsedIfAvailable(); diff --git a/llvm/lib/Analysis/Analysis.cpp b/llvm/lib/Analysis/Analysis.cpp index 460dddceaf17..e7257052f6ba 100644 --- a/llvm/lib/Analysis/Analysis.cpp +++ b/llvm/lib/Analysis/Analysis.cpp @@ -68,7 +68,6 @@ void llvm::initializeAnalysis(PassRegistry &Registry) { initializeModuleSummaryIndexWrapperPassPass(Registry); initializeMustExecutePrinterPass(Registry); initializeMustBeExecutedContextPrinterPass(Registry); - initializeObjCARCAAWrapperPassPass(Registry); initializeOptimizationRemarkEmitterWrapperPassPass(Registry); initializePhiValuesWrapperPassPass(Registry); initializePostDominatorTreeWrapperPassPass(Registry); diff --git a/llvm/lib/Analysis/ObjCARCAliasAnalysis.cpp b/llvm/lib/Analysis/ObjCARCAliasAnalysis.cpp index b839dbbb0348..76f6a74384b4 100644 --- a/llvm/lib/Analysis/ObjCARCAliasAnalysis.cpp +++ b/llvm/lib/Analysis/ObjCARCAliasAnalysis.cpp @@ -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(); -} diff --git a/llvm/lib/CodeGen/CMakeLists.txt b/llvm/lib/CodeGen/CMakeLists.txt index ce14e1d9d545..ed83333bade5 100644 --- a/llvm/lib/CodeGen/CMakeLists.txt +++ b/llvm/lib/CodeGen/CMakeLists.txt @@ -255,6 +255,7 @@ add_llvm_component_library(LLVMCodeGen BitWriter Core MC + ObjCARC ProfileData Scalar Support diff --git a/llvm/lib/CodeGen/CodeGen.cpp b/llvm/lib/CodeGen/CodeGen.cpp index 87090ec36993..5d30e82f49db 100644 --- a/llvm/lib/CodeGen/CodeGen.cpp +++ b/llvm/lib/CodeGen/CodeGen.cpp @@ -89,6 +89,7 @@ void llvm::initializeCodeGen(PassRegistry &Registry) { initializeMachineSchedulerPass(Registry); initializeMachineSinkingPass(Registry); initializeMachineVerifierPassPass(Registry); + initializeObjCARCContractLegacyPassPass(Registry); initializeOptimizePHIsPass(Registry); initializePEIPass(Registry); initializePHIEliminationPass(Registry); diff --git a/llvm/lib/Transforms/ObjCARC/ObjCARC.cpp b/llvm/lib/Transforms/ObjCARC/ObjCARC.cpp index 3c2058e566ff..02f9db719e26 100644 --- a/llvm/lib/Transforms/ObjCARC/ObjCARC.cpp +++ b/llvm/lib/Transforms/ObjCARC/ObjCARC.cpp @@ -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 Args, const Twine &NameStr, Instruction *InsertBefore, diff --git a/llvm/lib/Transforms/ObjCARC/ObjCARCAPElim.cpp b/llvm/lib/Transforms/ObjCARC/ObjCARCAPElim.cpp index 03e5fb18d5ac..dceb2ebb1863 100644 --- a/llvm/lib/Transforms/ObjCARC/ObjCARCAPElim.cpp +++ b/llvm/lib/Transforms/ObjCARC/ObjCARCAPElim.cpp @@ -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(); diff --git a/llvm/lib/Transforms/ObjCARC/ObjCARCExpand.cpp b/llvm/lib/Transforms/ObjCARC/ObjCARCExpand.cpp index efcdc51ef5e3..bb0a01b78a96 100644 --- a/llvm/lib/Transforms/ObjCARC/ObjCARCExpand.cpp +++ b/llvm/lib/Transforms/ObjCARC/ObjCARCExpand.cpp @@ -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)) diff --git a/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp b/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp index 5044d47fd37c..4957af3a94bc 100644 --- a/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp +++ b/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp @@ -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().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(); - AU.addRequired(); -} - /// Turn objc_retainAutoreleasedReturnValue into objc_retain if the operand is /// not a return value. bool diff --git a/llvm/tools/bugpoint/bugpoint.cpp b/llvm/tools/bugpoint/bugpoint.cpp index 4dece12f75ef..1701b16bd015 100644 --- a/llvm/tools/bugpoint/bugpoint.cpp +++ b/llvm/tools/bugpoint/bugpoint.cpp @@ -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); diff --git a/llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp b/llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp index 74b898bdbdfb..8657d894b00c 100644 --- a/llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp +++ b/llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp @@ -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); diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp index a056b8dbe23c..62bdd6e09501 100644 --- a/llvm/tools/opt/opt.cpp +++ b/llvm/tools/opt/opt.cpp @@ -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); diff --git a/llvm/utils/gn/secondary/llvm/lib/CodeGen/BUILD.gn b/llvm/utils/gn/secondary/llvm/lib/CodeGen/BUILD.gn index e312631385de..d0ac3a2d7f28 100644 --- a/llvm/utils/gn/secondary/llvm/lib/CodeGen/BUILD.gn +++ b/llvm/utils/gn/secondary/llvm/lib/CodeGen/BUILD.gn @@ -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", ]