summaryrefslogtreecommitdiffstats
path: root/polly/lib
diff options
context:
space:
mode:
Diffstat (limited to 'polly/lib')
-rw-r--r--polly/lib/CodeGen/CodeGeneration.cpp21
-rw-r--r--polly/lib/CodeGen/IslAst.cpp8
-rw-r--r--polly/lib/Transform/ScheduleOptimizer.cpp5
3 files changed, 32 insertions, 2 deletions
diff --git a/polly/lib/CodeGen/CodeGeneration.cpp b/polly/lib/CodeGen/CodeGeneration.cpp
index 240ce23c1b4..41a3b2fcf6a 100644
--- a/polly/lib/CodeGen/CodeGeneration.cpp
+++ b/polly/lib/CodeGen/CodeGeneration.cpp
@@ -182,8 +182,27 @@ static void removeLifetimeMarkers(Region *R) {
static bool CodeGen(Scop &S, IslAstInfo &AI, LoopInfo &LI, DominatorTree &DT,
ScalarEvolution &SE, RegionInfo &RI) {
+ // Check whether IslAstInfo uses the same isl_ctx. Since -polly-codegen
+ // reports itself to preserve DependenceInfo and IslAstInfo, we might get
+ // those analysis that were computed by a different ScopInfo for a different
+ // Scop structure. When the ScopInfo/Scop object is freed, there is a high
+ // probability that the new ScopInfo/Scop object will be created at the same
+ // heap position with the same address. Comparing whether the Scop or ScopInfo
+ // address is the expected therefore is unreliable.
+ // Instead, we compare the address of the isl_ctx object. Both, DependenceInfo
+ // and IslAstInfo must hold a reference to the isl_ctx object to ensure it is
+ // not freed before the destruction of those analyses which might happen after
+ // the destruction of the Scop/ScopInfo they refer to. Hence, the isl_ctx
+ // will not be freed and its space not reused as long there is a
+ // DependenceInfo or IslAstInfo around.
+ IslAst &Ast = AI.getIslAst();
+ if (Ast.getSharedIslCtx() != S.getSharedIslCtx()) {
+ DEBUG(dbgs() << "Got an IstAst for a different Scop/isl_ctx\n");
+ return false;
+ }
+
// Check if we created an isl_ast root node, otherwise exit.
- isl_ast_node *AstRoot = AI.getAst();
+ isl_ast_node *AstRoot = Ast.getAst();
if (!AstRoot)
return false;
diff --git a/polly/lib/CodeGen/IslAst.cpp b/polly/lib/CodeGen/IslAst.cpp
index 3c67cc7ed10..346e14f496b 100644
--- a/polly/lib/CodeGen/IslAst.cpp
+++ b/polly/lib/CodeGen/IslAst.cpp
@@ -806,6 +806,12 @@ bool IslAstInfoWrapperPass::runOnScop(Scop &Scop) {
const Dependences &D =
getAnalysis<DependenceInfo>().getDependences(Dependences::AL_Statement);
+ if (D.getSharedIslCtx() != Scop.getSharedIslCtx()) {
+ DEBUG(dbgs() << "Got dependence analysis for different SCoP/isl_ctx\n");
+ Ast.reset();
+ return false;
+ }
+
Ast.reset(new IslAstInfo(Scop, D));
DEBUG(printScop(dbgs(), Scop));
@@ -815,7 +821,7 @@ bool IslAstInfoWrapperPass::runOnScop(Scop &Scop) {
void IslAstInfoWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const {
// Get the Common analysis usage of ScopPasses.
ScopPass::getAnalysisUsage(AU);
- AU.addRequired<ScopInfoRegionPass>();
+ AU.addRequiredTransitive<ScopInfoRegionPass>();
AU.addRequired<DependenceInfo>();
AU.addPreserved<DependenceInfo>();
diff --git a/polly/lib/Transform/ScheduleOptimizer.cpp b/polly/lib/Transform/ScheduleOptimizer.cpp
index 0a2fe8b6897..899f1c06830 100644
--- a/polly/lib/Transform/ScheduleOptimizer.cpp
+++ b/polly/lib/Transform/ScheduleOptimizer.cpp
@@ -1485,6 +1485,11 @@ bool IslScheduleOptimizer::runOnScop(Scop &S) {
const Dependences &D =
getAnalysis<DependenceInfo>().getDependences(Dependences::AL_Statement);
+ if (D.getSharedIslCtx() != S.getSharedIslCtx()) {
+ DEBUG(dbgs() << "DependenceInfo for another SCoP/isl_ctx\n");
+ return false;
+ }
+
if (!D.hasValidDependences())
return false;
OpenPOWER on IntegriCloud