[Polly][NFC] Use factory pattern (#190456)

To (theoretically) reduce coupling of Scop and ScopBuilder.
This commit is contained in:
Michael Kruse 2026-04-04 14:49:13 +02:00 committed by GitHub
parent 6565e08c1e
commit 47d8003948
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 22 additions and 17 deletions

View File

@ -1868,17 +1868,12 @@ private:
ScopDetection::DetectionContext &DC, OptimizationRemarkEmitter &ORE,
int ID);
//@}
/// Return the access for the base ptr of @p MA if any.
MemoryAccess *lookupBasePtrAccess(MemoryAccess *MA);
/// Create an id for @p Param and store it in the ParameterIds map.
void createParameterId(const SCEV *Param);
/// Build the Context of the Scop.
void buildContext();
/// Add the bounds of the parameters to the context.
void addParameterBounds();
@ -1942,6 +1937,12 @@ public:
Scop &operator=(const Scop &) = delete;
~Scop();
/// Factory pattern for creating a new (empty) SCoP.
static std::unique_ptr<Scop> makeScop(Region &R, ScalarEvolution &SE,
LoopInfo &LI, DominatorTree &DT,
ScopDetection::DetectionContext &DC,
OptimizationRemarkEmitter &ORE, int ID);
/// Increment actual number of aliasing assumptions taken
///
/// @param Step Number of new aliasing assumptions which should be added to

View File

@ -3653,8 +3653,8 @@ static void verifyUses(Scop *S, LoopInfo &LI, DominatorTree &DT) {
#endif
void ScopBuilder::buildScop(Region &R, AssumptionCache &AC) {
scop.reset(new Scop(R, SE, LI, DT, *SD.getDetectionContext(&R), ORE,
SD.getNextID()));
scop = Scop::makeScop(R, SE, LI, DT, *SD.getDetectionContext(&R), ORE,
SD.getNextID());
buildStmts(R);

View File

@ -1492,14 +1492,6 @@ bool Scop::isDominatedBy(const DominatorTree &DT, BasicBlock *BB) const {
return DT.dominates(BB, getEntry());
}
void Scop::buildContext() {
isl::space Space = isl::space::params_alloc(getIslCtx(), 0);
Context = isl::set::universe(Space);
InvalidContext = isl::set::empty(Space);
AssumedContext = isl::set::universe(Space);
DefinedBehaviorContext = isl::set::universe(Space);
}
void Scop::addParameterBounds() {
unsigned PDim = 0;
for (auto *Parameter : Parameters) {
@ -1630,8 +1622,20 @@ Scop::Scop(Region &R, ScalarEvolution &ScalarEvolution, LoopInfo &LI,
IslParseFlags);
if (IslOnErrorAbort)
isl_options_set_on_error(getIslCtx().get(), ISL_ON_ERROR_ABORT);
buildContext();
isl_options_set_on_error(IslCtx.get(), ISL_ON_ERROR_ABORT);
isl::space Space = isl::space::params_alloc(getIslCtx(), 0);
Context = isl::set::universe(Space);
InvalidContext = isl::set::empty(Space);
AssumedContext = isl::set::universe(Space);
DefinedBehaviorContext = isl::set::universe(Space);
}
std::unique_ptr<Scop> Scop::makeScop(Region &R, ScalarEvolution &SE,
LoopInfo &LI, DominatorTree &DT,
ScopDetection::DetectionContext &DC,
OptimizationRemarkEmitter &ORE, int ID) {
return std::unique_ptr<Scop>{new Scop(R, SE, LI, DT, DC, ORE, ID)};
}
Scop::~Scop() = default;