From b4f08eb671643f96d837cebd3d9183a38f806308 Mon Sep 17 00:00:00 2001 From: Johannes Doerfert Date: Mon, 23 Feb 2015 13:51:35 +0000 Subject: [PATCH] [REFACTOR] Replace Pass* from BlockGen by the DomTree llvm-svn: 230220 --- polly/include/polly/CodeGen/BlockGenerators.h | 11 ++++++----- polly/lib/CodeGen/BlockGenerators.cpp | 17 ++++++----------- polly/lib/CodeGen/IslCodeGeneration.cpp | 2 +- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/polly/include/polly/CodeGen/BlockGenerators.h b/polly/include/polly/CodeGen/BlockGenerators.h index 6ccf801772aa..77522ab0e84d 100644 --- a/polly/include/polly/CodeGen/BlockGenerators.h +++ b/polly/include/polly/CodeGen/BlockGenerators.h @@ -72,13 +72,12 @@ public: /// @param Builder The LLVM-IR Builder used to generate the statement. The /// code is generated at the location, the Builder points /// to. - /// @param P A reference to the pass this function is called from. - /// The pass is needed to update other analysis. /// @param LI The loop info for the current function /// @param SE The scalar evolution info for the current function + /// @param DT The dominator tree of this function. /// @param ExprBuilder An expression builder to generate new access functions. - BlockGenerator(PollyIRBuilder &Builder, Pass *P, LoopInfo &LI, - ScalarEvolution &SE, IslExprBuilder *ExprBuilder = nullptr); + BlockGenerator(PollyIRBuilder &Builder, LoopInfo &LI, ScalarEvolution &SE, + DominatorTree &DT, IslExprBuilder *ExprBuilder = nullptr); /// @brief Copy the basic block. /// @@ -94,11 +93,13 @@ public: protected: PollyIRBuilder &Builder; - Pass *P; LoopInfo &LI; ScalarEvolution &SE; IslExprBuilder *ExprBuilder; + /// @brief The dominator tree of this function. + DominatorTree &DT; + /// @brief Get the new version of a value. /// /// Given an old value, we first check if a new version of this value is diff --git a/polly/lib/CodeGen/BlockGenerators.cpp b/polly/lib/CodeGen/BlockGenerators.cpp index a0025698335d..8b6abf1a8c51 100644 --- a/polly/lib/CodeGen/BlockGenerators.cpp +++ b/polly/lib/CodeGen/BlockGenerators.cpp @@ -76,9 +76,10 @@ bool polly::isIgnoredIntrinsic(const Value *V) { return false; } -BlockGenerator::BlockGenerator(PollyIRBuilder &B, Pass *P, LoopInfo &LI, - ScalarEvolution &SE, IslExprBuilder *ExprBuilder) - : Builder(B), P(P), LI(LI), SE(SE), ExprBuilder(ExprBuilder) {} +BlockGenerator::BlockGenerator(PollyIRBuilder &B, LoopInfo &LI, + ScalarEvolution &SE, DominatorTree &DT, + IslExprBuilder *ExprBuilder) + : Builder(B), LI(LI), SE(SE), ExprBuilder(ExprBuilder), DT(DT) {} Value *BlockGenerator::getNewValue(ScopStmt &Stmt, const Value *Old, ValueMapT &BBMap, ValueMapT &GlobalMap, @@ -285,12 +286,9 @@ void BlockGenerator::copyInstruction(ScopStmt &Stmt, const Instruction *Inst, void BlockGenerator::copyBB(ScopStmt &Stmt, ValueMapT &GlobalMap, LoopToScevMapT <S) { - auto *DTWP = P->getAnalysisIfAvailable(); - auto *DT = DTWP ? &DTWP->getDomTree() : nullptr; - BasicBlock *BB = Stmt.getBasicBlock(); BasicBlock *CopyBB = - SplitBlock(Builder.GetInsertBlock(), Builder.GetInsertPoint(), DT, &LI); + SplitBlock(Builder.GetInsertBlock(), Builder.GetInsertPoint(), &DT, &LI); CopyBB->setName("polly.stmt." + BB->getName()); Builder.SetInsertPoint(CopyBB->begin()); @@ -623,12 +621,9 @@ void VectorBlockGenerator::copyInstruction(ScopStmt &Stmt, } void VectorBlockGenerator::copyBB(ScopStmt &Stmt) { - auto *DTWP = P->getAnalysisIfAvailable(); - auto *DT = DTWP ? &DTWP->getDomTree() : nullptr; - BasicBlock *BB = Stmt.getBasicBlock(); BasicBlock *CopyBB = - SplitBlock(Builder.GetInsertBlock(), Builder.GetInsertPoint(), DT, &LI); + SplitBlock(Builder.GetInsertBlock(), Builder.GetInsertPoint(), &DT, &LI); CopyBB->setName("polly.stmt." + BB->getName()); Builder.SetInsertPoint(CopyBB->begin()); diff --git a/polly/lib/CodeGen/IslCodeGeneration.cpp b/polly/lib/CodeGen/IslCodeGeneration.cpp index e2f81dbf3444..007a4fce2afb 100644 --- a/polly/lib/CodeGen/IslCodeGeneration.cpp +++ b/polly/lib/CodeGen/IslCodeGeneration.cpp @@ -65,7 +65,7 @@ public: : S(S), Builder(Builder), Annotator(Annotator), Rewriter(new SCEVExpander(SE, "polly")), ExprBuilder(Builder, IDToValue, *Rewriter), - BlockGen(Builder, P, LI, SE, &ExprBuilder), P(P), DL(DL), LI(LI), + BlockGen(Builder, LI, SE, DT, &ExprBuilder), P(P), DL(DL), LI(LI), SE(SE), DT(DT) {} ~IslNodeBuilder() { delete Rewriter; }