Skip to content

Conversation

@Meinersbur
Copy link
Member

Reapply of a22d1c2. Using this PR for pre-merge CI.

Instead of relying on any pass manager to schedule Polly's passes, add
Polly's own pipeline manager which is seen as a monolithic pass in
LLVM's pass manager. Polly's former passes are now phases of the new
PhaseManager component.

Relying on LLVM's pass manager (the legacy as well as the New Pass
Manager) to manage Polly's phases never was a good fit that the
PhaseManager resolves:

  • Polly passes were modifying analysis results, in particular RegionInfo
    and ScopInfo. This means that there was not just one unique and
    "definite" analysis result, the actual result depended on which analyses
    ran prior, and the pass manager was not allowed to throw away cached
    analyses or prior SCoP optimizations would have been forgotten. The LLVM
    pass manger's persistance of analysis results is not contractual but
    designed for caching.

  • Polly depends on a particular execution order of passes and regions
    (e.g. regression tests, invalidation of consecutive SCoPs). LLVM's pass
    manager does not guarantee any excecution order.

  • Polly does not completely preserve DominatorTree, RegionInfo,
    LoopInfo, or ScalarEvolution, but only as-needed for Polly's own uses.
    Because the ScopDetection object stores references to those analyses, it
    still had to lie to the pass manager that they would be preserved, or
    the pass manager would have released and recomputed the invalidated
    analysis objects that ScopDetection/ScopInfo was still referencing. To
    ensure that no non-Polly pass would see these not-completely-preserved
    analyses, all analyses still had to be thrown away after the
    ScopPassManager, respectively with a BarrierNoopPass in case of the LPM.

  • The NPM's PassInstrumentation wraps the IR unit into an llvm::Any
    object, but implementations such as PrintIRInstrumentation call
    llvm_unreachable on encountering an unknown IR unit, such as SCoPs, with
    no extension points to add support. Hence LLVM crashes when dumping IR
    between SCoP passes (such as -print-before-changed with Polly being
    active).

The new PhaseManager uses some command line options that previously
belonged to Polly's legacy passes, such as -polly-print-detect (so the
option will continue to work). Hence the LPM support is incompatible
with the new approach and support for it is removed.

Instead of relying on any pass manager to schedule Polly's passes, add
Polly's own pipeline manager which is seen as a monolithic pass in
LLVM's pass manager. Polly's former passes are now phases of the new
PhaseManager component.

Relying on LLVM's pass manager (the legacy as well as the New Pass
Manager) to manage Polly's phases never was a good fit that the
PhaseManager resolves:

* Polly passes were modifying analysis results, in particular RegionInfo
and ScopInfo. This means that there was not just one unique and
"definite" analysis result, the actual result depended on which analyses
ran prior, and the pass manager was not allowed to throw away cached
analyses or prior SCoP optimizations would have been forgotten. The LLVM
pass manger's persistance of analysis results is not contractual but
designed for caching.

* Polly depends on a particular execution order of passes and regions
(e.g. regression tests, invalidation of consecutive SCoPs). LLVM's pass
manager does not guarantee any excecution order.

* Polly does not completely preserve DominatorTree, RegionInfo,
LoopInfo, or ScalarEvolution, but only as-needed for Polly's own uses.
Because the ScopDetection object stores references to those analyses, it
still had to lie to the pass manager that they would be preserved, or
the pass manager would have released and recomputed the invalidated
analysis objects that ScopDetection/ScopInfo was still referencing. To
ensure that no non-Polly pass would see these not-completely-preserved
analyses, all analyses still had to be thrown away after the
ScopPassManager, respectively with a BarrierNoopPass in case of the LPM.
 
* The NPM's PassInstrumentation wraps the IR unit into an `llvm::Any`
object, but implementations such as PrintIRInstrumentation call
llvm_unreachable on encountering an unknown IR unit, such as SCoPs, with
no extension points to add support. Hence LLVM crashes when dumping IR
between SCoP passes (such as `-print-before-changed` with Polly being
active).

The new PhaseManager uses some command line options that previously
belonged to Polly's legacy passes, such as `-polly-print-detect` (so the
option will continue to work). Hence the LPM support is incompatible
with the new approach and support for it is removed.
@llvmbot
Copy link
Member

llvmbot commented Nov 11, 2025

@llvm/pr-subscribers-llvm-transforms

Author: Michael Kruse (Meinersbur)

Changes

Reapply of a22d1c2. Using this PR for pre-merge CI.

Instead of relying on any pass manager to schedule Polly's passes, add
Polly's own pipeline manager which is seen as a monolithic pass in
LLVM's pass manager. Polly's former passes are now phases of the new
PhaseManager component.

Relying on LLVM's pass manager (the legacy as well as the New Pass
Manager) to manage Polly's phases never was a good fit that the
PhaseManager resolves:

  • Polly passes were modifying analysis results, in particular RegionInfo
    and ScopInfo. This means that there was not just one unique and
    "definite" analysis result, the actual result depended on which analyses
    ran prior, and the pass manager was not allowed to throw away cached
    analyses or prior SCoP optimizations would have been forgotten. The LLVM
    pass manger's persistance of analysis results is not contractual but
    designed for caching.

  • Polly depends on a particular execution order of passes and regions
    (e.g. regression tests, invalidation of consecutive SCoPs). LLVM's pass
    manager does not guarantee any excecution order.

  • Polly does not completely preserve DominatorTree, RegionInfo,
    LoopInfo, or ScalarEvolution, but only as-needed for Polly's own uses.
    Because the ScopDetection object stores references to those analyses, it
    still had to lie to the pass manager that they would be preserved, or
    the pass manager would have released and recomputed the invalidated
    analysis objects that ScopDetection/ScopInfo was still referencing. To
    ensure that no non-Polly pass would see these not-completely-preserved
    analyses, all analyses still had to be thrown away after the
    ScopPassManager, respectively with a BarrierNoopPass in case of the LPM.

  • The NPM's PassInstrumentation wraps the IR unit into an llvm::Any
    object, but implementations such as PrintIRInstrumentation call
    llvm_unreachable on encountering an unknown IR unit, such as SCoPs, with
    no extension points to add support. Hence LLVM crashes when dumping IR
    between SCoP passes (such as -print-before-changed with Polly being
    active).

The new PhaseManager uses some command line options that previously
belonged to Polly's legacy passes, such as -polly-print-detect (so the
option will continue to work). Hence the LPM support is incompatible
with the new approach and support for it is removed.


Patch is 994.30 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/167560.diff

