summaryrefslogtreecommitdiffstats
path: root/polly/lib/CodeGen/CodeGeneration.cpp
diff options
context:
space:
mode:
authorMichael Kruse <llvm@meinersbur.de>2017-09-21 00:01:13 +0000
committerMichael Kruse <llvm@meinersbur.de>2017-09-21 00:01:13 +0000
commit0e370cf1a767efd8d55c346df995df6d43e3ff7f (patch)
treeb97e897546127f40bf18425be390acb93efc5736 /polly/lib/CodeGen/CodeGeneration.cpp
parentf681a8fa3a7bd46edee8d0483c72f2a05794b2fd (diff)
downloadbcm5719-llvm-0e370cf1a767efd8d55c346df995df6d43e3ff7f.tar.gz
bcm5719-llvm-0e370cf1a767efd8d55c346df995df6d43e3ff7f.zip
Check whether IslAstInfo and DependenceInfo were computed for the same Scop.
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. This would be unfortunate because DependenceInfo and IslAstInfo hold references to resources allocated by ScopInfo/ScopBuilder/Scop (e.g. isl_id). If -polly-codegen and DependenceInfo/IslAstInfo do not agree on which Scop to use, unpredictable things can happen. 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 address not reused as long there is a DependenceInfo or IslAstInfo around. This fixes llvm.org/PR34441 llvm-svn: 313842
Diffstat (limited to 'polly/lib/CodeGen/CodeGeneration.cpp')
-rw-r--r--polly/lib/CodeGen/CodeGeneration.cpp21
1 files changed, 20 insertions, 1 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;
OpenPOWER on IntegriCloud