xref: /llvm-project/polly/test/ScopDetectionDiagnostics/ReportIrreducibleRegion.ll (revision e1f056f692d869708c1898d9d65a69ac5584a0ed)
1; RUN: opt %loadNPMPolly '-passes=print<polly-detect>' -pass-remarks-missed="polly-detect" -disable-output < %s 2>&1| FileCheck %s
2target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
3
4;void foo(int a, int b) {
5;  if(b == 42) {
6;    if (a > 0) {
7;      LABEL1:
8;      a--;
9;    }
10;
11;    if (a > 0) {
12;      goto LABEL1;
13;    }
14;    b = b + 42;
15;  }
16;}
17
18; CHECK: remark: ReportIrreducibleRegion.c:3:7: The following errors keep this region from being a Scop.
19; CHECK-NEXT: remark: ReportIrreducibleRegion.c:9:4: Irreducible region encountered in control flow.
20; CHECK-NEXT: remark: ReportIrreducibleRegion.c:9:4: Invalid Scop candidate ends here.
21
22
23; Function Attrs: nounwind uwtable
24define void @foo(i32 %a, i32 %b) #0 !dbg !4 {
25entry:
26  %a.addr = alloca i32, align 4
27  %b.addr = alloca i32, align 4
28  store i32 %a, ptr %a.addr, align 4
29  call void @llvm.dbg.declare(metadata ptr %a.addr, metadata !11, metadata !12), !dbg !13
30  store i32 %b, ptr %b.addr, align 4
31  call void @llvm.dbg.declare(metadata ptr %b.addr, metadata !14, metadata !12), !dbg !15
32  %0 = load i32, ptr %b.addr, align 4, !dbg !16
33  %cmp = icmp eq i32 %0, 42, !dbg !18
34  br i1 %cmp, label %if.then, label %if.end6, !dbg !19
35
36if.then:                                          ; preds = %entry
37  %1 = load i32, ptr %a.addr, align 4, !dbg !20
38  %cmp1 = icmp sgt i32 %1, 0, !dbg !23
39  br i1 %cmp1, label %if.then2, label %if.end, !dbg !24
40
41if.then2:                                         ; preds = %if.then
42  br label %LABEL1, !dbg !25
43
44LABEL1:                                           ; preds = %if.then4, %if.then2
45  %2 = load i32, ptr %a.addr, align 4, !dbg !27
46  %dec = add nsw i32 %2, -1, !dbg !27
47  store i32 %dec, ptr %a.addr, align 4, !dbg !27
48  br label %if.end, !dbg !29
49
50if.end:                                           ; preds = %LABEL1, %if.then
51  %3 = load i32, ptr %a.addr, align 4, !dbg !30
52  %cmp3 = icmp sgt i32 %3, 0, !dbg !32
53  br i1 %cmp3, label %if.then4, label %if.end5, !dbg !33
54
55if.then4:                                         ; preds = %if.end
56  br label %LABEL1, !dbg !34
57
58if.end5:                                          ; preds = %if.end
59  %4 = load i32, ptr %b.addr, align 4, !dbg !36
60  %add = add nsw i32 %4, 42, !dbg !37
61  store i32 %add, ptr %b.addr, align 4, !dbg !38
62  br label %if.end6, !dbg !39
63
64if.end6:                                          ; preds = %if.end5, %entry
65  ret void, !dbg !40
66}
67
68; Function Attrs: nounwind readnone
69declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
70
71attributes #0 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
72attributes #1 = { nounwind readnone }
73
74!llvm.dbg.cu = !{!0}
75!llvm.module.flags = !{!8, !9}
76!llvm.ident = !{!10}
77
78!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.8.0", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2)
79!1 = !DIFile(filename: "ReportIrreducibleRegion.c", directory: "llvm/tools/polly/test/ScopDetectionDiagnostics")
80!2 = !{}
81!4 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !5, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
82!5 = !DISubroutineType(types: !6)
83!6 = !{null, !7, !7}
84!7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
85!8 = !{i32 2, !"Dwarf Version", i32 4}
86!9 = !{i32 2, !"Debug Info Version", i32 3}
87!10 = !{!"clang version 3.8.0"}
88!11 = !DILocalVariable(name: "a", arg: 1, scope: !4, file: !1, line: 1, type: !7)
89!12 = !DIExpression()
90!13 = !DILocation(line: 1, column: 14, scope: !4)
91!14 = !DILocalVariable(name: "b", arg: 2, scope: !4, file: !1, line: 1, type: !7)
92!15 = !DILocation(line: 1, column: 21, scope: !4)
93!16 = !DILocation(line: 2, column: 5, scope: !17)
94!17 = distinct !DILexicalBlock(scope: !4, file: !1, line: 2, column: 5)
95!18 = !DILocation(line: 2, column: 7, scope: !17)
96!19 = !DILocation(line: 2, column: 5, scope: !4)
97!20 = !DILocation(line: 3, column: 7, scope: !21)
98!21 = distinct !DILexicalBlock(scope: !22, file: !1, line: 3, column: 7)
99!22 = distinct !DILexicalBlock(scope: !17, file: !1, line: 2, column: 14)
100!23 = !DILocation(line: 3, column: 9, scope: !21)
101!24 = !DILocation(line: 3, column: 7, scope: !22)
102!25 = !DILocation(line: 3, column: 14, scope: !26)
103!26 = !DILexicalBlockFile(scope: !21, file: !1, discriminator: 1)
104!27 = !DILocation(line: 5, column: 5, scope: !28)
105!28 = distinct !DILexicalBlock(scope: !21, file: !1, line: 3, column: 14)
106!29 = !DILocation(line: 6, column: 3, scope: !28)
107!30 = !DILocation(line: 8, column: 7, scope: !31)
108!31 = distinct !DILexicalBlock(scope: !22, file: !1, line: 8, column: 7)
109!32 = !DILocation(line: 8, column: 9, scope: !31)
110!33 = !DILocation(line: 8, column: 7, scope: !22)
111!34 = !DILocation(line: 9, column: 4, scope: !35)
112!35 = distinct !DILexicalBlock(scope: !31, file: !1, line: 8, column: 14)
113!36 = !DILocation(line: 11, column: 7, scope: !22)
114!37 = !DILocation(line: 11, column: 9, scope: !22)
115!38 = !DILocation(line: 11, column: 5, scope: !22)
116!39 = !DILocation(line: 12, column: 2, scope: !22)
117!40 = !DILocation(line: 13, column: 1, scope: !4)
118