1146 Files Affected:

  • (modified) llvm/lib/Transforms/Scalar/LoopVersioningLICM.cpp (+1-1)
  • (modified) polly/docs/ReleaseNotes.rst (+4)
  • (modified) polly/include/polly/Canonicalization.h (-8)
  • (modified) polly/include/polly/CodeGen/CodeGeneration.h (+3)
  • (modified) polly/include/polly/CodeGen/IslAst.h (+4-32)
  • (modified) polly/include/polly/CodePreparation.h (+6)
  • (modified) polly/include/polly/DeLICM.h (+1-10)
  • (modified) polly/include/polly/DeadCodeElimination.h (+2-11)
  • (modified) polly/include/polly/DependenceInfo.h (+3-103)
  • (modified) polly/include/polly/FlattenSchedule.h (+3-13)
  • (modified) polly/include/polly/ForwardOpTree.h (+9-11)
  • (modified) polly/include/polly/JSONExporter.h (+4-9)
  • (removed) polly/include/polly/LinkAllPasses.h (-156)
  • (modified) polly/include/polly/MaximalStaticExpansion.h (+2)
  • (added) polly/include/polly/Pass/PhaseManager.h (+127)
  • (added) polly/include/polly/Pass/PollyFunctionPass.h (+32)
  • (added) polly/include/polly/Pass/PollyModulePass.h (+30)
  • (modified) polly/include/polly/PruneUnprofitable.h (+2-10)
  • (modified) polly/include/polly/RegisterPasses.h (-2)
  • (modified) polly/include/polly/ScheduleOptimizer.h (+4-12)
  • (modified) polly/include/polly/ScopDetection.h (-27)
  • (modified) polly/include/polly/ScopGraphPrinter.h (+3)
  • (modified) polly/include/polly/ScopInfo.h (-76)
  • (modified) polly/include/polly/ScopInliner.h (-6)
  • (modified) polly/include/polly/ScopPass.h (-28)
  • (modified) polly/include/polly/Simplify.h (+2-21)
  • (modified) polly/include/polly/Support/DumpFunctionPass.h (-12)
  • (modified) polly/include/polly/Support/DumpModulePass.h (+1-14)
  • (modified) polly/include/polly/Support/ScopHelper.h (-8)
  • (modified) polly/lib/Analysis/DependenceInfo.cpp (+9-211)
  • (modified) polly/lib/Analysis/PruneUnprofitable.cpp (+2-30)
  • (modified) polly/lib/Analysis/ScopBuilder.cpp (+1)
  • (modified) polly/lib/Analysis/ScopDetection.cpp (-107)
  • (modified) polly/lib/Analysis/ScopGraphPrinter.cpp (+14-106)
  • (modified) polly/lib/Analysis/ScopInfo.cpp (-228)
  • (modified) polly/lib/Analysis/ScopPass.cpp (-36)
  • (modified) polly/lib/CMakeLists.txt (+3)
  • (modified) polly/lib/CodeGen/CodeGeneration.cpp (+3-69)
  • (modified) polly/lib/CodeGen/IslAst.cpp (+17-84)
  • (modified) polly/lib/Exchange/JSONExporter.cpp (+22-138)
  • (added) polly/lib/Pass/PhaseManager.cpp (+432)
  • (added) polly/lib/Pass/PollyFunctionPass.cpp (+22)
  • (added) polly/lib/Pass/PollyModulePass.cpp (+29)
  • (modified) polly/lib/Support/DumpFunctionPass.cpp (-41)
  • (modified) polly/lib/Support/DumpModulePass.cpp (-47)
  • (modified) polly/lib/Support/PollyPasses.def (+17-8)
  • (modified) polly/lib/Support/RegisterPasses.cpp (+274-125)
  • (modified) polly/lib/Support/ScopHelper.cpp (-12)
  • (modified) polly/lib/Transform/Canonicalization.cpp (-65)
  • (modified) polly/lib/Transform/CodePreparation.cpp (-69)
  • (modified) polly/lib/Transform/DeLICM.cpp (+28-97)
  • (modified) polly/lib/Transform/DeadCodeElimination.cpp (+6-38)
  • (modified) polly/lib/Transform/FlattenSchedule.cpp (+35-104)
  • (modified) polly/lib/Transform/ForwardOpTree.cpp (+25-106)
  • (modified) polly/lib/Transform/MaximalStaticExpansion.cpp (+22-59)
  • (modified) polly/lib/Transform/ScheduleOptimizer.cpp (+23-129)
  • (modified) polly/lib/Transform/ScopInliner.cpp (-46)
  • (modified) polly/lib/Transform/Simplify.cpp (+15-86)
  • (modified) polly/test/CodeGen/20100617.ll (+1-1)
  • (modified) polly/test/CodeGen/20100622.ll (+2-2)
  • (modified) polly/test/CodeGen/20100707.ll (+1-1)
  • (modified) polly/test/CodeGen/20100707_2.ll (+1-1)
  • (modified) polly/test/CodeGen/20100708.ll (+1-1)
  • (modified) polly/test/CodeGen/20100708_2.ll (+1-1)
  • (modified) polly/test/CodeGen/20100713.ll (+1-1)
  • (modified) polly/test/CodeGen/20100713_2.ll (+1-1)
  • (modified) polly/test/CodeGen/20100717.ll (+1-1)
  • (modified) polly/test/CodeGen/20100718-DomInfo-2.ll (+1-1)
  • (modified) polly/test/CodeGen/20100718-DomInfo.ll (+1-1)
  • (modified) polly/test/CodeGen/20100720-MultipleConditions.ll (+1-1)
  • (modified) polly/test/CodeGen/20100809-IndependentBlock.ll (+1-1)
  • (modified) polly/test/CodeGen/20100811-ScalarDependencyBetweenBrAndCnd.ll (+1-1)
  • (modified) polly/test/CodeGen/20101030-Overflow.ll (+1-1)
  • (modified) polly/test/CodeGen/20101103-Overflow3.ll (+1-1)
  • (modified) polly/test/CodeGen/20101103-signmissmatch.ll (+1-1)
  • (modified) polly/test/CodeGen/20110226-Ignore-Dead-Code.ll (+1-1)
  • (modified) polly/test/CodeGen/20110226-PHI-Node-removed.ll (+1-1)
  • (modified) polly/test/CodeGen/20120316-InvalidCast.ll (+1-1)
  • (modified) polly/test/CodeGen/20120403-RHS-type-mismatch.ll (+1-1)
  • (modified) polly/test/CodeGen/20130221.ll (+1-1)
  • (modified) polly/test/CodeGen/20150328-SCEVExpanderIntroducesNewIV.ll (+1-1)
  • (modified) polly/test/CodeGen/Intrinsics/llvm-expect.ll (+1-1)
  • (modified) polly/test/CodeGen/LoopParallelMD/do_not_mutate_debug_info.ll (+1-1)
  • (modified) polly/test/CodeGen/LoopParallelMD/loop_nest_param_parallel.ll (+1-1)
  • (modified) polly/test/CodeGen/LoopParallelMD/single_loop_param_parallel.ll (+2-2)
  • (modified) polly/test/CodeGen/MemAccess/bad_alignment.ll (+1-1)
  • (modified) polly/test/CodeGen/MemAccess/codegen_address_space.ll (+1-1)
  • (modified) polly/test/CodeGen/MemAccess/codegen_constant_offset.ll (+1-1)
  • (modified) polly/test/CodeGen/MemAccess/codegen_simple.ll (+1-1)
  • (modified) polly/test/CodeGen/MemAccess/codegen_simple_float.ll (+1-1)
  • (modified) polly/test/CodeGen/MemAccess/codegen_simple_md.ll (+2-2)
  • (modified) polly/test/CodeGen/MemAccess/codegen_simple_md_float.ll (+2-2)
  • (modified) polly/test/CodeGen/MemAccess/create_arrays.ll (+2-2)
  • (modified) polly/test/CodeGen/MemAccess/create_arrays_heap.ll (+2-2)
  • (modified) polly/test/CodeGen/MemAccess/default_aligned_new_access_function.ll (+1-1)
  • (modified) polly/test/CodeGen/MemAccess/different_types.ll (+1-3)
  • (modified) polly/test/CodeGen/MemAccess/generate-all.ll (+2-4)
  • (modified) polly/test/CodeGen/MemAccess/invariant_base_ptr.ll (+1-3)
  • (modified) polly/test/CodeGen/MemAccess/map_scalar_access.ll (+2-2)
  • (modified) polly/test/CodeGen/MemAccess/multiple_types.ll (+1-3)
  • (modified) polly/test/CodeGen/MemAccess/simple.ll (+1-1)
  • (modified) polly/test/CodeGen/MemAccess/simple_analyze.ll (+1-1)
  • (modified) polly/test/CodeGen/MemAccess/update_access_functions.ll (+1-3)
  • (modified) polly/test/CodeGen/Metadata/basic_vec_annotate.ll (+1-1)
  • (modified) polly/test/CodeGen/Metadata/fallback_vec_annotate.ll (+2-2)
  • (modified) polly/test/CodeGen/OpenMP/alias-metadata.ll (+1-1)
  • (modified) polly/test/CodeGen/OpenMP/floord-as-argument-to-subfunction.ll (+1-1)
  • (modified) polly/test/CodeGen/OpenMP/inlineasm.ll (+1-1)
  • (modified) polly/test/CodeGen/OpenMP/invariant_base_pointer_preloaded.ll (+1-2)
  • (modified) polly/test/CodeGen/OpenMP/invariant_base_pointer_preloaded_different_bb.ll (+1-2)
  • (modified) polly/test/CodeGen/OpenMP/invariant_base_pointer_preloaded_pass_only_needed.ll (+1-2)
  • (modified) polly/test/CodeGen/OpenMP/invariant_base_pointers_preloaded.ll (+1-2)
  • (modified) polly/test/CodeGen/OpenMP/loop-body-references-outer-iv.ll (+2-2)
  • (modified) polly/test/CodeGen/OpenMP/loop-body-references-outer-values-2.ll (+2-2)
  • (modified) polly/test/CodeGen/OpenMP/loop-body-references-outer-values-3.ll (+2-2)
  • (modified) polly/test/CodeGen/OpenMP/loop-body-references-outer-values.ll (+2-2)
  • (modified) polly/test/CodeGen/OpenMP/loop-bounds-reference-outer-ids.ll (+2-2)
  • (modified) polly/test/CodeGen/OpenMP/mapped-phi-access.ll (+1-1)
  • (modified) polly/test/CodeGen/OpenMP/matmul-parallel.ll (+2-2)
  • (modified) polly/test/CodeGen/OpenMP/new_multidim_access.ll (+2-6)
  • (modified) polly/test/CodeGen/OpenMP/recomputed-srem.ll (+1-2)
  • (modified) polly/test/CodeGen/OpenMP/reference-argument-from-non-affine-region.ll (+5-14)
  • (modified) polly/test/CodeGen/OpenMP/reference-other-bb.ll (+1-1)
  • (modified) polly/test/CodeGen/OpenMP/reference-preceeding-loop.ll (+2-2)
  • (modified) polly/test/CodeGen/OpenMP/reference_latest.ll (+1-1)
  • (modified) polly/test/CodeGen/OpenMP/scev-rewriting.ll (+1-1)
  • (modified) polly/test/CodeGen/OpenMP/single_loop.ll (+9-9)
  • (modified) polly/test/CodeGen/OpenMP/single_loop_with_loop_invariant_baseptr.ll (+2-2)
  • (modified) polly/test/CodeGen/OpenMP/single_loop_with_param.ll (+3-13)
  • (modified) polly/test/CodeGen/OpenMP/two-parallel-loops-reference-outer-indvar.ll (+2-2)
  • (modified) polly/test/CodeGen/PHIInExit.ll (+1-1)
  • (modified) polly/test/CodeGen/RuntimeDebugBuilder/combine_different_values.ll (+1-3)
  • (modified) polly/test/CodeGen/RuntimeDebugBuilder/stmt_tracing.ll (+1-1)
  • (modified) polly/test/CodeGen/alias-check-multi-dim.ll (+1-2)
  • (modified) polly/test/CodeGen/alias_metadata_too_many_arrays.ll (+1-2)
  • (modified) polly/test/CodeGen/aliasing_different_base_and_access_type.ll (+1-1)
  • (modified) polly/test/CodeGen/aliasing_different_pointer_types.ll (+1-1)
  • (modified) polly/test/CodeGen/aliasing_multidimensional_access.ll (+1-1)
  • (modified) polly/test/CodeGen/aliasing_parametric_simple_1.ll (+1-1)
  • (modified) polly/test/CodeGen/aliasing_parametric_simple_2.ll (+1-1)
  • (modified) polly/test/CodeGen/aliasing_struct_element.ll (+1-1)
  • (modified) polly/test/CodeGen/alignment.ll (+1-1)
  • (modified) polly/test/CodeGen/annotated_alias_scopes.ll (+1-1)
  • (modified) polly/test/CodeGen/blas_sscal_simplified.ll (+1-1)
  • (modified) polly/test/CodeGen/conflict-between-loop-invariant-code-hosting-and-escape-map-computation.ll (+1-1)
  • (modified) polly/test/CodeGen/constant_condition.ll (+1-1)
  • (modified) polly/test/CodeGen/create-conditional-scop.ll (+1-1)
  • (modified) polly/test/CodeGen/dead_invariant_load_instruction_referenced_by_parameter_1.ll (+1-1)
  • (modified) polly/test/CodeGen/dead_invariant_load_instruction_referenced_by_parameter_2.ll (+1-1)
  • (modified) polly/test/CodeGen/debug-intrinsics.ll (+2-6)
  • (modified) polly/test/CodeGen/dominance_problem_after_early_codegen_bailout.ll (+1-1)
  • (modified) polly/test/CodeGen/empty_domain_in_context.ll (+1-1)
  • (modified) polly/test/CodeGen/entry_with_trivial_phi.ll (+1-1)
  • (modified) polly/test/CodeGen/entry_with_trivial_phi_other_bb.ll (+1-1)
  • (modified) polly/test/CodeGen/error-stmt-in-non-affine-region.ll (+1-1)
  • (modified) polly/test/CodeGen/error_block_contains_invalid_memory_access.ll (+1-1)
  • (modified) polly/test/CodeGen/exprModDiv.ll (+2-5)
  • (modified) polly/test/CodeGen/hoisted_load_escapes_through_phi.ll (+2-4)
  • (modified) polly/test/CodeGen/hoisting_1.ll (+1-1)
  • (modified) polly/test/CodeGen/hoisting_2.ll (+1-1)
  • (modified) polly/test/CodeGen/inner_scev_sdiv_1.ll (+1-1)
  • (modified) polly/test/CodeGen/inner_scev_sdiv_2.ll (+1-1)
  • (modified) polly/test/CodeGen/inner_scev_sdiv_3.ll (+1-1)
  • (modified) polly/test/CodeGen/inner_scev_sdiv_in_lb.ll (+2-2)
  • (modified) polly/test/CodeGen/inner_scev_sdiv_in_lb_invariant.ll (+1-2)
  • (modified) polly/test/CodeGen/inner_scev_sdiv_in_rtc.ll (+1-2)
  • (modified) polly/test/CodeGen/intrinsics_lifetime.ll (+1-1)
  • (modified) polly/test/CodeGen/intrinsics_misc.ll (+1-1)
  • (modified) polly/test/CodeGen/inv-load-lnt-crash-wrong-order-2.ll (+1-2)
  • (modified) polly/test/CodeGen/inv-load-lnt-crash-wrong-order-3.ll (+1-2)
  • (modified) polly/test/CodeGen/inv-load-lnt-crash-wrong-order.ll (+1-2)
  • (modified) polly/test/CodeGen/invariant-load-dimension.ll (+2-2)
  • (modified) polly/test/CodeGen/invariant-load-preload-base-pointer-origin-first.ll (+1-1)
  • (modified) polly/test/CodeGen/invariant_cannot_handle_void.ll (+2-2)
  • (modified) polly/test/CodeGen/invariant_load.ll (+1-1)
  • (modified) polly/test/CodeGen/invariant_load_address_space.ll (+1-1)
  • (modified) polly/test/CodeGen/invariant_load_alias_metadata.ll (+1-2)
  • (modified) polly/test/CodeGen/invariant_load_base_pointer.ll (+1-1)
  • (modified) polly/test/CodeGen/invariant_load_base_pointer_conditional.ll (+1-1)
  • (modified) polly/test/CodeGen/invariant_load_base_pointer_conditional_2.ll (+3-3)
  • (modified) polly/test/CodeGen/invariant_load_canonicalize_array_baseptrs.ll (+1-3)
  • (modified) polly/test/CodeGen/invariant_load_condition.ll (+1-1)
  • (modified) polly/test/CodeGen/invariant_load_different_sized_types.ll (+1-2)
  • (modified) polly/test/CodeGen/invariant_load_escaping.ll (+1-1)
  • (modified) polly/test/CodeGen/invariant_load_escaping_second_scop.ll (+1-1)
  • (modified) polly/test/CodeGen/invariant_load_in_non_affine_subregion.ll (+1-1)
  • (modified) polly/test/CodeGen/invariant_load_loop_ub.ll (+1-1)
  • (modified) polly/test/CodeGen/invariant_load_not_executed_but_in_parameters.ll (+1-1)
  • (modified) polly/test/CodeGen/invariant_load_outermost.ll (+1-1)
  • (modified) polly/test/CodeGen/invariant_load_parameters_cyclic_dependence.ll (+2-2)
  • (modified) polly/test/CodeGen/invariant_load_ptr_ptr_noalias.ll (+1-1)
  • (modified) polly/test/CodeGen/invariant_load_scalar_dep.ll (+1-1)
  • (modified) polly/test/CodeGen/invariant_load_scalar_escape_alloca_sharing.ll (+1-1)
  • (modified) polly/test/CodeGen/invariant_loads_from_struct_with_different_types_1.ll (+1-1)
  • (modified) polly/test/CodeGen/invariant_loads_from_struct_with_different_types_2.ll (+1-1)
  • (modified) polly/test/CodeGen/invariant_loads_ignore_parameter_bounds.ll (+1-2)
  • (modified) polly/test/CodeGen/invariant_verify_function_failed.ll (+1-1)
  • (modified) polly/test/CodeGen/invariant_verify_function_failed_2.ll (+2-2)
  • (modified) polly/test/CodeGen/issue56692.ll (+1-1)
  • (modified) polly/test/CodeGen/large-numbers-in-boundary-context.ll (+1-1)
  • (modified) polly/test/CodeGen/load_subset_with_context.ll (+1-1)
  • (modified) polly/test/CodeGen/loop-invariant-load-type-mismatch.ll (+1-1)
  • (modified) polly/test/CodeGen/loop_with_condition.ll (+1-1)
  • (modified) polly/test/CodeGen/loop_with_condition_2.ll (+1-1)
  • (modified) polly/test/CodeGen/loop_with_condition_ineq.ll (+1-1)
  • (modified) polly/test/CodeGen/loop_with_condition_nested.ll (+2-2)
  • (modified) polly/test/CodeGen/loop_with_conditional_entry_edge_split_hard_case.ll (+1-1)
  • (modified) polly/test/CodeGen/memcpy_annotations.ll (+1-1)
  • (modified) polly/test/CodeGen/multidim-non-matching-typesize-2.ll (+1-2)
  • (modified) polly/test/CodeGen/multidim-non-matching-typesize.ll (+1-2)
  • (modified) polly/test/CodeGen/multidim_2d_parametric_array_static_loop_bounds.ll (+1-1)
  • (modified) polly/test/CodeGen/multidim_alias_check.ll (+1-1)
  • (modified) polly/test/CodeGen/multiple-codegens.ll (+2-2)
  • (added) polly/test/CodeGen/multiple-scops-in-a-row-disappearing.ll (+64)
  • (modified) polly/test/CodeGen/multiple-scops-in-a-row.ll (+1-1)
  • (modified) polly/test/CodeGen/multiple-types-invariant-load-2.ll (+1-2)
  • (modified) polly/test/CodeGen/multiple-types-invariant-load.ll (+1-2)
  • (modified) polly/test/CodeGen/multiple_sai_fro_same_base_address.ll (+2-2)
  • (modified) polly/test/CodeGen/no-overflow-tracking.ll (+2-2)
  • (modified) polly/test/CodeGen/no_guard_bb.ll (+1-1)
  • (modified) polly/test/CodeGen/non-affine-dominance-generated-entering.ll (+1-1)
  • (modified) polly/test/CodeGen/non-affine-exit-node-dominance.ll (+1-1)
  • (modified) polly/test/CodeGen/non-affine-phi-node-expansion-2.ll (+1-2)
  • (modified) polly/test/CodeGen/non-affine-phi-node-expansion-3.ll (+1-2)
  • (modified) polly/test/CodeGen/non-affine-phi-node-expansion-4.ll (+1-2)
  • (modified) polly/test/CodeGen/non-affine-phi-node-expansion.ll (+1-2)
  • (modified) polly/test/CodeGen/non-affine-region-exit-phi-incoming-synthesize-2.ll (+1-1)
  • (modified) polly/test/CodeGen/non-affine-region-exit-phi-incoming-synthesize.ll (+1-1)
  • (modified) polly/test/CodeGen/non-affine-region-implicit-store.ll (+1-1)
  • (modified) polly/test/CodeGen/non-affine-region-phi-references-in-scop-value.ll (+1-2)
  • (modified) polly/test/CodeGen/non-affine-subregion-dominance-reuse.ll (+1-2)
  • (modified) polly/test/CodeGen/non-affine-switch.ll (+1-2)
  • (modified) polly/test/CodeGen/non-affine-synthesized-in-branch.ll (+1-1)
  • (modified) polly/test/CodeGen/non-affine-update.ll (+1-2)
  • (modified) polly/test/CodeGen/non-hoisted-load-needed-as-base-ptr.ll (+1-1)
  • (modified) polly/test/CodeGen/non_affine_float_compare.ll (+1-3)
  • (modified) polly/test/CodeGen/only_non_affine_error_region.ll (+1-1)
  • (modified) polly/test/CodeGen/openmp_limit_threads.ll (+6-6)
  • (modified) polly/test/CodeGen/out-of-scop-phi-node-use.ll (+1-1)
  • (modified) polly/test/CodeGen/param_div_div_div_2.ll (+2-2)
  • (modified) polly/test/CodeGen/partial_write_array.ll (+1-1)
  • (modified) polly/test/CodeGen/partial_write_emptyset.ll (+1-1)
  • (modified) polly/test/CodeGen/partial_write_full_write_that_appears_partial.ll (+1-1)
  • (modified) polly/test/CodeGen/partial_write_impossible_restriction.ll (+1-1)
  • (modified) polly/test/CodeGen/partial_write_in_region.ll (+1-4)
  • (modified) polly/test/CodeGen/partial_write_in_region_with_loop.ll (+1-4)
  • (modified) polly/test/CodeGen/partial_write_mapped_scalar.ll (+1-1)
  • (modified) polly/test/CodeGen/partial_write_mapped_scalar_subregion.ll (+1-1)
  • (modified) polly/test/CodeGen/perf_monitoring.ll (+1-2)
  • (modified) polly/test/CodeGen/perf_monitoring_cycles_per_scop.ll (+1-2)
  • (modified) polly/test/CodeGen/perf_monitoring_trip_counts_per_scop.ll (+1-2)
  • (modified) polly/test/CodeGen/phi-defined-before-scop.ll (+1-1)
  • (modified) polly/test/CodeGen/phi_after_error_block_outside_of_scop.ll (+1-1)
  • (modified) polly/test/CodeGen/phi_condition_modeling_1.ll (+1-1)
  • (modified) polly/test/CodeGen/phi_condition_modeling_2.ll (+1-1)
  • (modified) polly/test/CodeGen/phi_conditional_simple_1.ll (+2-2)
  • (modified) polly/test/CodeGen/phi_in_exit_early_lnt_failure_1.ll (+1-1)
  • (modified) polly/test/CodeGen/phi_in_exit_early_lnt_failure_2.ll (+1-1)
  • (modified) polly/test/CodeGen/phi_in_exit_early_lnt_failure_3.ll (+1-1)
  • (modified) polly/test/CodeGen/phi_in_exit_early_lnt_failure_5.ll (+1-1)
  • (modified) polly/test/CodeGen/phi_loop_carried_float.ll (+1-1)
  • (modified) polly/test/CodeGen/phi_loop_carried_float_escape.ll (+2-4)
  • (modified) polly/test/CodeGen/phi_scalar_simple_1.ll (+1-1)
  • (modified) polly/test/CodeGen/phi_scalar_simple_2.ll (+1-1)
  • (modified) polly/test/CodeGen/phi_with_multi_exiting_edges_2.ll (+1-1)
  • (modified) polly/test/CodeGen/phi_with_one_exit_edge.ll (+1-1)
  • (modified) polly/test/CodeGen/pointer-type-expressions-2.ll (+2-2)
  • (modified) polly/test/CodeGen/pointer-type-expressions.ll (+2-2)
  • (modified) polly/test/CodeGen/pointer-type-pointer-type-comparison.ll (+2-2)
  • (modified) polly/test/CodeGen/pointer_rem.ll (+2-2)
  • (modified) polly/test/CodeGen/pr25241.ll (+1-1)
  • (modified) polly/test/CodeGen/ptrtoint_as_parameter.ll (+1-1)
  • (modified) polly/test/CodeGen/read-only-scalars.ll (+2-6)
  • (modified) polly/test/CodeGen/reduction.ll (+1-1)
  • (modified) polly/test/CodeGen/reduction_2.ll (+1-1)
  • (modified) polly/test/CodeGen/reduction_simple_binary.ll (+1-1)
  • (modified) polly/test/CodeGen/reggen_domtree_crash.ll (+1-1)
  • (modified) polly/test/CodeGen/region-with-instructions.ll (+1-1)
  • (modified) polly/test/CodeGen/region_exiting-domtree.ll (+1-1)
  • (modified) polly/test/CodeGen/region_multiexit_partialwrite.ll (+1-1)
  • (modified) polly/test/CodeGen/run-time-condition-with-scev-parameters.ll (+2-2)
  • (modified) polly/test/CodeGen/run-time-condition.ll (+1-1)
  • (modified) polly/test/CodeGen/scalar-references-used-in-scop-compute.ll (+1-1)
  • (modified) polly/test/CodeGen/scalar-store-from-same-bb.ll (+1-2)
  • (modified) polly/test/CodeGen/scalar_codegen_crash.ll (+1-2)
  • (modified) polly/test/CodeGen/scev-backedgetaken.ll (+1-1)
  • (modified) polly/test/CodeGen/scev-division-invariant-load.ll (+1-1)
  • (modified) polly/test/CodeGen/scev.ll (+1-1)
  • (modified) polly/test/CodeGen/scev_expansion_in_nonaffine.ll (+1-2)
  • (modified) polly/test/CodeGen/scev_looking_through_bitcasts.ll (+1-1)
  • (modified) polly/test/CodeGen/scop_expander_insert_point.ll (+1-2)
  • (modified) polly/test/CodeGen/scop_expander_segfault.ll (+1-1)
  • (modified) polly/test/CodeGen/scop_never_executed_runtime_check_location.ll (+1-1)
  • (modified) polly/test/CodeGen/select-base-pointer.ll (+1-1)
  • (modified) polly/test/CodeGen/sequential_loops.ll (+1-1)
  • (modified) polly/test/CodeGen/simple_loop_non_single_exit.ll (+1-1)
  • (modified) polly/test/CodeGen/simple_loop_non_single_exit_2.ll (+1-1)
