xref: /llvm-project/llvm/test/Transforms/CodeExtractor/PartialInlineDebug.ll (revision 0ca8ddd84d416b2b2b831fbc75ac8dbb77a12928)
1*0ca8ddd8SRoman Lebedev; RUN: opt < %s -S -passes=partial-inliner -skip-partial-inlining-cost-analysis=true | FileCheck %s
2cee313d2SEric Christopher
3cee313d2SEric Christopher; CHECK-LABEL: @callee
4cee313d2SEric Christopher; CHECK: %mul = mul nsw i32 %v, 10, !dbg ![[DBG1:[0-9]+]]
5cee313d2SEric Christopherdefine i32 @callee(i32 %v) !dbg !16 {
6cee313d2SEric Christopherentry:
7cee313d2SEric Christopher  %cmp = icmp sgt i32 %v, 2000
8cee313d2SEric Christopher  br i1 %cmp, label %if.then, label %if.end
9cee313d2SEric Christopher
10cee313d2SEric Christopherif.then:                                          ; preds = %entry
11cee313d2SEric Christopher  %mul = mul nsw i32 %v, 10, !dbg !17
12cee313d2SEric Christopher  br label %if.then2
13cee313d2SEric Christopher
14cee313d2SEric Christopherif.then2:
15cee313d2SEric Christopher  %sub = sub i32 %v, 10, !dbg !23
16cee313d2SEric Christopher  br label %if.end
17cee313d2SEric Christopher
18cee313d2SEric Christopherif.end:                                           ; preds = %if.then, %entry
19cee313d2SEric Christopher  %v2 = phi i32 [ %v, %entry ], [ %mul, %if.then2 ]
20cee313d2SEric Christopher  %add = add nsw i32 %v2, 200
21cee313d2SEric Christopher  ret i32 %add
22cee313d2SEric Christopher}
23cee313d2SEric Christopher
24cee313d2SEric Christopher; CHECK-LABEL: @caller
25cee313d2SEric Christopher; CHECK: codeRepl.i:
26cee313d2SEric Christopher; CHECK-NOT: br label
2741d5033eSNikita Popov; CHECK: call void @callee.2.if.then(i32 %v, ptr %mul.loc.i), !dbg ![[DBG2:[0-9]+]]
28cee313d2SEric Christopherdefine i32 @caller(i32 %v) !dbg !8 {
29cee313d2SEric Christopherentry:
30cee313d2SEric Christopher  %call = call i32 @callee(i32 %v), !dbg !14
31cee313d2SEric Christopher  ret i32 %call
32cee313d2SEric Christopher}
33cee313d2SEric Christopher
34cee313d2SEric Christopher
35cee313d2SEric Christopher; CHECK-LABEL: @callee2
36cee313d2SEric Christopher; CHECK: %sub = sub i32 %v, 10, !dbg ![[DBG3:[0-9]+]]
37cee313d2SEric Christopherdefine i32 @callee2(i32 %v) !dbg !18 {
38cee313d2SEric Christopherentry:
39cee313d2SEric Christopher  %cmp = icmp sgt i32 %v, 2000
40cee313d2SEric Christopher  br i1 %cmp, label %if.then, label %if.end
41cee313d2SEric Christopher
42cee313d2SEric Christopherif.then:
43cee313d2SEric Christopher  br label %if.then2
44cee313d2SEric Christopher
45cee313d2SEric Christopherif.then2:
46cee313d2SEric Christopher  %sub = sub i32 %v, 10, !dbg !20
47cee313d2SEric Christopher  br label %if.end
48cee313d2SEric Christopher
49cee313d2SEric Christopherif.end:
50cee313d2SEric Christopher  %v2 = phi i32 [ %v, %entry ], [ %sub, %if.then2 ]
51cee313d2SEric Christopher  %add = add nsw i32 %v2, 200
52cee313d2SEric Christopher  ret i32 %add
53cee313d2SEric Christopher}
54cee313d2SEric Christopher
55cee313d2SEric Christopher; CHECK-LABEL: @caller2
56cee313d2SEric Christopher; CHECK: codeRepl.i:
57cee313d2SEric Christopher; CHECK-NOT: br label
5841d5033eSNikita Popov; CHECK: call void @callee2.1.if.then(i32 %v, ptr %sub.loc.i), !dbg ![[DBG4:[0-9]+]]
59cee313d2SEric Christopherdefine i32 @caller2(i32 %v) !dbg !21 {
60cee313d2SEric Christopherentry:
61cee313d2SEric Christopher  %call = call i32 @callee2(i32 %v), !dbg !22
62cee313d2SEric Christopher  ret i32 %call
63cee313d2SEric Christopher}
64cee313d2SEric Christopher
65cee313d2SEric Christopher; CHECK-LABEL: define internal void @callee2.1.if.then
66cee313d2SEric Christopher; CHECK: br label %if.then, !dbg ![[DBG5:[0-9]+]]
67cee313d2SEric Christopher
68cee313d2SEric Christopher; CHECK-LABEL: define internal void @callee.2.if.then
69cee313d2SEric Christopher; CHECK: br label %if.then, !dbg ![[DBG6:[0-9]+]]
70cee313d2SEric Christopher
71cee313d2SEric Christopher; CHECK: ![[DBG1]] = !DILocation(line: 10, column: 7,
72cee313d2SEric Christopher; CHECK: ![[DBG2]] = !DILocation(line: 10, column: 7,
73cee313d2SEric Christopher; CHECK: ![[DBG3]] = !DILocation(line: 110, column: 17,
74cee313d2SEric Christopher; CHECK: ![[DBG4]] = !DILocation(line: 110, column: 17,
75cee313d2SEric Christopher; CHECK: ![[DBG5]] = !DILocation(line: 110, column: 17,
76cee313d2SEric Christopher; CHECK: ![[DBG6]] = !DILocation(line: 10, column: 7,
77cee313d2SEric Christopher
78cee313d2SEric Christopher
79cee313d2SEric Christopher!llvm.dbg.cu = !{!0}
80cee313d2SEric Christopher!llvm.module.flags = !{!3, !4, !5, !6}
81cee313d2SEric Christopher!llvm.ident = !{!7}
82cee313d2SEric Christopher
83cee313d2SEric Christopher!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 6.0.0 (trunk 177881)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
84cee313d2SEric Christopher!1 = !DIFile(filename: "test.c", directory: "/tmp")
85cee313d2SEric Christopher!2 = !{}
86cee313d2SEric Christopher!3 = !{i32 2, !"Dwarf Version", i32 4}
87cee313d2SEric Christopher!4 = !{i32 2, !"Debug Info Version", i32 3}
88cee313d2SEric Christopher!5 = !{i32 1, !"wchar_size", i32 4}
89cee313d2SEric Christopher!6 = !{i32 1, !"min_enum_size", i32 4}
90cee313d2SEric Christopher!7 = !{!"clang version 6.0.0"}
91cee313d2SEric Christopher!8 = distinct !DISubprogram(name: "caller", scope: !1, file: !1, line: 3, type: !9, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !12)
92cee313d2SEric Christopher!9 = !DISubroutineType(types: !10)
93cee313d2SEric Christopher!10 = !{!11, !11}
94cee313d2SEric Christopher!11 = !DIBasicType(name: "int", size: 19, encoding: DW_ATE_signed)
95cee313d2SEric Christopher!12 = !{!13}
96cee313d2SEric Christopher!13 = !DILocalVariable(name: "v", arg: 1, scope: !8, file: !1, line: 3, type: !11)
97cee313d2SEric Christopher!14 = !DILocation(line: 5, column: 10, scope: !8)
98cee313d2SEric Christopher!15 = distinct !DILexicalBlock(scope: !16, file: !1, line: 9, column: 7)
99cee313d2SEric Christopher!16 = distinct !DISubprogram(name: "callee", scope: !1, file: !1, line: 8, type: !9, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !12)
100cee313d2SEric Christopher!17 = !DILocation(line: 10, column: 7, scope: !15)
101cee313d2SEric Christopher!18 = distinct !DISubprogram(name: "callee2", scope: !1, file: !1, line: 8, type: !9, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !12)
102cee313d2SEric Christopher!19 = distinct !DILexicalBlock(scope: !18, file: !1, line: 100, column: 1)
103cee313d2SEric Christopher!20 = !DILocation(line: 110, column: 17, scope: !19)
104cee313d2SEric Christopher!21 = distinct !DISubprogram(name: "caller2", scope: !1, file: !1, line: 8, type: !9, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !12)
105cee313d2SEric Christopher!22 = !DILocation(line: 110, column: 17, scope: !21)
106cee313d2SEric Christopher!23 = !DILocation(line: 15, column: 7, scope: !15)
107