summaryrefslogtreecommitdiffstats
path: root/polly/test/Isl/CodeGen
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/test/Isl/CodeGen
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/test/Isl/CodeGen')
-rw-r--r--polly/test/Isl/CodeGen/multiple-codegens.ll61
1 files changed, 61 insertions, 0 deletions
diff --git a/polly/test/Isl/CodeGen/multiple-codegens.ll b/polly/test/Isl/CodeGen/multiple-codegens.ll
new file mode 100644
index 00000000000..b9bfb55e041
--- /dev/null
+++ b/polly/test/Isl/CodeGen/multiple-codegens.ll
@@ -0,0 +1,61 @@
+; RUN: opt %loadPolly -polly-scops -polly-opt-isl -polly-codegen -polly-scops -polly-codegen -S < %s | FileCheck %s
+;
+; llvm.org/PR34441
+; Properly handle multiple -polly-scops/-polly-codegen in the same
+; RegionPassManager. -polly-codegen must not reuse the -polly-ast analysis the
+; was created for the first -polly-scops pass.
+; The current solution is that only the first -polly-codegen is allowed to
+; generate code, the second detects it is re-using an IslAst that belongs to a
+; different ScopInfo.
+;
+; int a, b, c;
+;
+; int main () {
+; while (a++)
+; while (b) {
+; c = 0;
+; break;
+; }
+; return 0;
+; }
+;
+target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
+
+@a = common global i32 0, align 4
+@b = common global i32 0, align 4
+@c = common global i32 0, align 4
+
+; Function Attrs: nounwind uwtable
+define i32 @main() {
+entry:
+ %retval = alloca i32, align 4
+ store i32 0, i32* %retval, align 4
+ %.pre = load i32, i32* @a, align 4
+ br label %while.cond
+
+while.cond: ; preds = %while.end, %entry
+ %0 = phi i32 [ %inc, %while.end ], [ %.pre, %entry ]
+ %inc = add nsw i32 %0, 1
+ store i32 %inc, i32* @a, align 4
+ %tobool = icmp ne i32 %0, 0
+ br i1 %tobool, label %while.body, label %while.end4
+
+while.body: ; preds = %while.cond
+ %1 = load i32, i32* @b, align 4
+ %tobool2 = icmp ne i32 %1, 0
+ br i1 %tobool2, label %while.body3, label %while.end
+
+while.body3: ; preds = %while.body
+ store i32 0, i32* @c, align 4
+ br label %while.end
+
+while.end: ; preds = %while.body3, %while.body
+ br label %while.cond
+
+while.end4: ; preds = %while.cond
+ ret i32 0
+}
+
+
+; CHECK: polly.start:
+; CHECK-NOT: polly.start:
OpenPOWER on IntegriCloud