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
62 lines
1.8 KiB
LLVM
62 lines
1.8 KiB
LLVM
; 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:
|