diff --git a/llvm/lib/Transforms/Scalar/LoopVersioningLICM.cpp b/llvm/lib/Transforms/Scalar/LoopVersioningLICM.cpp
index f3e6cbf53507a..3aed643ee8065 100644
--- a/llvm/lib/Transforms/Scalar/LoopVersioningLICM.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopVersioningLICM.cpp
@@ -413,7 +413,7 @@ bool LoopVersioningLICM::legalLoopInstructions() {
     LLVM_DEBUG(dbgs() << "    Found a read-only loop!\n");
     return false;
   }
-  // Profitablity check:
+  // Profitability check:
   // Check invariant threshold, should be in limit.
   if (InvariantCounter * 100 < InvariantThreshold * LoadAndStoreCounter) {
     LLVM_DEBUG(
diff --git a/polly/docs/ReleaseNotes.rst b/polly/docs/ReleaseNotes.rst
index f5ea47b69cf02..215a802843304 100644
--- a/polly/docs/ReleaseNotes.rst
+++ b/polly/docs/ReleaseNotes.rst
@@ -13,3 +13,7 @@ In Polly |version| the following important changes have been incorporated.
 
  * ScopInliner has been updated for the New Pass Manager.
 
+ * Polly now is a monolithic pass split into phases.
+
+ * Polly's support for the legacy pass manager has been removed.
+
diff --git a/polly/include/polly/Canonicalization.h b/polly/include/polly/Canonicalization.h
index 03f277e4e91ba..972b660894a1c 100644
--- a/polly/include/polly/Canonicalization.h
+++ b/polly/include/polly/Canonicalization.h
@@ -11,12 +11,6 @@
 
 #include "llvm/Passes/PassBuilder.h"
 
-namespace llvm {
-namespace legacy {
-class PassManagerBase;
-}
-} // namespace llvm
-
 namespace polly {
 
 /// Schedule a set of canonicalization passes to prepare for Polly.
@@ -26,8 +20,6 @@ namespace polly {
 /// into a canonical form that simplifies the analysis and optimization passes
 /// of Polly. The set of optimization passes scheduled here is probably not yet
 /// optimal. TODO: Optimize the set of canonicalization passes.
-void registerCanonicalicationPasses(llvm::legacy::PassManagerBase &PM);
-
 llvm::FunctionPassManager
 buildCanonicalicationPassesForNPM(llvm::ModulePassManager &MPM,
                                   llvm::OptimizationLevel Level);
diff --git a/polly/include/polly/CodeGen/CodeGeneration.h b/polly/include/polly/CodeGen/CodeGeneration.h
index 57aec1d70cc72..2340fbe016b49 100644
--- a/polly/include/polly/CodeGen/CodeGeneration.h
+++ b/polly/include/polly/CodeGen/CodeGeneration.h
@@ -14,6 +14,7 @@
 #include "llvm/IR/PassManager.h"
 
 namespace polly {
+class IslAstInfo;
 
 enum VectorizerChoice {
   VECTORIZER_NONE,
@@ -33,6 +34,8 @@ struct CodeGenerationPass final : PassInfoMixin<CodeGenerationPass> {
 };
 
 extern bool PerfMonitoring;
+
+bool runCodeGeneration(Scop &S, llvm::RegionInfo &RI, IslAstInfo &AI);
 } // namespace polly
 
 #endif // POLLY_CODEGENERATION_H
diff --git a/polly/include/polly/CodeGen/IslAst.h b/polly/include/polly/CodeGen/IslAst.h
index c99a4957d6b48..3e1ff2c8a24da 100644
--- a/polly/include/polly/CodeGen/IslAst.h
+++ b/polly/include/polly/CodeGen/IslAst.h
@@ -21,6 +21,7 @@
 #ifndef POLLY_ISLAST_H
 #define POLLY_ISLAST_H
 
+#include "polly/DependenceInfo.h"
 #include "polly/ScopPass.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/IR/PassManager.h"
@@ -172,33 +173,6 @@ struct IslAstAnalysis : AnalysisInfoMixin<IslAstAnalysis> {
                  ScopStandardAnalysisResults &SAR);
 };
 
-class IslAstInfoWrapperPass final : public ScopPass {
-  std::unique_ptr<IslAstInfo> Ast;
-
-public:
-  static char ID;
-
-  IslAstInfoWrapperPass() : ScopPass(ID) {}
-
-  IslAstInfo &getAI() { return *Ast; }
-  const IslAstInfo &getAI() const { return *Ast; }
-
-  /// Build the AST for the given SCoP @p S.
-  bool runOnScop(Scop &S) override;
-
-  /// Register all analyses and transformation required.
-  void getAnalysisUsage(AnalysisUsage &AU) const override;
-
-  /// Release the internal memory.
-  void releaseMemory() override;
-
-  /// Print a source code representation of the program.
-  void printScop(raw_ostream &OS, Scop &S) const override;
-};
-
-llvm::Pass *createIslAstInfoWrapperPassPass();
-llvm::Pass *createIslAstInfoPrinterLegacyPass(llvm::raw_ostream &OS);
-
 struct IslAstPrinterPass final : PassInfoMixin<IslAstPrinterPass> {
   IslAstPrinterPass(raw_ostream &OS) : OS(OS) {}
 
@@ -207,11 +181,9 @@ struct IslAstPrinterPass final : PassInfoMixin<IslAstPrinterPass> {
 
   raw_ostream &OS;
 };
-} // namespace polly
 
-namespace llvm {
-void initializeIslAstInfoWrapperPassPass(llvm::PassRegistry &);
-void initializeIslAstInfoPrinterLegacyPassPass(llvm::PassRegistry &);
-} // namespace llvm
+std::unique_ptr<IslAstInfo> runIslAstGen(Scop &S,
+                                         DependenceAnalysis::Result &DA);
+} // namespace polly
 
 #endif // POLLY_ISLAST_H
diff --git a/polly/include/polly/CodePreparation.h b/polly/include/polly/CodePreparation.h
index c6bc526db209d..1a15e3d4d5a29 100644
--- a/polly/include/polly/CodePreparation.h
+++ b/polly/include/polly/CodePreparation.h
@@ -15,6 +15,12 @@
 
 #include "llvm/IR/PassManager.h"
 
+namespace llvm {
+class DominatorTree;
+class LoopInfo;
+class RegionInfo;
+} // namespace llvm
+
 namespace polly {
 struct CodePreparationPass final : llvm::PassInfoMixin<CodePreparationPass> {
   llvm::PreservedAnalyses run(llvm::Function &F,
diff --git a/polly/include/polly/DeLICM.h b/polly/include/polly/DeLICM.h
index 0e03c04079480..63fc509e0bd46 100644
--- a/polly/include/polly/DeLICM.h
+++ b/polly/include/polly/DeLICM.h
@@ -21,15 +21,10 @@
 #include "isl/isl-noexceptions.h"
 
 namespace llvm {
-class PassRegistry;
-class Pass;
 class raw_ostream;
 } // namespace llvm
 
 namespace polly {
-/// Create a new DeLICM pass instance.
-llvm::Pass *createDeLICMWrapperPass();
-llvm::Pass *createDeLICMPrinterLegacyPass(llvm::raw_ostream &OS);
 
 struct DeLICMPass final : llvm::PassInfoMixin<DeLICMPass> {
   DeLICMPass() {}
@@ -59,11 +54,7 @@ bool isConflicting(isl::union_set ExistingOccupied,
                    isl::union_map ProposedWrites,
                    llvm::raw_ostream *OS = nullptr, unsigned Indent = 0);
 
+bool runDeLICM(Scop &S);
 } // namespace polly
 
-namespace llvm {
-void initializeDeLICMWrapperPassPass(llvm::PassRegistry &);
-void initializeDeLICMPrinterLegacyPassPass(llvm::PassRegistry &);
-} // namespace llvm
-
 #endif /* POLLY_DELICM_H */
diff --git a/polly/include/polly/DeadCodeElimination.h b/polly/include/polly/DeadCodeElimination.h
index d416afa030c56..4d8da56c76eec 100644
--- a/polly/include/polly/DeadCodeElimination.h
+++ b/polly/include/polly/DeadCodeElimination.h
@@ -13,16 +13,10 @@
 #ifndef POLLY_DEADCODEELIMINATION_H
 #define POLLY_DEADCODEELIMINATION_H
 
+#include "polly/DependenceInfo.h"
 #include "polly/ScopPass.h"
 
-namespace llvm {
-class PassRegistry;
-class Pass;
-class raw_ostream;
-} // namespace llvm
-
 namespace polly {
-llvm::Pass *createDeadCodeElimWrapperPass();
 
 struct DeadCodeElimPass final : llvm::PassInfoMixin<DeadCodeElimPass> {
   DeadCodeElimPass() {}
@@ -31,10 +25,7 @@ struct DeadCodeElimPass final : llvm::PassInfoMixin<DeadCodeElimPass> {
                               ScopStandardAnalysisResults &SAR, SPMUpdater &U);
 };
 
+bool runDeadCodeElim(Scop &S, DependenceAnalysis::Result &DA);
 } // namespace polly
 
-namespace llvm {
-void initializeDeadCodeElimWrapperPassPass(llvm::PassRegistry &);
-} // namespace llvm
-
 #endif /* POLLY_DEADCODEELIMINATION_H */
diff --git a/polly/include/polly/DependenceInfo.h b/polly/include/polly/DependenceInfo.h
index d562ad80592f2..88ea468dd5473 100644
--- a/polly/include/polly/DependenceInfo.h
+++ b/polly/include/polly/DependenceInfo.h
@@ -145,7 +145,6 @@ class Dependences final {
   friend struct DependenceAnalysis;
   friend struct DependenceInfoPrinterPass;
   friend class DependenceInfo;
-  friend class DependenceInfoWrapperPass;
 
   /// Destructor that will free internal objects.
   ~Dependences() { releaseMemory(); }
@@ -192,6 +191,8 @@ class Dependences final {
   const AnalysisLevel Level;
 };
 
+extern Dependences::AnalysisLevel OptAnalysisLevel;
+
 struct DependenceAnalysis final : public AnalysisInfoMixin<DependenceAnalysis> {
   static AnalysisKey Key;
   struct Result {
@@ -232,108 +233,7 @@ struct DependenceInfoPrinterPass final
   raw_ostream &OS;
 };
 
-class DependenceInfo final : public ScopPass {
-public:
-  static char ID;
-
-  /// Construct a new DependenceInfo pass.
-  DependenceInfo() : ScopPass(ID) {}
-
-  /// Return the dependence information for the current SCoP.
-  ///
-  /// @param Level The granularity of dependence analysis result.
-  ///
-  /// @return The dependence analysis result
-  ///
-  const Dependences &getDependences(Dependences::AnalysisLevel Level);
-
-  /// Recompute dependences from schedule and memory accesses.
-  const Dependences &recomputeDependences(Dependences::AnalysisLevel Level);
-
-  /// Invalidate the dependence information and recompute it when needed again.
-  /// May be required when the underlying Scop was changed in a way that would
-  /// add new dependencies (e.g. between new statement instances insierted into
-  /// the SCoP) or intentionally breaks existing ones. It is not required when
-  /// updating the schedule that conforms the existing dependencies.
-  void abandonDependences();
-
-  /// Compute the dependence information for the SCoP @p S.
-  bool runOnScop(Scop &S) override;
-
-  /// Print the dependences for the given SCoP to @p OS.
-  void printScop(raw_ostream &OS, Scop &) const override;
-
-  /// Release the internal memory.
-  void releaseMemory() override {
-    for (auto &d : D)
-      d.reset();
-  }
-
-  /// Register all analyses and transformation required.
-  void getAnalysisUsage(AnalysisUsage &AU) const override;
-
-private:
-  Scop *S;
-
-  /// Dependences struct for the current SCoP.
-  std::unique_ptr<Dependences> D[Dependences::NumAnalysisLevels];
-};
-
-llvm::Pass *createDependenceInfoPass();
-llvm::Pass *createDependenceInfoPrinterLegacyPass(llvm::raw_ostream &OS);
-
-/// Construct a new DependenceInfoWrapper pass.
-class DependenceInfoWrapperPass final : public FunctionPass {
-public:
-  static char ID;
-
-  /// Construct a new DependenceInfoWrapper pass.
-  DependenceInfoWrapperPass() : FunctionPass(ID) {}
-
-  /// Return the dependence information for the given SCoP.
-  ///
-  /// @param S     SCoP object.
-  /// @param Level The granularity of dependence analysis result.
-  ///
-  /// @return The dependence analysis result
-  ///
-  const Dependences &getDependences(Scop *S, Dependences::AnalysisLevel Level);
-
-  /// Recompute dependences from schedule and memory accesses.
-  const Dependences &recomputeDependences(Scop *S,
-                                          Dependences::AnalysisLevel Level);
-
-  /// Compute the dependence information on-the-fly for the function.
-  bool runOnFunction(Function &F) override;
-
-  /// Print the dependences for the current function to @p OS.
-  void print(raw_ostream &OS, const Module *M = nullptr) const override;
-
-  /// Release the internal memory.
-  void releaseMemory() override { ScopToDepsMap.clear(); }
-
-  /// Register all analyses and transformation required.
-  void getAnalysisUsage(AnalysisUsage &AU) const override;
-
-private:
-  using ScopToDepsMapTy = DenseMap<Scop *, std::unique_ptr<Dependences>>;
-
-  /// Scop to Dependence map for the current function.
-  ScopToDepsMapTy ScopToDepsMap;
-};
-
-llvm::Pass *createDependenceInfoWrapperPassPass();
-llvm::Pass *
-createDependenceInfoPrinterLegacyFunctionPass(llvm::raw_ostream &OS);
-
+DependenceAnalysis::Result runDependenceAnalysis(Scop &S);
 } // namespace polly
 
-namespace llvm {
-void initializeDependenceInfoPass(llvm::PassRegistry &);
-void initializeDependenceInfoPrinterLegacyPassPass(llvm::PassRegistry &);
-void initializeDependenceInfoWrapperPassPass(llvm::PassRegistry &);
-void initializeDependenceInfoPrinterLegacyFunctionPassPass(
-    llvm::PassRegistry &);
-} // namespace llvm
-
 #endif
diff --git a/polly/include/polly/FlattenSchedule.h b/polly/include/polly/FlattenSchedule.h
index 3ef3c304243df..154344d2f5c3e 100644
--- a/polly/include/polly/FlattenSchedule.h
+++ b/polly/include/polly/FlattenSchedule.h
@@ -15,20 +15,10 @@
 #ifndef POLLY_FLATTENSCHEDULE_H
 #define POLLY_FLATTENSCHEDULE_H
 
-namespace llvm {
-class PassRegistry;
-class Pass;
-class raw_ostream;
-} // namespace llvm
-
 namespace polly {
-llvm::Pass *createFlattenSchedulePass();
-llvm::Pass *createFlattenSchedulePrinterLegacyPass(llvm::raw_ostream &OS);
-} // namespace polly
+class Scop;
 
-namespace llvm {
-void initializeFlattenSchedulePass(llvm::PassRegistry &);
-void initializeFlattenSchedulePrinterLegacyPassPass(llvm::PassRegistry &);
-} // namespace llvm
+void runFlattenSchedulePass(Scop &S);
+} // namespace polly
 
 #endif /* POLLY_FLATTENSCHEDULE_H */
diff --git a/polly/include/polly/ForwardOpTree.h b/polly/include/polly/ForwardOpTree.h
index b5da0f513ab78..8b2ece1f08e15 100644
--- a/polly/include/polly/ForwardOpTree.h
+++ b/polly/include/polly/ForwardOpTree.h
@@ -15,13 +15,7 @@
 
 #include "polly/ScopPass.h"
 
-namespace llvm {
-class PassRegistry;
-} // namespace llvm
-
 namespace polly {
-llvm::Pass *createForwardOpTreeWrapperPass();
-llvm::Pass *createForwardOpTreePrinterLegacyPass(llvm::raw_ostream &OS);
 
 struct ForwardOpTreePass final : llvm::PassInfoMixin<ForwardOpTreePass> {
   ForwardOpTreePass() {}
@@ -41,11 +35,15 @@ struct ForwardOpTreePrinterPass final
   llvm::raw_ostream &OS;
 };
 
+/// Pass that redirects scalar reads to array elements that are known to contain
+/// the same value.
+///
+/// This reduces the number of scalar accesses and therefore potentially
+/// increases the freedom of the scheduler. In the ideal case, all reads of a
+/// scalar definition are redirected (We currently do not care about removing
+/// the write in this case).  This is also useful for the main DeLICM pass as
+/// there are less scalars to be mapped.
+bool runForwardOpTree(Scop &S);
 } // namespace polly
 
-namespace llvm {
-void initializeForwardOpTreeWrapperPassPass(PassRegistry &);
-void initializeForwardOpTreePrinterLegacyPassPass(PassRegistry &);
-} // namespace llvm
-
 #endif // POLLY_FORWARDOPTREE_H
diff --git a/polly/include/polly/JSONExporter.h b/polly/include/polly/JSONExporter.h
index 958f95ea11404..82a881c737064 100644
--- a/polly/include/polly/JSONExporter.h
+++ b/polly/include/polly/JSONExporter.h
@@ -9,13 +9,11 @@
 #ifndef POLLY_JSONEXPORTER_H
 #define POLLY_JSONEXPORTER_H
 
+#include "polly/DependenceInfo.h"
 #include "polly/ScopPass.h"
 #include "llvm/IR/PassManager.h"
 
 namespace polly {
-llvm::Pass *createJSONExporterPass();
-llvm::Pass *createJSONImporterPass();
-llvm::Pass *createJSONImporterPrinterLegacyPass(llvm::raw_ostream &OS);
 
 /// This pass exports a scop to a jscop file. The filename is generated from the
 /// concatenation of the function and scop name.
@@ -30,12 +28,9 @@ struct JSONImportPass final : llvm::PassInfoMixin<JSONExportPass> {
   llvm::PreservedAnalyses run(Scop &, ScopAnalysisManager &,
                               ScopStandardAnalysisResults &, SPMUpdater &);
 };
-} // namespace polly
 
-namespace llvm {
-void initializeJSONExporterPass(llvm::PassRegistry &);
-void initializeJSONImporterPass(llvm::PassRegistry &);
-void initializeJSONImporterPrinterLegacyPassPass(llvm::PassRegistry &);
-} // namespace llvm
+void runImportJSON(Scop &S, DependenceAnalysis::Result &DA);
+void runExportJSON(Scop &S);
+} // namespace polly
 
 #endif /* POLLY_JSONEXPORTER_H */
diff --git a/polly/include/polly/LinkAllPasses.h b/polly/include/polly/LinkAllPasses.h
deleted file mode 100644
index 9978344c73e9f..0000000000000
--- a/polly/include/polly/LinkAllPasses.h
+++ /dev/null
@@ -1,156 +0,0 @@
-//===- polly/LinkAllPasses.h ----------- Reference All Passes ---*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// This header file pulls in all transformation and analysis passes for tools
-// like opt and bugpoint that need this functionality.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef POLLY_LINKALLPASSES_H
-#define POLLY_LINKALLPASSES_H
-
-#include "polly/Config/config.h"
-#include "polly/Support/DumpFunctionPass.h"
-#include "polly/Support/DumpModulePass.h"
-#include "llvm/ADT/StringRef.h"
-#include "llvm/Support/AlwaysTrue.h"
-
-namespace llvm {
-class Pass;
-class PassRegistry;
-} // namespace llvm
-
-namespace polly {
-llvm::Pass *createCodePreparationPass();
-llvm::Pass *createScopInlinerPass();
-llvm::Pass *createDeadCodeElimWrapperPass();
-llvm::Pass *createDependenceInfoPass();
-llvm::Pass *createDependenceInfoPrinterLegacyPass(llvm::raw_ostream &OS);
-llvm::Pass *createDependenceInfoWrapperPassPass();
-llvm::Pass *
-createDependenceInfoPrinterLegacyFunctionPass(llvm::raw_ostream &OS);
-llvm::Pass *createDOTOnlyPrinterWrapperPass();
-llvm::Pass *createDOTOnlyViewerWrapperPass();
-llvm::Pass *createDOTPrinterWrapperPass();
-llvm::Pass *createDOTViewerWrapperPass();
-llvm::Pass *createJSONExporterPass();
-llvm::Pass *createJSONImporterPass();
-llvm::Pass *createJSONImporterPrinterLegacyPass(llvm::raw_ostream &OS);
-llvm::Pass *createPollyCanonicalizePass();
-llvm::Pass *createScopDetectionWrapperPassPass();
-llvm::Pass *createScopDetectionPrinterLegacyPass(llvm::raw_ostream &OS);
-llvm::Pass *createScopInfoRegionPassPass();
-llvm::Pass *createScopInfoPrinterLegacyRegionPass(llvm::raw_ostream &OS);
-llvm::Pass *createScopInfoWrapperPassPass();
-llvm::Pass *createScopInfoPrinterLegacyFunctionPass(llvm::raw_ostream &OS);
-llvm::Pass *createIslAstInfoWrapperPassPass();
-llvm::Pass *createIslAstInfoPrinterLegacyPass(llvm::raw_ostream &OS);
-llvm::Pass *createCodeGenerationPass();
-llvm::Pass *createIslScheduleOptimizerWrapperPass();
-llvm::Pass *createIslScheduleOptimizerPrinterLegacyPass(llvm::raw_ostream &OS);
-llvm::Pass *createFlattenSchedulePass();
-llvm::Pass *createFlattenSchedulePrinterLegacyPass(llvm::raw_ostream &OS);
-llvm::Pass *createForwardOpTreeWrapperPass();
-llvm::Pass *createForwardOpTreePrinterLegacyPass(llvm::raw_ostream &OS);
-llvm::Pass *createDeLICMWrapperPass();
-llvm::Pass *createDeLICMPrinterLegacyPass(llvm::raw_ostream &OS);
-llvm::Pass *createMaximalStaticExpansionPass();
-llvm::Pass *createSimplifyWrapperPass(int);
-llvm::Pass *createSimplifyPrinterLegacyPass(llvm::raw_ostream &OS);
-llvm::Pass *createPruneUnprofitableWrapperPass();
-
-extern char &CodePreparationID;
-} // namespace polly
-
-namespace {
-struct PollyForcePassLinking {
-  PollyForcePassLinking() {
-    // We must reference the passes in such a way that compilers will not delete
-    // it all as dead code, even with whole program optimization, yet is
-    // effectively a NO-OP.
-    if (llvm::getNonFoldableAlwaysTrue())
-      return;
-
-    polly::createCodePreparationPass();
-    polly::createDeadCodeElimWrapperPass();
-    polly::createDependenceInfoPass();
-    polly::createDependenceInfoPrinterLegacyPass(llvm::outs());
-    polly::createDependenceInfoWrapperPassPass();
-    polly::createDependenceInfoPrinterLegacyFunctionPass(llvm::outs());
-    polly::createDOTOnlyPrinterWrapperPass();
-    polly::createDOTOnlyViewerWrapperPass();
-    polly::createDOTPrinterWrapperPass();
-    polly::createDOTViewerWrapperPass();
-    polly::createJSONExporterPass();
-    polly::createJSONImporterPass();
-    polly::createJSONImporterPrinterLegacyPass(llvm::outs());
-    polly::createScopDetectionWrapperPassPass();
-    polly::createScopDetectionPrinterLegacyPass(llvm::outs());
-    polly::createScopInfoRegionPassPass();
-    polly::createScopInfoPrinterLegacyRegionPass(llvm::outs());
-    polly::createScopInfoWrapperPassPass();
-    polly::createScopInfoPrinterLegacyFunctionPass(llvm::outs());
-    polly::createPollyCanonicalizePass();
-    polly::createIslAstInfoWrapperPassPass();
-    polly::createIslAstInfoPrinterLegacyPass(llvm::outs());
-    polly::createCodeGenerationPass();
-    polly::createIslScheduleOptimizerWrapperPass();
-    polly::createIslScheduleOptimizerPrinterLegacyPass(llvm::outs());
-    polly::createMaximalStaticExpansionPass();
-    polly::createFlattenSchedulePass();
-    polly::createFlattenSchedulePrinterLegacyPass(llvm::errs());
-    polly::createForwardOpTreeWrapperPass();
-    polly::createForwardOpTreePrinterLegacyPass(llvm::errs());
-    p...
[truncated]

@Meinersbur Meinersbur merged commit 7a0f7db into llvm:main Nov 13, 2025
56 of 64 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants