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.
6 ; CHECK: declare void @llvm.dbg.value(metadata,
9 ; CHECK: call void @llvm.dbg.value(metadata i32 0,
10 ; CHECK-NEXT: [[R1:%.+]] = call i32 @callee(i32 0, i32 %dd), !dbg [[DBG1:!.*]]
11 ; CHECK: call void @llvm.dbg.value(metadata i32 0,
12 ; CHECK-NEXT: [[R2:%.+]] = call i32 @callee(i32 1, i32 %dd), !dbg [[DBG1]]
13 ; CHECK-LABEL: CallSite:
14 ; CHECK-NEXT: phi i32 [ [[R2]], %land.rhs.split ], [ [[R1]], %entry.split ], !dbg [[DBG1]]
15 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 1,
17 declare void @llvm.dbg.value(metadata, metadata, metadata)
19 define i32 @test1(ptr dereferenceable(4) %cc, i32 %dd) !dbg !6 {
21 br i1 undef, label %CallSite, label %land.rhs
23 land.rhs: ; preds = %entry
26 CallSite: ; preds = %land.rhs, %entry
27 %pv = phi i32 [ 0, %entry ], [ 1, %land.rhs ]
28 call void @llvm.dbg.value(metadata i32 0, metadata !9, metadata !DIExpression()), !dbg !18
29 %call = call i32 @callee(i32 %pv, i32 %dd), !dbg !18
30 call void @llvm.dbg.value(metadata i32 1, metadata !9, metadata !DIExpression()), !dbg !18
35 ; CHECK: [[LV1:%.*]] = load i32, ptr %ptr, align 4, !dbg [[DBG_LV:!.*]]
36 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 0,
37 ; CHECK-NEXT: [[R1:%.+]] = call i32 @callee(i32 0, i32 10), !dbg [[DBG_CALL:!.*]]
38 ; CHECK: [[LV2:%.*]] = load i32, ptr %ptr, align 4, !dbg [[DBG_LV]]
39 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 0,
40 ; CHECK-NEXT: [[R2:%.+]] = call i32 @callee(i32 0, i32 %i), !dbg [[DBG_CALL]]
41 ; CHECK-LABEL: CallSite:
42 ; CHECK-NEXT: phi i32 [ [[LV1]], %Header.split ], [ [[LV2]], %TBB.split ], !dbg [[DBG_LV]]
43 ; CHECK-NEXT: phi i32 [ [[R1]], %Header.split ], [ [[R2]], %TBB.split ], !dbg [[DBG_CALL]]
44 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 1,
46 define void @test2(ptr %ptr, i32 %i) !dbg !19 {
48 %tobool = icmp ne i32 %i, 10
49 br i1 %tobool, label %TBB, label %CallSite
51 TBB: ; preds = %Header
52 br i1 undef, label %CallSite, label %End
54 CallSite: ; preds = %TBB, %Header
55 %lv = load i32, ptr %ptr, align 4, !dbg !25
56 call void @llvm.dbg.value(metadata i32 0, metadata !21, metadata !DIExpression()), !dbg !26
57 %cv = call i32 @callee(i32 0, i32 %i), !dbg !26
58 call void @llvm.dbg.value(metadata i32 1, metadata !21, metadata !DIExpression()), !dbg !26
59 %sub = sub nsw i32 %lv, %cv
62 End: ; preds = %CallSite, %TBB
66 define i32 @callee(i32 %aa, i32 %bb) {
68 %add = add nsw i32 %aa, %bb
73 !llvm.debugify = !{!3, !4}
74 !llvm.module.flags = !{!5}
76 !0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
77 !1 = !DIFile(filename: "<stdin>", directory: "/")
81 !5 = !{i32 2, !"Debug Info Version", i32 3}
82 !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)
83 !7 = !DISubroutineType(types: !2)
84 !8 = !{!9, !11, !13, !15, !16, !17}
85 !9 = !DILocalVariable(name: "2", scope: !6, file: !1, line: 3, type: !10)
86 !10 = !DIBasicType(name: "ty64", size: 64, encoding: DW_ATE_unsigned)
87 !11 = !DILocalVariable(name: "3", scope: !6, file: !1, line: 5, type: !12)
88 !12 = !DIBasicType(name: "ty32", size: 32, encoding: DW_ATE_unsigned)
89 !13 = !DILocalVariable(name: "4", scope: !6, file: !1, line: 6, type: !14)
90 !14 = !DIBasicType(name: "ty8", size: 8, encoding: DW_ATE_unsigned)
91 !15 = !DILocalVariable(name: "5", scope: !6, file: !1, line: 9, type: !12)
92 !16 = !DILocalVariable(name: "6", scope: !6, file: !1, line: 10, type: !12)
93 !17 = !DILocalVariable(name: "7", scope: !6, file: !1, line: 11, type: !10)
94 !18 = !DILocation(line: 10, column: 1, scope: !6)
95 !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)
96 !20 = !{!21, !22, !23, !24}
97 !21 = !DILocalVariable(name: "8", scope: !19, file: !1, line: 14, type: !14)
98 !22 = !DILocalVariable(name: "9", scope: !19, file: !1, line: 17, type: !10)
99 !23 = !DILocalVariable(name: "10", scope: !19, file: !1, line: 18, type: !12)
100 !24 = !DILocalVariable(name: "11", scope: !19, file: !1, line: 20, type: !12)
101 !25 = !DILocation(line: 18, column: 1, scope: !19)
102 !26 = !DILocation(line: 19, column: 1, scope: !19)