xref: /llvm-project/polly/test/ScopDetectionDiagnostics/ReportLoopHasNoExit.ll (revision 5aafc6d58f3405662902cee006be11e599801b88)
1; XFAIL: *
2
3; The test case stopped making sense after r310940 that added infinite loops to
4; the PostDominatorTree. Infinite loops are postdominated only by the virtual
5; root, which causes them not to appear in regions in ScopDetection anymore.
6
7; RUN: opt %loadNPMPolly -pass-remarks-missed="polly-detect" -polly-allow-nonaffine-loops '-passes=print<polly-detect>' -disable-output < %s 2>&1 | FileCheck %s
8; RUN: opt %loadNPMPolly -pass-remarks-missed="polly-detect" -polly-allow-nonaffine-loops=false '-passes=print<polly-detect>' -disable-output < %s 2>&1 | FileCheck %s
9
10; void func (int param0, int N, int *A)
11; {
12;   for (int i = 0; i < N; i++)
13;     if (param0)
14;       while (1)
15;         A[i] = 1;
16;     else
17;      A[i] = 2;
18; }
19
20; CHECK: remark: ReportLoopHasNoExit.c:7:7: Loop cannot be handled because it has no exit.
21
22
23
24target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
25
26; Function Attrs: nounwind uwtable
27define void @func(i32 %param0, i32 %N, ptr %A) #0 !dbg !6 {
28entry:
29  %param0.addr = alloca i32, align 4
30  %N.addr = alloca i32, align 4
31  %A.addr = alloca ptr, align 8
32  %i = alloca i32, align 4
33  store i32 %param0, ptr %param0.addr, align 4
34  store i32 %N, ptr %N.addr, align 4
35  store ptr %A, ptr %A.addr, align 8
36  store i32 0, ptr %i, align 4
37  br label %for.cond
38
39for.cond:                                         ; preds = %for.inc, %entry
40  %0 = load i32, ptr %i, align 4
41  %1 = load i32, ptr %N.addr, align 4
42  %cmp = icmp slt i32 %0, %1
43  br i1 %cmp, label %for.body, label %for.end, !dbg !27
44
45for.body:                                         ; preds = %for.cond
46  %2 = load i32, ptr %param0.addr, align 4
47  %tobool = icmp ne i32 %2, 0
48  br i1 %tobool, label %if.then, label %if.else
49
50if.then:                                          ; preds = %for.body
51  br label %while.body
52
53while.body:                                       ; preds = %if.then, %while.body
54  %3 = load i32, ptr %i, align 4
55  %idxprom = sext i32 %3 to i64
56  %4 = load ptr, ptr %A.addr, align 8
57  %arrayidx = getelementptr inbounds i32, ptr %4, i64 %idxprom
58  store i32 1, ptr %arrayidx, align 4
59  br label %while.body, !dbg !37
60
61if.else:                                          ; preds = %for.body
62  %5 = load i32, ptr %i, align 4
63  %idxprom1 = sext i32 %5 to i64
64  %6 = load ptr, ptr %A.addr, align 8
65  %arrayidx2 = getelementptr inbounds i32, ptr %6, i64 %idxprom1
66  store i32 2, ptr %arrayidx2, align 4
67  br label %if.end
68
69if.end:                                           ; preds = %if.else
70  br label %for.inc
71
72for.inc:                                          ; preds = %if.end
73  %7 = load i32, ptr %i, align 4
74  %inc = add nsw i32 %7, 1
75  store i32 %inc, ptr %i, align 4
76  br label %for.cond
77
78for.end:                                          ; preds = %for.cond
79  ret void
80}
81
82; Function Attrs: nounwind readnone
83declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
84
85attributes #0 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
86attributes #1 = { nounwind readnone }
87
88!llvm.dbg.cu = !{!0}
89!llvm.module.flags = !{!3, !4}
90!llvm.ident = !{!5}
91
92!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.9.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
93!1 = !DIFile(filename: "ReportLoopHasNoExit.c", directory: "test/ScopDetectionDiagnostics/")
94!2 = !{}
95!3 = !{i32 2, !"Dwarf Version", i32 4}
96!4 = !{i32 2, !"Debug Info Version", i32 3}
97!5 = !{!"clang version 3.9.0 "}
98!6 = distinct !DISubprogram(name: "func", scope: !1, file: !1, line: 1,  isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
99!19 = distinct !DILexicalBlock(scope: !6, file: !1, line: 3, column: 3)
100!23 = !DILexicalBlockFile(scope: !24, file: !1, discriminator: 1)
101!24 = distinct !DILexicalBlock(scope: !19, file: !1, line: 3, column: 3)
102!27 = !DILocation(line: 3, column: 3, scope: !23)
103!29 = distinct !DILexicalBlock(scope: !30, file: !1, line: 5, column: 9)
104!30 = distinct !DILexicalBlock(scope: !24, file: !1, line: 4, column: 3)
105!33 = distinct !DILexicalBlock(scope: !29, file: !1, line: 6, column: 5)
106!37 = !DILocation(line: 7, column: 7, scope: !38)
107!38 = !DILexicalBlockFile(scope: !33, file: !1, discriminator: 1)
108