[llvm] aecb36c - [GlobalOpt] Remove legacy pass
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 14 13:01:09 PST 2023
Author: Arthur Eubanks
Date: 2023-02-14T12:51:45-08:00
New Revision: aecb36c8489a09bcc3deefd7936b9ba18a5eb322
URL: https://github.com/llvm/llvm-project/commit/aecb36c8489a09bcc3deefd7936b9ba18a5eb322
DIFF: https://github.com/llvm/llvm-project/commit/aecb36c8489a09bcc3deefd7936b9ba18a5eb322.diff
LOG: [GlobalOpt] Remove legacy pass
This is part of the optimization pipeline, of which the legacy pass manager version is deprecated.
Added:
Modified:
llvm/bindings/ocaml/transforms/ipo/ipo_ocaml.c
llvm/bindings/ocaml/transforms/ipo/llvm_ipo.ml
llvm/bindings/ocaml/transforms/ipo/llvm_ipo.mli
llvm/include/llvm-c/Transforms/IPO.h
llvm/include/llvm/LinkAllPasses.h
llvm/include/llvm/Transforms/IPO.h
llvm/lib/Transforms/IPO/GlobalOpt.cpp
llvm/lib/Transforms/IPO/IPO.cpp
llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
llvm/test/Bindings/OCaml/ipo.ml
Removed:
################################################################################
diff --git a/llvm/bindings/ocaml/transforms/ipo/ipo_ocaml.c b/llvm/bindings/ocaml/transforms/ipo/ipo_ocaml.c
index 8e263cb71b2b6..09450dc1a8ca2 100644
--- a/llvm/bindings/ocaml/transforms/ipo/ipo_ocaml.c
+++ b/llvm/bindings/ocaml/transforms/ipo/ipo_ocaml.c
@@ -49,12 +49,6 @@ value llvm_add_global_dce(LLVMPassManagerRef PM) {
return Val_unit;
}
-/* [`Module] Llvm.PassManager.t -> unit */
-value llvm_add_global_optimizer(LLVMPassManagerRef PM) {
- LLVMAddGlobalOptimizerPass(PM);
- return Val_unit;
-}
-
/* [`Module] Llvm.PassManager.t -> unit */
value llvm_add_ipsccp(LLVMPassManagerRef PM) {
LLVMAddIPSCCPPass(PM);
diff --git a/llvm/bindings/ocaml/transforms/ipo/llvm_ipo.ml b/llvm/bindings/ocaml/transforms/ipo/llvm_ipo.ml
index d1ebd56bb05b4..3d7464956d011 100644
--- a/llvm/bindings/ocaml/transforms/ipo/llvm_ipo.ml
+++ b/llvm/bindings/ocaml/transforms/ipo/llvm_ipo.ml
@@ -21,9 +21,6 @@ external add_always_inliner
external add_global_dce
: [ `Module ] Llvm.PassManager.t -> unit
= "llvm_add_global_dce"
-external add_global_optimizer
- : [ `Module ] Llvm.PassManager.t -> unit
- = "llvm_add_global_optimizer"
external add_ipsccp
: [ `Module ] Llvm.PassManager.t -> unit
= "llvm_add_ipsccp"
diff --git a/llvm/bindings/ocaml/transforms/ipo/llvm_ipo.mli b/llvm/bindings/ocaml/transforms/ipo/llvm_ipo.mli
index 68c772e1c0f2c..03f3a183b95e6 100644
--- a/llvm/bindings/ocaml/transforms/ipo/llvm_ipo.mli
+++ b/llvm/bindings/ocaml/transforms/ipo/llvm_ipo.mli
@@ -36,11 +36,6 @@ external add_global_dce
: [ `Module ] Llvm.PassManager.t -> unit
= "llvm_add_global_dce"
-(** See the [llvm::createGlobalOptimizerPass] function. *)
-external add_global_optimizer
- : [ `Module ] Llvm.PassManager.t -> unit
- = "llvm_add_global_optimizer"
-
(** See the [llvm::createIPSCCPPass] function. *)
external add_ipsccp
: [ `Module ] Llvm.PassManager.t -> unit
diff --git a/llvm/include/llvm-c/Transforms/IPO.h b/llvm/include/llvm-c/Transforms/IPO.h
index f4da3f509fdc3..f6fd7882ea65f 100644
--- a/llvm/include/llvm-c/Transforms/IPO.h
+++ b/llvm/include/llvm-c/Transforms/IPO.h
@@ -42,9 +42,6 @@ void LLVMAddAlwaysInlinerPass(LLVMPassManagerRef PM);
/** See llvm::createGlobalDCEPass function. */
void LLVMAddGlobalDCEPass(LLVMPassManagerRef PM);
-/** See llvm::createGlobalOptimizerPass function. */
-void LLVMAddGlobalOptimizerPass(LLVMPassManagerRef PM);
-
/** See llvm::createIPSCCPPass function. */
void LLVMAddIPSCCPPass(LLVMPassManagerRef PM);
diff --git a/llvm/include/llvm/LinkAllPasses.h b/llvm/include/llvm/LinkAllPasses.h
index 0f591b0be0d2f..9e3ac6fd821b5 100644
--- a/llvm/include/llvm/LinkAllPasses.h
+++ b/llvm/include/llvm/LinkAllPasses.h
@@ -94,7 +94,6 @@ namespace {
(void) llvm::createDomViewerWrapperPassPass();
(void) llvm::createAlwaysInlinerLegacyPass();
(void) llvm::createGlobalDCEPass();
- (void) llvm::createGlobalOptimizerPass();
(void) llvm::createGlobalsAAWrapperPass();
(void) llvm::createGuardWideningPass();
(void) llvm::createLoopGuardWideningPass();
diff --git a/llvm/include/llvm/Transforms/IPO.h b/llvm/include/llvm/Transforms/IPO.h
index bd68454c2a820..297e69542064e 100644
--- a/llvm/include/llvm/Transforms/IPO.h
+++ b/llvm/include/llvm/Transforms/IPO.h
@@ -43,12 +43,6 @@ ModulePass *createAnnotation2MetadataLegacyPass();
///
ModulePass *createConstantMergePass();
-//===----------------------------------------------------------------------===//
-/// createGlobalOptimizerPass - This function returns a new pass that optimizes
-/// non-address taken internal globals.
-///
-ModulePass *createGlobalOptimizerPass();
-
//===----------------------------------------------------------------------===//
/// createGlobalDCEPass - This transform is designed to eliminate unreachable
/// internal globals (functions or global variables)
diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
index 040701e243ce5..6f35da193926f 100644
--- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
@@ -2562,65 +2562,3 @@ PreservedAnalyses GlobalOptPass::run(Module &M, ModuleAnalysisManager &AM) {
PA.preserveSet<CFGAnalyses>();
return PA;
}
-
-namespace {
-
-struct GlobalOptLegacyPass : public ModulePass {
- static char ID; // Pass identification, replacement for typeid
-
- GlobalOptLegacyPass() : ModulePass(ID) {
- initializeGlobalOptLegacyPassPass(*PassRegistry::getPassRegistry());
- }
-
- bool runOnModule(Module &M) override {
- if (skipModule(M))
- return false;
-
- auto &DL = M.getDataLayout();
- auto LookupDomTree = [this](Function &F) -> DominatorTree & {
- return this->getAnalysis<DominatorTreeWrapperPass>(F).getDomTree();
- };
- auto GetTLI = [this](Function &F) -> TargetLibraryInfo & {
- return this->getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(F);
- };
- auto GetTTI = [this](Function &F) -> TargetTransformInfo & {
- return this->getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F);
- };
-
- auto GetBFI = [this](Function &F) -> BlockFrequencyInfo & {
- return this->getAnalysis<BlockFrequencyInfoWrapperPass>(F).getBFI();
- };
-
- auto ChangedCFGCallback = [&LookupDomTree](Function &F) {
- auto &DT = LookupDomTree(F);
- DT.recalculate(F);
- };
-
- return optimizeGlobalsInModule(M, DL, GetTLI, GetTTI, GetBFI, LookupDomTree,
- ChangedCFGCallback, nullptr);
- }
-
- void getAnalysisUsage(AnalysisUsage &AU) const override {
- AU.addRequired<TargetLibraryInfoWrapperPass>();
- AU.addRequired<TargetTransformInfoWrapperPass>();
- AU.addRequired<DominatorTreeWrapperPass>();
- AU.addRequired<BlockFrequencyInfoWrapperPass>();
- }
-};
-
-} // end anonymous namespace
-
-char GlobalOptLegacyPass::ID = 0;
-
-INITIALIZE_PASS_BEGIN(GlobalOptLegacyPass, "globalopt",
- "Global Variable Optimizer", false, false)
-INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass)
-INITIALIZE_PASS_DEPENDENCY(TargetTransformInfoWrapperPass)
-INITIALIZE_PASS_DEPENDENCY(BlockFrequencyInfoWrapperPass)
-INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
-INITIALIZE_PASS_END(GlobalOptLegacyPass, "globalopt",
- "Global Variable Optimizer", false, false)
-
-ModulePass *llvm::createGlobalOptimizerPass() {
- return new GlobalOptLegacyPass();
-}
diff --git a/llvm/lib/Transforms/IPO/IPO.cpp b/llvm/lib/Transforms/IPO/IPO.cpp
index 8af02f811831d..7d95c761d3d50 100644
--- a/llvm/lib/Transforms/IPO/IPO.cpp
+++ b/llvm/lib/Transforms/IPO/IPO.cpp
@@ -29,7 +29,6 @@ void llvm::initializeIPO(PassRegistry &Registry) {
initializeDAHPass(Registry);
initializeForceFunctionAttrsLegacyPassPass(Registry);
initializeGlobalDCELegacyPassPass(Registry);
- initializeGlobalOptLegacyPassPass(Registry);
initializeAlwaysInlinerLegacyPassPass(Registry);
initializeInferFunctionAttrsLegacyPassPass(Registry);
initializeLoopExtractorLegacyPassPass(Registry);
@@ -66,10 +65,6 @@ void LLVMAddGlobalDCEPass(LLVMPassManagerRef PM) {
unwrap(PM)->add(createGlobalDCEPass());
}
-void LLVMAddGlobalOptimizerPass(LLVMPassManagerRef PM) {
- unwrap(PM)->add(createGlobalOptimizerPass());
-}
-
void LLVMAddIPSCCPPass(LLVMPassManagerRef PM) {
unwrap(PM)->add(createIPSCCPPass());
}
diff --git a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
index 93465a3509267..ce0792631ff12 100644
--- a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
+++ b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
@@ -312,7 +312,6 @@ void PassManagerBuilder::populateModulePassManager(
MPM.add(createIPSCCPPass()); // IP SCCP
- MPM.add(createGlobalOptimizerPass()); // Optimize out global vars
// Promote any localized global vars.
MPM.add(createPromoteMemoryToRegisterPass());
@@ -364,7 +363,6 @@ void PassManagerBuilder::populateModulePassManager(
// benefits generally outweight the cost, making the whole pipeline
// faster.
if (RunInliner) {
- MPM.add(createGlobalOptimizerPass());
MPM.add(createGlobalDCEPass());
}
diff --git a/llvm/test/Bindings/OCaml/ipo.ml b/llvm/test/Bindings/OCaml/ipo.ml
index 6bea990cae98b..124a9734ce235 100644
--- a/llvm/test/Bindings/OCaml/ipo.ml
+++ b/llvm/test/Bindings/OCaml/ipo.ml
@@ -52,7 +52,6 @@ let test_transforms () =
++ add_function_attrs
++ add_always_inliner
++ add_global_dce
- ++ add_global_optimizer
++ add_ipsccp
++ PassManager.run_module m
++ PassManager.dispose)
More information about the llvm-commits
mailing list