Recommit "[SCCP] Remove legacy SCCP pass."
authorFlorian Hahn <flo@fhahn.com>
Fri, 24 Feb 2023 12:47:30 +0000 (13:47 +0100)
committerFlorian Hahn <flo@fhahn.com>
Fri, 24 Feb 2023 12:47:31 +0000 (13:47 +0100)
This reverts commit a9a1950115d7db95c7439128b14af2cefe8f796d.

The legacy PM uses in Polly have been removed, so recommit the patch.

Original message:
    This is part of the optimization pipeline, of which the legacy pass manager version is deprecated.

    Reviewed By: aeubanks

    Differential Revision: https://reviews.llvm.org/D144201

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/LinkAllPasses.h
llvm/include/llvm/Transforms/Scalar.h
llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
llvm/lib/Transforms/Scalar/SCCP.cpp
llvm/lib/Transforms/Scalar/Scalar.cpp

index 57069c1..ff21c35 100644 (file)
@@ -111,11 +111,6 @@ external add_reassociation
   : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit
   = "llvm_add_reassociation"
 
-(** See the [llvm::createSCCPPass] function. *)
-external add_sccp
-  : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit
-  = "llvm_add_sccp"
-
 (** See the [llvm::createSROAPass] function. *)
 external add_scalar_repl_aggregation
   : [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit
index 304e87a..a804169 100644 (file)
@@ -140,12 +140,6 @@ value llvm_add_reassociation(LLVMPassManagerRef PM) {
 }
 
 /* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
-value llvm_add_sccp(LLVMPassManagerRef PM) {
-  LLVMAddSCCPPass(PM);
-  return Val_unit;
-}
-
-/* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
 value llvm_add_scalar_repl_aggregates(LLVMPassManagerRef PM) {
   LLVMAddScalarReplAggregatesPass(PM);
   return Val_unit;
index 020af80..8eefe7b 100644 (file)
@@ -94,9 +94,6 @@ void LLVMAddPartiallyInlineLibCallsPass(LLVMPassManagerRef PM);
 /** See llvm::createReassociatePass function. */
 void LLVMAddReassociatePass(LLVMPassManagerRef PM);
 
-/** See llvm::createSCCPPass function. */
-void LLVMAddSCCPPass(LLVMPassManagerRef PM);
-
 /** See llvm::createSROAPass function. */
 void LLVMAddScalarReplAggregatesPass(LLVMPassManagerRef PM);
 
index 6681082..8f07acd 100644 (file)
@@ -134,7 +134,6 @@ namespace {
       (void) llvm::createRegionOnlyViewerPass();
       (void) llvm::createRegionPrinterPass();
       (void) llvm::createRegionViewerPass();
-      (void) llvm::createSCCPPass();
       (void) llvm::createSafeStackPass();
       (void) llvm::createSROAPass();
       (void) llvm::createSingleLoopExtractorPass();
index 8770eec..825d70e 100644 (file)
@@ -33,12 +33,6 @@ FunctionPass *createAlignmentFromAssumptionsPass();
 
 //===----------------------------------------------------------------------===//
 //
-// SCCP - Sparse conditional constant propagation.
-//
-FunctionPass *createSCCPPass();
-
-//===----------------------------------------------------------------------===//
-//
 // RedundantDbgInstElimination - This pass removes redundant dbg intrinsics
 // without modifying the CFG of the function.  It is a FunctionPass.
 //
index 6312217..ed394a1 100644 (file)
@@ -166,7 +166,6 @@ void PassManagerBuilder::addFunctionSimplificationPasses(
     MPM.add(createMergedLoadStoreMotionPass()); // Merge ld/st in diamonds
     MPM.add(createGVNPass(DisableGVNLoadPRE));  // Remove redundancies
   }
-  MPM.add(createSCCPPass());                  // Constant prop with SCCP
 
   // Delete dead bit computations (instcombine runs after to fold away the dead
   // computations, and then ADCE will run later to exploit any new DCE
@@ -235,7 +234,6 @@ void PassManagerBuilder::addVectorPasses(legacy::PassManagerBase &PM,
                                          .sinkCommonInsts(true)));
 
   if (IsFullLTO) {
-    PM.add(createSCCPPass());                 // Propagate exposed constants
     PM.add(createInstructionCombiningPass()); // Clean up again
     PM.add(createBitTrackingDCEPass());
   }
index 7b396c6..fcdc503 100644 (file)
@@ -41,7 +41,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/Debug.h"
@@ -136,54 +135,3 @@ PreservedAnalyses SCCPPass::run(Function &F, FunctionAnalysisManager &AM) {
   PA.preserve<DominatorTreeAnalysis>();
   return PA;
 }
-
-namespace {
-
-//===--------------------------------------------------------------------===//
-//
-/// SCCP Class - This class uses the SCCPSolver to implement a per-function
-/// Sparse Conditional Constant Propagator.
-///
-class SCCPLegacyPass : public FunctionPass {
-public:
-  // Pass identification, replacement for typeid
-  static char ID;
-
-  SCCPLegacyPass() : FunctionPass(ID) {
-    initializeSCCPLegacyPassPass(*PassRegistry::getPassRegistry());
-  }
-
-  void getAnalysisUsage(AnalysisUsage &AU) const override {
-    AU.addRequired<TargetLibraryInfoWrapperPass>();
-    AU.addPreserved<GlobalsAAWrapperPass>();
-    AU.addPreserved<DominatorTreeWrapperPass>();
-  }
-
-  // runOnFunction - Run the Sparse Conditional Constant Propagation
-  // algorithm, and return true if the function was modified.
-  bool runOnFunction(Function &F) override {
-    if (skipFunction(F))
-      return false;
-    const DataLayout &DL = F.getParent()->getDataLayout();
-    const TargetLibraryInfo *TLI =
-        &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(F);
-    auto *DTWP = getAnalysisIfAvailable<DominatorTreeWrapperPass>();
-    DomTreeUpdater DTU(DTWP ? &DTWP->getDomTree() : nullptr,
-                       DomTreeUpdater::UpdateStrategy::Lazy);
-    return runSCCP(F, DL, TLI, DTU);
-  }
-};
-
-} // end anonymous namespace
-
-char SCCPLegacyPass::ID = 0;
-
-INITIALIZE_PASS_BEGIN(SCCPLegacyPass, "sccp",
-                      "Sparse Conditional Constant Propagation", false, false)
-INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass)
-INITIALIZE_PASS_END(SCCPLegacyPass, "sccp",
-                    "Sparse Conditional Constant Propagation", false, false)
-
-// createSCCPPass - This is the public interface to this file.
-FunctionPass *llvm::createSCCPPass() { return new SCCPLegacyPass(); }
-
index 38c2bff..a7fe494 100644 (file)
@@ -82,7 +82,6 @@ void llvm::initializeScalarOpts(PassRegistry &Registry) {
   initializeRegToMemLegacyPass(Registry);
   initializeRewriteStatepointsForGCLegacyPassPass(Registry);
   initializeScalarizeMaskedMemIntrinLegacyPassPass(Registry);
-  initializeSCCPLegacyPassPass(Registry);
   initializeSROALegacyPassPass(Registry);
   initializeCFGSimplifyPassPass(Registry);
   initializeStructurizeCFGLegacyPassPass(Registry);
@@ -191,10 +190,6 @@ void LLVMAddReassociatePass(LLVMPassManagerRef PM) {
   unwrap(PM)->add(createReassociatePass());
 }
 
-void LLVMAddSCCPPass(LLVMPassManagerRef PM) {
-  unwrap(PM)->add(createSCCPPass());
-}
-
 void LLVMAddScalarReplAggregatesPass(LLVMPassManagerRef PM) {
   unwrap(PM)->add(createSROAPass());
 }