Skip to content

Commit 2d950f3

Browse files
committedApr 4, 2017
[Polly][NewPM] Pull references to the legacy PM interface from utilities and helpers
Summary: A couple of the utilities used to analyze or build IR make explicit use of the legacy PM on their interface, to access analysis results. This patch removes the legacy PM from the interface, and just passes the required results directly. This shouldn't introduce any function changes, although the API technically allowed to obtain two different analysis results before, one passed by reference and one through the PM. I don't believe that was ever intended, however. Reviewers: grosser, Meinersbur Reviewed By: grosser Subscribers: nemanjai, pollydev, llvm-commits Tags: #polly Differential Revision: https://reviews.llvm.org/D31653 llvm-svn: 299423
1 parent 43ba525 commit 2d950f3

File tree

8 files changed

+26
-28
lines changed

8 files changed

+26
-28
lines changed
 

‎polly/include/polly/CodeGen/IslNodeBuilder.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ isl_stat addReferencesFromStmt(const ScopStmt *Stmt, void *UserPtr,
6060

6161
class IslNodeBuilder {
6262
public:
63-
IslNodeBuilder(PollyIRBuilder &Builder, ScopAnnotator &Annotator, Pass *P,
63+
IslNodeBuilder(PollyIRBuilder &Builder, ScopAnnotator &Annotator,
6464
const DataLayout &DL, LoopInfo &LI, ScalarEvolution &SE,
6565
DominatorTree &DT, Scop &S, BasicBlock *StartBlock)
6666
: S(S), Builder(Builder), Annotator(Annotator),
6767
ExprBuilder(S, Builder, IDToValue, ValueMap, DL, SE, DT, LI,
6868
StartBlock),
6969
BlockGen(Builder, LI, SE, DT, ScalarMap, EscapeMap, ValueMap,
7070
&ExprBuilder, StartBlock),
71-
RegionGen(BlockGen), P(P), DL(DL), LI(LI), SE(SE), DT(DT),
71+
RegionGen(BlockGen), DL(DL), LI(LI), SE(SE), DT(DT),
7272
StartBlock(StartBlock) {}
7373

7474
virtual ~IslNodeBuilder() = default;
@@ -138,7 +138,6 @@ class IslNodeBuilder {
138138
/// The generator used to copy a non-affine region.
139139
RegionGenerator RegionGen;
140140

141-
Pass *const P;
142141
const DataLayout &DL;
143142
LoopInfo &LI;
144143
ScalarEvolution &SE;

‎polly/include/polly/CodeGen/LoopGenerators.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,8 @@ using namespace llvm;
5050
///
5151
/// @return Value* The newly created induction variable for this loop.
5252
Value *createLoop(Value *LowerBound, Value *UpperBound, Value *Stride,
53-
PollyIRBuilder &Builder, Pass *P, LoopInfo &LI,
54-
DominatorTree &DT, BasicBlock *&ExitBlock,
55-
ICmpInst::Predicate Predicate,
53+
PollyIRBuilder &Builder, LoopInfo &LI, DominatorTree &DT,
54+
BasicBlock *&ExitBlock, ICmpInst::Predicate Predicate,
5655
ScopAnnotator *Annotator = NULL, bool Parallel = false,
5756
bool UseGuard = true);
5857

@@ -99,9 +98,9 @@ Value *createLoop(Value *LowerBound, Value *UpperBound, Value *Stride,
9998
class ParallelLoopGenerator {
10099
public:
101100
/// Create a parallel loop generator for the current function.
102-
ParallelLoopGenerator(PollyIRBuilder &Builder, Pass *P, LoopInfo &LI,
101+
ParallelLoopGenerator(PollyIRBuilder &Builder, LoopInfo &LI,
103102
DominatorTree &DT, const DataLayout &DL)
104-
: Builder(Builder), P(P), LI(LI), DT(DT),
103+
: Builder(Builder), LI(LI), DT(DT),
105104
LongType(
106105
Type::getIntNTy(Builder.getContext(), DL.getPointerSizeInBits())),
107106
M(Builder.GetInsertBlock()->getParent()->getParent()) {}
@@ -131,9 +130,6 @@ class ParallelLoopGenerator {
131130
/// The IR builder we use to create instructions.
132131
PollyIRBuilder &Builder;
133132

134-
/// A pass pointer to update analysis information.
135-
Pass *P;
136-
137133
/// The loop info of the current function we need to update.
138134
LoopInfo &LI;
139135

‎polly/include/polly/CodeGen/Utils.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ namespace llvm {
1717
class Pass;
1818
class Value;
1919
class BasicBlock;
20+
class DominatorTree;
21+
class RegionInfo;
22+
class LoopInfo;
2023
} // namespace llvm
2124

2225
namespace polly {
@@ -55,7 +58,9 @@ class Scop;
5558
/// @param RTC The runtime condition checked before executing the new SCoP.
5659
///
5760
/// @return The 'StartBlock' to which new code can be added.
58-
llvm::BasicBlock *executeScopConditionally(Scop &S, llvm::Pass *P,
59-
llvm::Value *RTC);
61+
llvm::BasicBlock *executeScopConditionally(Scop &S, llvm::Value *RTC,
62+
llvm::DominatorTree &DT,
63+
llvm::RegionInfo &RI,
64+
llvm::LoopInfo &LI);
6065
} // namespace polly
6166
#endif

‎polly/lib/CodeGen/CodeGeneration.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,10 @@ class CodeGeneration : public ScopPass {
145145
// which may introduce scalar dependences that prevent us from correctly
146146
// code generating this scop.
147147
BasicBlock *StartBlock =
148-
executeScopConditionally(S, this, Builder.getTrue());
148+
executeScopConditionally(S, Builder.getTrue(), *DT, *RI, *LI);
149149
auto *SplitBlock = StartBlock->getSinglePredecessor();
150150

151-
IslNodeBuilder NodeBuilder(Builder, Annotator, this, *DL, *LI, *SE, *DT, S,
151+
IslNodeBuilder NodeBuilder(Builder, Annotator, *DL, *LI, *SE, *DT, S,
152152
StartBlock);
153153

154154
if (PerfMonitoring) {

‎polly/lib/CodeGen/IslNodeBuilder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ void IslNodeBuilder::createForSequential(__isl_take isl_ast_node *For,
498498
// omit the GuardBB in front of the loop.
499499
bool UseGuardBB =
500500
!SE.isKnownPredicate(Predicate, SE.getSCEV(ValueLB), SE.getSCEV(ValueUB));
501-
IV = createLoop(ValueLB, ValueUB, ValueInc, Builder, P, LI, DT, ExitBlock,
501+
IV = createLoop(ValueLB, ValueUB, ValueInc, Builder, LI, DT, ExitBlock,
502502
Predicate, &Annotator, Parallel, UseGuardBB);
503503
IDToValue[IteratorID] = IV;
504504

@@ -625,7 +625,7 @@ void IslNodeBuilder::createForParallel(__isl_take isl_ast_node *For) {
625625
}
626626

627627
ValueMapT NewValues;
628-
ParallelLoopGenerator ParallelLoopGen(Builder, P, LI, DT, DL);
628+
ParallelLoopGenerator ParallelLoopGen(Builder, LI, DT, DL);
629629

630630
IV = ParallelLoopGen.createParallelLoop(ValueLB, ValueUB, ValueInc,
631631
SubtreeValues, NewValues, &LoopBody);

‎polly/lib/CodeGen/LoopGenerators.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static cl::opt<int>
5050
// 'polly.indvar_next' as well as the condition to check if we execute another
5151
// iteration of the loop. After the loop has finished, we branch to ExitBB.
5252
Value *polly::createLoop(Value *LB, Value *UB, Value *Stride,
53-
PollyIRBuilder &Builder, Pass *P, LoopInfo &LI,
53+
PollyIRBuilder &Builder, LoopInfo &LI,
5454
DominatorTree &DT, BasicBlock *&ExitBB,
5555
ICmpInst::Predicate Predicate,
5656
ScopAnnotator *Annotator, bool Parallel,
@@ -360,7 +360,7 @@ Value *ParallelLoopGenerator::createSubFn(Value *Stride, AllocaInst *StructData,
360360

361361
Builder.CreateBr(CheckNextBB);
362362
Builder.SetInsertPoint(&*--Builder.GetInsertPoint());
363-
IV = createLoop(LB, UB, Stride, Builder, P, LI, DT, AfterBB,
363+
IV = createLoop(LB, UB, Stride, Builder, LI, DT, AfterBB,
364364
ICmpInst::ICMP_SLE, nullptr, true, /* UseGuard */ false);
365365

366366
BasicBlock::iterator LoopBody = Builder.GetInsertPoint();

‎polly/lib/CodeGen/PPCGCodeGeneration.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,11 @@ static __isl_give isl_id_to_ast_expr *pollyBuildAstExprForStmt(
143143
/// @see GPUNodeBuilder::createUser
144144
class GPUNodeBuilder : public IslNodeBuilder {
145145
public:
146-
GPUNodeBuilder(PollyIRBuilder &Builder, ScopAnnotator &Annotator, Pass *P,
146+
GPUNodeBuilder(PollyIRBuilder &Builder, ScopAnnotator &Annotator,
147147
const DataLayout &DL, LoopInfo &LI, ScalarEvolution &SE,
148148
DominatorTree &DT, Scop &S, BasicBlock *StartBlock,
149149
gpu_prog *Prog)
150-
: IslNodeBuilder(Builder, Annotator, P, DL, LI, SE, DT, S, StartBlock),
150+
: IslNodeBuilder(Builder, Annotator, DL, LI, SE, DT, S, StartBlock),
151151
Prog(Prog) {
152152
getExprBuilder().setIDToSAI(&IDToSAI);
153153
}
@@ -1543,7 +1543,6 @@ void GPUNodeBuilder::createKernelFunction(ppcg_kernel *Kernel,
15431543
BasicBlock *PrevBlock = Builder.GetInsertBlock();
15441544
auto EntryBlock = BasicBlock::Create(Builder.getContext(), "entry", FN);
15451545

1546-
DominatorTree &DT = P->getAnalysis<DominatorTreeWrapperPass>().getDomTree();
15471546
DT.addNewBlock(EntryBlock, PrevBlock);
15481547

15491548
Builder.SetInsertPoint(EntryBlock);
@@ -2403,9 +2402,9 @@ class PPCGCodeGeneration : public ScopPass {
24032402
// which may introduce scalar dependences that prevent us from correctly
24042403
// code generating this scop.
24052404
BasicBlock *StartBlock =
2406-
executeScopConditionally(*S, this, Builder.getTrue());
2405+
executeScopConditionally(*S, Builder.getTrue(), *DT, *RI, *LI);
24072406

2408-
GPUNodeBuilder NodeBuilder(Builder, Annotator, this, *DL, *LI, *SE, *DT, *S,
2407+
GPUNodeBuilder NodeBuilder(Builder, Annotator, *DL, *LI, *SE, *DT, *S,
24092408
StartBlock, Prog);
24102409

24112410
// TODO: Handle LICM

‎polly/lib/CodeGen/Utils.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,11 @@ static BasicBlock *splitEdge(BasicBlock *Prev, BasicBlock *Succ,
7676
return MiddleBlock;
7777
}
7878

79-
BasicBlock *polly::executeScopConditionally(Scop &S, Pass *P, Value *RTC) {
79+
BasicBlock *polly::executeScopConditionally(Scop &S, Value *RTC,
80+
DominatorTree &DT, RegionInfo &RI,
81+
LoopInfo &LI) {
8082
Region &R = S.getRegion();
8183
PollyIRBuilder Builder(S.getEntry());
82-
DominatorTree &DT = P->getAnalysis<DominatorTreeWrapperPass>().getDomTree();
83-
RegionInfo &RI = P->getAnalysis<RegionInfoPass>().getRegionInfo();
84-
LoopInfo &LI = P->getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
8584

8685
// Before:
8786
//

0 commit comments

Comments
 (0)
Please sign in to comment.