1 ; RUN: opt -passes=callsite-splitting -S < %s | FileCheck %s --implicit-check-not=dbg.value
2 ; RUN: opt -passes=callsite-splitting -S < %s --try-experimental-debuginfo-iterators | FileCheck %s --implicit-check-not=dbg.value
4 ;; Test that DebugLocs are preserved, and that dbg.values are duplicated.
8 ; CHECK: #dbg_value(i32 0,
9 ; CHECK-NEXT: [[R1:%.+]] = call i32 @callee(i32 0, i32 %dd), !dbg [[DBG1:!.*]]
10 ; CHECK: #dbg_value(i32 0,
11 ; CHECK-NEXT: [[R2:%.+]] = call i32 @callee(i32 1, i32 %dd), !dbg [[DBG1]]
12 ; CHECK-LABEL: CallSite:
13 ; CHECK-NEXT: phi i32 [ [[R2]], %land.rhs.split ], [ [[R1]], %entry.split ], !dbg [[DBG1]]
14 ; CHECK-NEXT: #dbg_value(i32 1,
16 declare void @llvm.dbg.value(metadata, metadata, metadata)
18 define i32 @test1(ptr dereferenceable(4) %cc, i32 %dd, i1 %arg) !dbg !6 {
20 br i1 %arg, label %CallSite, label %land.rhs
22 land.rhs: ; preds = %entry
25 CallSite: ; preds = %land.rhs, %entry
26 %pv = phi i32 [ 0, %entry ], [ 1, %land.rhs ]
27 call void @llvm.dbg.value(metadata i32 0, metadata !9, metadata !DIExpression()), !dbg !18
28 %call = call i32 @callee(i32 %pv, i32 %dd), !dbg !18
29 call void @llvm.dbg.value(metadata i32 1, metadata !9, metadata !DIExpression()), !dbg !18
34 ; CHECK: [[LV1:%.*]] = load i32, ptr %ptr, align 4, !dbg [[DBG_LV:!.*]]
35 ; CHECK-NEXT: #dbg_value(i32 0,
36 ; CHECK-NEXT: [[R1:%.+]] = call i32 @callee(i32 0, i32 10), !dbg [[DBG_CALL:!.*]]
37 ; CHECK: [[LV2:%.*]] = load i32, ptr %ptr, align 4, !dbg [[DBG_LV]]
38 ; CHECK-NEXT: #dbg_value(i32 0,
39 ; CHECK-NEXT: [[R2:%.+]] = call i32 @callee(i32 0, i32 %i), !dbg [[DBG_CALL]]
40 ; CHECK-LABEL: CallSite:
41 ; CHECK-NEXT: phi i32 [ [[LV1]], %Header.split ], [ [[LV2]], %TBB.split ], !dbg [[DBG_LV]]
42 ; CHECK-NEXT: phi i32 [ [[R1]], %Header.split ], [ [[R2]], %TBB.split ], !dbg [[DBG_CALL]]
43 ; CHECK-NEXT: #dbg_value(i32 1,
45 define void @test2(ptr %ptr, i32 %i, i1 %arg) !dbg !19 {
47 %tobool = icmp ne i32 %i, 10
48 br i1 %tobool, label %TBB, label %CallSite
50 TBB: ; preds = %Header
51 br i1 %arg, label %CallSite, label %End
53 CallSite: ; preds = %TBB, %Header
54 %lv = load i32, ptr %ptr, align 4, !dbg !25
55 call void @llvm.dbg.value(metadata i32 0, metadata !21, metadata !DIExpression()), !dbg !26
56 %cv = call i32 @callee(i32 0, i32 %i), !dbg !26
57 call void @llvm.dbg.value(metadata i32 1, metadata !21, metadata !DIExpression()), !dbg !26
58 %sub = sub nsw i32 %lv, %cv
61 End: ; preds = %CallSite, %TBB
65 define i32 @callee(i32 %aa, i32 %bb) {
67 %add = add nsw i32 %aa, %bb
72 !llvm.debugify = !{!3, !4}
73 !llvm.module.flags = !{!5}
75 !0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
76 !1 = !DIFile(filename: "<stdin>", directory: "/")
80 !5 = !{i32 2, !"Debug Info Version", i32 3}
81 !6 = distinct !DISubprogram(name: "test", linkageName: "test", scope: null, file: !1, line: 3, type: !7, isLocal: false, isDefinition: true, scopeLine: 3, isOptimized: true, unit: !0, retainedNodes: !8)
82 !7 = !DISubroutineType(types: !2)
83 !8 = !{!9, !11, !13, !15, !16, !17}
84 !9 = !DILocalVariable(name: "2", scope: !6, file: !1, line: 3, type: !10)
85 !10 = !DIBasicType(name: "ty64", size: 64, encoding: DW_ATE_unsigned)
86 !11 = !DILocalVariable(name: "3", scope: !6, file: !1, line: 5, type: !12)
87 !12 = !DIBasicType(name: "ty32", size: 32, encoding: DW_ATE_unsigned)
88 !13 = !DILocalVariable(name: "4", scope: !6, file: !1, line: 6, type: !14)
89 !14 = !DIBasicType(name: "ty8", size: 8, encoding: DW_ATE_unsigned)
90 !15 = !DILocalVariable(name: "5", scope: !6, file: !1, line: 9, type: !12)
91 !16 = !DILocalVariable(name: "6", scope: !6, file: !1, line: 10, type: !12)
92 !17 = !DILocalVariable(name: "7", scope: !6, file: !1, line: 11, type: !10)
93 !18 = !DILocation(line: 10, column: 1, scope: !6)
94 !19 = distinct !DISubprogram(name: "test_add_new_phi", linkageName: "test_add_new_phi", scope: null, file: !1, line: 14, type: !7, isLocal: false, isDefinition: true, scopeLine: 14, isOptimized: true, unit: !0, retainedNodes: !20)
95 !20 = !{!21, !22, !23, !24}
96 !21 = !DILocalVariable(name: "8", scope: !19, file: !1, line: 14, type: !14)
97 !22 = !DILocalVariable(name: "9", scope: !19, file: !1, line: 17, type: !10)
98 !23 = !DILocalVariable(name: "10", scope: !19, file: !1, line: 18, type: !12)
99 !24 = !DILocalVariable(name: "11", scope: !19, file: !1, line: 20, type: !12)
100 !25 = !DILocation(line: 18, column: 1, scope: !19)
101 !26 = !DILocation(line: 19, column: 1, scope: !19)