1; RUN: opt -S -strip-debug < %s | FileCheck %s
2
3target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
4target triple = "x86_64-apple-macosx10.12.0"
5
6; CHECK-LABEL: _Z5test1v
7; CHECK-NOT: br {{.*}} !llvm.loop
8define void @_Z5test1v() !dbg !7 {
9entry:
10  br label %while.body, !dbg !9
11
12while.body:
13  call void @_Z3barv(), !dbg !10
14  br label %while.body, !dbg !11, !llvm.loop !13
15
16return:
17  ret void, !dbg !14
18}
19
20declare void @_Z3barv()
21declare i1 @_Z3bazv()
22
23; CHECK-LABEL: _Z5test2v
24; CHECK: br {{.*}} !llvm.loop [[LOOP:![0-9]+]]
25define void @_Z5test2v() !dbg !15 {
26entry:
27  br label %while.body, !dbg !16
28
29while.body:
30  call void @_Z3barv(), !dbg !17
31  br label %while.body, !dbg !18, !llvm.loop !19
32
33return:
34  ret void, !dbg !21
35}
36
37; CHECK-LABEL: _Z5test3v
38define void @_Z5test3v() !dbg !22 {
39entry:
40  br label %while.body, !dbg !23
41
42while.body:
43  %c = call i1 @_Z3bazv()
44  br i1 %c, label %if, label %then
45
46if:
47  call void @_Z3barv(), !dbg !24
48; CHECK: br {{.*}} !llvm.loop [[LOOP2:![0-9]+]]
49  br label %while.body, !dbg !25, !llvm.loop !26
50
51then:
52; CHECK: br {{.*}} !llvm.loop [[LOOP2]]
53  br label %while.body, !dbg !25, !llvm.loop !26
54
55return:
56  ret void, !dbg !28
57}
58
59; CHECK-LABEL: _Z5test4v
60; CHECK-NOT: br {{.*}} !llvm.loop
61define void @_Z5test4v() !dbg !30 {
62entry:
63  br label %while.body, !dbg !31
64
65while.body:
66  call void @_Z3barv(), !dbg !32
67  br label %while.body, !dbg !33, !llvm.loop !34
68
69return:
70  ret void, !dbg !36
71}
72
73!llvm.dbg.cu = !{!0}
74!llvm.module.flags = !{!3, !4, !5}
75!llvm.ident = !{!6}
76
77!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 4.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !2)
78!1 = !DIFile(filename: "test.cpp", directory: "/tmp")
79!2 = !{}
80!3 = !{i32 2, !"Dwarf Version", i32 4}
81!4 = !{i32 2, !"Debug Info Version", i32 3}
82!5 = !{i32 1, !"PIC Level", i32 2}
83!6 = !{!"clang version 4.0.0"}
84!7 = distinct !DISubprogram(name: "test1", scope: !1, file: !1, line: 3, type: !8, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
85!8 = !DISubroutineType(types: !2)
86!9 = !DILocation(line: 4, column: 3, scope: !7)
87!10 = !DILocation(line: 5, column: 5, scope: !7)
88!11 = !DILocation(line: 4, column: 3, scope: !12)
89!12 = !DILexicalBlockFile(scope: !7, file: !1, discriminator: 1)
90!13 = distinct !{!13, !9}
91!14 = !DILocation(line: 6, column: 1, scope: !7)
92!15 = distinct !DISubprogram(name: "test2", scope: !1, file: !1, line: 8, type: !8, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
93!16 = !DILocation(line: 8, column: 14, scope: !15)
94!17 = !DILocation(line: 11, column: 5, scope: !15)
95!18 = !DILocation(line: 10, column: 3, scope: !15)
96!19 = distinct !{!19, !16, !20}
97!20 = !{!"llvm.loop.unroll.enable"}
98!21 = !DILocation(line: 12, column: 1, scope: !15)
99!22 = distinct !DISubprogram(name: "test3", scope: !1, file: !1, line: 8, type: !8, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
100!23 = !DILocation(line: 8, column: 14, scope: !22)
101!24 = !DILocation(line: 11, column: 5, scope: !22)
102!25 = !DILocation(line: 10, column: 3, scope: !22)
103!26 = distinct !{!26, !23, !29, !27}
104!27 = !{!"llvm.loop.unroll.enable"}
105!28 = !DILocation(line: 12, column: 1, scope: !22)
106!29 = !DILocation(line: 12, column: 1, scope: !22)
107!30 = distinct !DISubprogram(name: "test4", scope: !1, file: !1, line: 8, type: !8, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
108!31 = !DILocation(line: 8, column: 14, scope: !30)
109!32 = !DILocation(line: 11, column: 5, scope: !30)
110!33 = !DILocation(line: 10, column: 3, scope: !30)
111!34 = distinct !{!34, !31, !35}
112!35 = !DILocation(line: 12, column: 1, scope: !30)
113!36 = !DILocation(line: 12, column: 1, scope: !30)
114
115; CHECK-NOT: !DICompileUnit
116; CHECK-NOT: !DIFile
117; CHECK-NOT: !DISubprogram
118; CHECK-NOT: !DISubroutineType
119; CHECK-NOT: !DILocation
120; CHECK-NOT: !DILexicalBlockFile
121; CHECK: [[LOOP]] = distinct !{[[LOOP]], [[LOOP_UNROLL:![0-9]+]]}
122; CHECK-NEXT: [[LOOP_UNROLL]] = !{!"llvm.loop.unroll.enable"}
123; CHECK: [[LOOP2]] = distinct !{[[LOOP2]], [[LOOP_UNROLL]]}
124; CHECK-NOT: !DILocation
125