1; RUN: opt %loadPolly -polly-scops -polly-opt-isl -polly-codegen -polly-scops -polly-codegen -S < %s | FileCheck %s
2; RUN: opt %loadNPMPolly "-passes=scop(polly-opt-isl,polly-codegen,polly-codegen)" -S < %s | FileCheck %s
3; RUN: opt %loadNPMPolly "-passes=scop(polly-opt-isl,polly-codegen),scop(polly-codegen)" -S < %s | FileCheck %s
4;
5; llvm.org/PR34441
6; Properly handle multiple -polly-scops/-polly-codegen in the same
7; RegionPassManager. -polly-codegen must not reuse the -polly-ast analysis the
8; was created for the first -polly-scops pass.
9; The current solution is that only the first -polly-codegen is allowed to
10; generate code, the second detects it is re-using an IslAst that belongs to a
11; different ScopInfo.
12;
13; int a, b, c;
14;
15; int main () {
16;  while (a++)
17;    while (b) {
18;        c = 0;
19;        break;
20;      }
21;  return 0;
22; }
23;
24target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
25
26@a = common global i32 0, align 4
27@b = common global i32 0, align 4
28@c = common global i32 0, align 4
29
30; Function Attrs: nounwind uwtable
31define i32 @main() {
32entry:
33  %retval = alloca i32, align 4
34  store i32 0, i32* %retval, align 4
35  %.pre = load i32, i32* @a, align 4
36  br label %while.cond
37
38while.cond:                                       ; preds = %while.end, %entry
39  %0 = phi i32 [ %inc, %while.end ], [ %.pre, %entry ]
40  %inc = add nsw i32 %0, 1
41  store i32 %inc, i32* @a, align 4
42  %tobool = icmp ne i32 %0, 0
43  br i1 %tobool, label %while.body, label %while.end4
44
45while.body:                                       ; preds = %while.cond
46  %1 = load i32, i32* @b, align 4
47  %tobool2 = icmp ne i32 %1, 0
48  br i1 %tobool2, label %while.body3, label %while.end
49
50while.body3:                                      ; preds = %while.body
51  store i32 0, i32* @c, align 4
52  br label %while.end
53
54while.end:                                        ; preds = %while.body3, %while.body
55  br label %while.cond
56
57while.end4:                                       ; preds = %while.cond
58  ret i32 0
59}
60
61
62; CHECK: polly.start:
63; CHECK-NOT: polly.start:
64