[polly] Don't count scops in a global variable.

This can cause issues with thread safety.

Differential Revision: https://reviews.llvm.org/D75089
This commit is contained in:
Eli Friedman 2020-02-24 15:40:06 -08:00
parent fe210a1ff2
commit 888b12b270
4 changed files with 9 additions and 26 deletions

View file

@ -185,6 +185,9 @@ public:
int MaxDepth; int MaxDepth;
}; };
int NextScopID = 0;
int getNextID() { return NextScopID++; }
private: private:
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//

View file

@ -1709,12 +1709,6 @@ private:
/// The name of the SCoP (identical to the regions name) /// The name of the SCoP (identical to the regions name)
Optional<std::string> name; Optional<std::string> name;
/// The ID to be assigned to the next Scop in a function
static int NextScopID;
/// The name of the function currently under consideration
static std::string CurrentFunc;
// Access functions of the SCoP. // Access functions of the SCoP.
// //
// This owns all the MemoryAccess objects of the Scop created in this pass. // This owns all the MemoryAccess objects of the Scop created in this pass.
@ -1899,12 +1893,10 @@ private:
DenseMap<const ScopArrayInfo *, SmallVector<MemoryAccess *, 4>> DenseMap<const ScopArrayInfo *, SmallVector<MemoryAccess *, 4>>
PHIIncomingAccs; PHIIncomingAccs;
/// Return the ID for a new Scop within a function
static int getNextID(std::string ParentFunc);
/// Scop constructor; invoked from ScopBuilder::buildScop. /// Scop constructor; invoked from ScopBuilder::buildScop.
Scop(Region &R, ScalarEvolution &SE, LoopInfo &LI, DominatorTree &DT, Scop(Region &R, ScalarEvolution &SE, LoopInfo &LI, DominatorTree &DT,
ScopDetection::DetectionContext &DC, OptimizationRemarkEmitter &ORE); ScopDetection::DetectionContext &DC, OptimizationRemarkEmitter &ORE,
int ID);
//@} //@}

View file

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

View file

@ -1692,25 +1692,12 @@ isl::set Scop::getDomainConditions(BasicBlock *BB) const {
return getDomainConditions(BBR->getEntry()); return getDomainConditions(BBR->getEntry());
} }
int Scop::NextScopID = 0;
std::string Scop::CurrentFunc;
int Scop::getNextID(std::string ParentFunc) {
if (ParentFunc != CurrentFunc) {
CurrentFunc = ParentFunc;
NextScopID = 0;
}
return NextScopID++;
}
Scop::Scop(Region &R, ScalarEvolution &ScalarEvolution, LoopInfo &LI, Scop::Scop(Region &R, ScalarEvolution &ScalarEvolution, LoopInfo &LI,
DominatorTree &DT, ScopDetection::DetectionContext &DC, DominatorTree &DT, ScopDetection::DetectionContext &DC,
OptimizationRemarkEmitter &ORE) OptimizationRemarkEmitter &ORE, int ID)
: IslCtx(isl_ctx_alloc(), isl_ctx_free), SE(&ScalarEvolution), DT(&DT), : IslCtx(isl_ctx_alloc(), isl_ctx_free), SE(&ScalarEvolution), DT(&DT),
R(R), name(None), HasSingleExitEdge(R.getExitingBlock()), DC(DC), R(R), name(None), HasSingleExitEdge(R.getExitingBlock()), DC(DC),
ORE(ORE), Affinator(this, LI), ORE(ORE), Affinator(this, LI), ID(ID) {
ID(getNextID((*R.getEntry()->getParent()).getName().str())) {
if (IslOnErrorAbort) if (IslOnErrorAbort)
isl_options_set_on_error(getIslCtx().get(), ISL_ON_ERROR_ABORT); isl_options_set_on_error(getIslCtx().get(), ISL_ON_ERROR_ABORT);
buildContext(); buildContext();