[llvm-branch-commits] [polly] [Polly] Introduce PhaseManager and remove LPM support (PR #125442)

Karthika Devi C via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Apr 8 22:02:14 PDT 2025


================
@@ -16,105 +16,50 @@
 //===----------------------------------------------------------------------===//
 
 #include "polly/CodePreparation.h"
-#include "polly/LinkAllPasses.h"
 #include "polly/Support/ScopHelper.h"
 #include "llvm/Analysis/DominanceFrontier.h"
 #include "llvm/Analysis/LoopInfo.h"
 #include "llvm/Analysis/RegionInfo.h"
 #include "llvm/Analysis/ScalarEvolution.h"
-#include "llvm/InitializePasses.h"
 
 using namespace llvm;
 using namespace polly;
 
-namespace {
-
-/// Prepare the IR for the scop detection.
-///
-class CodePreparation final : public FunctionPass {
-  CodePreparation(const CodePreparation &) = delete;
-  const CodePreparation &operator=(const CodePreparation &) = delete;
-
-  LoopInfo *LI;
-  ScalarEvolution *SE;
-
-  void clear();
-
-public:
-  static char ID;
-
-  explicit CodePreparation() : FunctionPass(ID) {}
-  ~CodePreparation();
-
-  /// @name FunctionPass interface.
-  //@{
-  void getAnalysisUsage(AnalysisUsage &AU) const override;
-  void releaseMemory() override;
-  bool runOnFunction(Function &F) override;
-  void print(raw_ostream &OS, const Module *) const override;
-  //@}
-};
-} // namespace
-
-PreservedAnalyses CodePreparationPass::run(Function &F,
-                                           FunctionAnalysisManager &FAM) {
-
+static bool runCodePreprationImpl(Function &F, DominatorTree *DT, LoopInfo *LI,
+                                  RegionInfo *RI) {
   // Find first non-alloca instruction. Every basic block has a non-alloca
   // instruction, as every well formed basic block has a terminator.
   auto &EntryBlock = F.getEntryBlock();
   BasicBlock::iterator I = EntryBlock.begin();
   while (isa<AllocaInst>(I))
     ++I;
 
-  auto &DT = FAM.getResult<DominatorTreeAnalysis>(F);
-  auto &LI = FAM.getResult<LoopAnalysis>(F);
+  // Abort if not necessary to split
+  if (I->isTerminator() && isa<BranchInst>(I) &&
+      cast<BranchInst>(I)->isUnconditional())
+    return false;
 
   // splitBlock updates DT, LI and RI.
-  splitEntryBlockForAlloca(&EntryBlock, &DT, &LI, nullptr);
----------------
kartcq wrote:

Can we please move CodePreparation pass changes to separate commit.
This will make the these changes more trackable.

https://github.com/llvm/llvm-project/pull/125442


More information about the llvm-branch-commits mailing list