[polly] d7c4590 - [LoopIdiomRecognize] Remove legacy pass
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 19 21:39:52 PST 2023
Author: Fangrui Song
Date: 2023-02-19T21:39:47-08:00
New Revision: d7c459070cf3382f30abaf0b258223f7c254a06c
URL: https://github.com/llvm/llvm-project/commit/d7c459070cf3382f30abaf0b258223f7c254a06c
DIFF: https://github.com/llvm/llvm-project/commit/d7c459070cf3382f30abaf0b258223f7c254a06c.diff
LOG: [LoopIdiomRecognize] Remove legacy pass
Following recent changes to remove non-core legacy passes.
Added:
Modified:
llvm/bindings/ocaml/transforms/scalar_opts/llvm_scalar_opts.ml
llvm/bindings/ocaml/transforms/scalar_opts/llvm_scalar_opts.mli
llvm/bindings/ocaml/transforms/scalar_opts/scalar_opts_ocaml.c
llvm/include/llvm-c/Transforms/Scalar.h
llvm/include/llvm/InitializePasses.h
llvm/include/llvm/LinkAllPasses.h
llvm/include/llvm/Transforms/Scalar.h
llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
llvm/lib/Transforms/Scalar/Scalar.cpp
llvm/test/Bindings/OCaml/scalar_opts.ml
polly/lib/CodeGen/CodegenCleanup.cpp
Removed:
################################################################################
diff --git a/llvm/bindings/ocaml/transforms/scalar_opts/llvm_scalar_opts.ml b/llvm/bindings/ocaml/transforms/scalar_opts/llvm_scalar_opts.ml
index 30f4f8f6bf24c..cf212b90f717b 100644
--- a/llvm/bindings/ocaml/transforms/scalar_opts/llvm_scalar_opts.ml
+++ b/llvm/bindings/ocaml/transforms/scalar_opts/llvm_scalar_opts.ml
@@ -42,9 +42,6 @@ external add_jump_threading
external add_licm
: [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit
= "llvm_add_licm"
-external add_loop_idiom
- : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit
- = "llvm_add_loop_idiom"
external add_loop_rotation
: [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit
= "llvm_add_loop_rotate"
diff --git a/llvm/bindings/ocaml/transforms/scalar_opts/llvm_scalar_opts.mli b/llvm/bindings/ocaml/transforms/scalar_opts/llvm_scalar_opts.mli
index 7ac557d204c18..57069c19133fc 100644
--- a/llvm/bindings/ocaml/transforms/scalar_opts/llvm_scalar_opts.mli
+++ b/llvm/bindings/ocaml/transforms/scalar_opts/llvm_scalar_opts.mli
@@ -71,11 +71,6 @@ external add_licm
: [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit
= "llvm_add_licm"
-(** See the [llvm::createLoopIdiomPass] function. *)
-external add_loop_idiom
- : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit
- = "llvm_add_loop_idiom"
-
(** See the [llvm::createLoopRotatePass] function. *)
external add_loop_rotation
: [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit
diff --git a/llvm/bindings/ocaml/transforms/scalar_opts/scalar_opts_ocaml.c b/llvm/bindings/ocaml/transforms/scalar_opts/scalar_opts_ocaml.c
index 12e0f88eae052..304e87a3f2f60 100644
--- a/llvm/bindings/ocaml/transforms/scalar_opts/scalar_opts_ocaml.c
+++ b/llvm/bindings/ocaml/transforms/scalar_opts/scalar_opts_ocaml.c
@@ -91,12 +91,6 @@ value llvm_add_licm(LLVMPassManagerRef PM) {
return Val_unit;
}
-/* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
-value llvm_add_loop_idiom(LLVMPassManagerRef PM) {
- LLVMAddLoopIdiomPass(PM);
- return Val_unit;
-}
-
/* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
value llvm_add_loop_rotate(LLVMPassManagerRef PM) {
LLVMAddLoopRotatePass(PM);
diff --git a/llvm/include/llvm-c/Transforms/Scalar.h b/llvm/include/llvm-c/Transforms/Scalar.h
index 5aaeb9470168f..020af80763d48 100644
--- a/llvm/include/llvm-c/Transforms/Scalar.h
+++ b/llvm/include/llvm-c/Transforms/Scalar.h
@@ -76,9 +76,6 @@ void LLVMAddJumpThreadingPass(LLVMPassManagerRef PM);
/** See llvm::createLICMPass function. */
void LLVMAddLICMPass(LLVMPassManagerRef PM);
-/** See llvm::createLoopIdiomPass function */
-void LLVMAddLoopIdiomPass(LLVMPassManagerRef PM);
-
/** See llvm::createLoopRotatePass function. */
void LLVMAddLoopRotatePass(LLVMPassManagerRef PM);
diff --git a/llvm/include/llvm/InitializePasses.h b/llvm/include/llvm/InitializePasses.h
index 01df2e063e7f0..2924b02774bd6 100644
--- a/llvm/include/llvm/InitializePasses.h
+++ b/llvm/include/llvm/InitializePasses.h
@@ -209,7 +209,6 @@ void initializeLoopAccessLegacyAnalysisPass(PassRegistry&);
void initializeLoopDataPrefetchLegacyPassPass(PassRegistry&);
void initializeLoopExtractorLegacyPassPass(PassRegistry &);
void initializeLoopGuardWideningLegacyPassPass(PassRegistry&);
-void initializeLoopIdiomRecognizeLegacyPassPass(PassRegistry&);
void initializeLoopInfoWrapperPassPass(PassRegistry&);
void initializeLoopInstSimplifyLegacyPassPass(PassRegistry&);
void initializeLoopPassPass(PassRegistry&);
diff --git a/llvm/include/llvm/LinkAllPasses.h b/llvm/include/llvm/LinkAllPasses.h
index 8d1d1883972a2..66810828c0db5 100644
--- a/llvm/include/llvm/LinkAllPasses.h
+++ b/llvm/include/llvm/LinkAllPasses.h
@@ -113,7 +113,6 @@ namespace {
(void) llvm::createLoopSimplifyCFGPass();
(void) llvm::createLoopStrengthReducePass();
(void) llvm::createLoopUnrollPass();
- (void) llvm::createLoopIdiomPass();
(void) llvm::createLoopRotatePass();
(void) llvm::createLowerConstantIntrinsicsPass();
(void) llvm::createLowerExpectIntrinsicPass();
diff --git a/llvm/include/llvm/Transforms/Scalar.h b/llvm/include/llvm/Transforms/Scalar.h
index 2dea75291d4c7..8770eecceb7f8 100644
--- a/llvm/include/llvm/Transforms/Scalar.h
+++ b/llvm/include/llvm/Transforms/Scalar.h
@@ -176,12 +176,6 @@ Pass *createSimpleLoopUnrollPass(int OptLevel = 2, bool OnlyWhenForced = false,
//
Pass *createLoopRotatePass(int MaxHeaderSize = -1, bool PrepareForLTO = false);
-//===----------------------------------------------------------------------===//
-//
-// LoopIdiom - This pass recognizes and replaces idioms in loops.
-//
-Pass *createLoopIdiomPass();
-
//===----------------------------------------------------------------------===//
//
// DemoteRegisterToMemoryPass - This pass is used to demote registers to memory
diff --git a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
index 841e608079018..6312217840c16 100644
--- a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
+++ b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
@@ -152,7 +152,6 @@ void PassManagerBuilder::addFunctionSimplificationPasses(
SimplifyCFGOptions().convertSwitchRangeToICmp(true)));
MPM.add(createInstructionCombiningPass());
// We resume loop passes creating a second loop pipeline here.
- MPM.add(createLoopIdiomPass()); // Recognize idioms like memset.
MPM.add(createIndVarSimplifyPass()); // Canonicalize indvars
// Unroll small loops and perform peeling.
diff --git a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
index 035cbdf595a8c..6922ba3d70027 100644
--- a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
@@ -254,62 +254,8 @@ class LoopIdiomRecognize {
/// @}
};
-
-class LoopIdiomRecognizeLegacyPass : public LoopPass {
-public:
- static char ID;
-
- explicit LoopIdiomRecognizeLegacyPass() : LoopPass(ID) {
- initializeLoopIdiomRecognizeLegacyPassPass(
- *PassRegistry::getPassRegistry());
- }
-
- bool runOnLoop(Loop *L, LPPassManager &LPM) override {
- if (DisableLIRP::All)
- return false;
-
- if (skipLoop(L))
- return false;
-
- AliasAnalysis *AA = &getAnalysis<AAResultsWrapperPass>().getAAResults();
- DominatorTree *DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
- LoopInfo *LI = &getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
- ScalarEvolution *SE = &getAnalysis<ScalarEvolutionWrapperPass>().getSE();
- TargetLibraryInfo *TLI =
- &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(
- *L->getHeader()->getParent());
- const TargetTransformInfo *TTI =
- &getAnalysis<TargetTransformInfoWrapperPass>().getTTI(
- *L->getHeader()->getParent());
- const DataLayout *DL = &L->getHeader()->getModule()->getDataLayout();
- auto *MSSAAnalysis = getAnalysisIfAvailable<MemorySSAWrapperPass>();
- MemorySSA *MSSA = nullptr;
- if (MSSAAnalysis)
- MSSA = &MSSAAnalysis->getMSSA();
-
- // For the old PM, we can't use OptimizationRemarkEmitter as an analysis
- // pass. Function analyses need to be preserved across loop transformations
- // but ORE cannot be preserved (see comment before the pass definition).
- OptimizationRemarkEmitter ORE(L->getHeader()->getParent());
-
- LoopIdiomRecognize LIR(AA, DT, LI, SE, TLI, TTI, MSSA, DL, ORE);
- return LIR.runOnLoop(L);
- }
-
- /// This transformation requires natural loop information & requires that
- /// loop preheaders be inserted into the CFG.
- void getAnalysisUsage(AnalysisUsage &AU) const override {
- AU.addRequired<TargetLibraryInfoWrapperPass>();
- AU.addRequired<TargetTransformInfoWrapperPass>();
- AU.addPreserved<MemorySSAWrapperPass>();
- getLoopAnalysisUsage(AU);
- }
-};
-
} // end anonymous namespace
-char LoopIdiomRecognizeLegacyPass::ID = 0;
-
PreservedAnalyses LoopIdiomRecognizePass::run(Loop &L, LoopAnalysisManager &AM,
LoopStandardAnalysisResults &AR,
LPMUpdater &) {
@@ -334,16 +280,6 @@ PreservedAnalyses LoopIdiomRecognizePass::run(Loop &L, LoopAnalysisManager &AM,
return PA;
}
-INITIALIZE_PASS_BEGIN(LoopIdiomRecognizeLegacyPass, "loop-idiom",
- "Recognize loop idioms", false, false)
-INITIALIZE_PASS_DEPENDENCY(LoopPass)
-INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass)
-INITIALIZE_PASS_DEPENDENCY(TargetTransformInfoWrapperPass)
-INITIALIZE_PASS_END(LoopIdiomRecognizeLegacyPass, "loop-idiom",
- "Recognize loop idioms", false, false)
-
-Pass *llvm::createLoopIdiomPass() { return new LoopIdiomRecognizeLegacyPass(); }
-
static void deleteDeadInstruction(Instruction *I) {
I->replaceAllUsesWith(PoisonValue::get(I->getType()));
I->eraseFromParent();
diff --git a/llvm/lib/Transforms/Scalar/Scalar.cpp b/llvm/lib/Transforms/Scalar/Scalar.cpp
index e07471f75dae2..38c2bffc66d0a 100644
--- a/llvm/lib/Transforms/Scalar/Scalar.cpp
+++ b/llvm/lib/Transforms/Scalar/Scalar.cpp
@@ -65,7 +65,6 @@ void llvm::initializeScalarOpts(PassRegistry &Registry) {
initializeLoopRotateLegacyPassPass(Registry);
initializeLoopStrengthReducePass(Registry);
initializeLoopUnrollPass(Registry);
- initializeLoopIdiomRecognizeLegacyPassPass(Registry);
initializeLowerAtomicLegacyPassPass(Registry);
initializeLowerConstantIntrinsicsPass(Registry);
initializeLowerExpectIntrinsicPass(Registry);
@@ -168,10 +167,6 @@ void LLVMAddLICMPass(LLVMPassManagerRef PM) {
unwrap(PM)->add(createLICMPass());
}
-void LLVMAddLoopIdiomPass(LLVMPassManagerRef PM) {
- unwrap(PM)->add(createLoopIdiomPass());
-}
-
void LLVMAddLoopRotatePass(LLVMPassManagerRef PM) {
unwrap(PM)->add(createLoopRotatePass());
}
diff --git a/llvm/test/Bindings/OCaml/scalar_opts.ml b/llvm/test/Bindings/OCaml/scalar_opts.ml
index d63d63b9f0564..861e38c4bf012 100644
--- a/llvm/test/Bindings/OCaml/scalar_opts.ml
+++ b/llvm/test/Bindings/OCaml/scalar_opts.ml
@@ -53,7 +53,6 @@ let test_transforms () =
++ add_instruction_combination
++ add_jump_threading
++ add_licm
- ++ add_loop_idiom
++ add_loop_rotation
++ add_loop_unroll
++ add_memcpy_opt
diff --git a/polly/lib/CodeGen/CodegenCleanup.cpp b/polly/lib/CodeGen/CodegenCleanup.cpp
index 0f66d757c67bd..e57475079788e 100644
--- a/polly/lib/CodeGen/CodegenCleanup.cpp
+++ b/polly/lib/CodeGen/CodegenCleanup.cpp
@@ -84,7 +84,6 @@ class CodegenCleanup final : public FunctionPass {
FPM->add(createCFGSimplificationPass());
FPM->add(createInstructionCombiningPass(true));
FPM->add(createIndVarSimplifyPass());
- FPM->add(createLoopIdiomPass());
FPM->add(createCFGSimplificationPass());
FPM->add(createSimpleLoopUnrollPass(3));
FPM->add(createMergedLoadStoreMotionPass());
More information about the llvm-commits
mailing list