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