130 lines · plain
1# RUN: llc %s --start-before=branch-folder --stop-after=branch-folder -o - \2# RUN: | FileCheck %s --implicit-check-not=DBG_PHI3 4## Check that common instructions hoisted from `if.then` and `if.else` into5## common pred `entry` get merged debug locations. The debug instructions from6## both branches should get hoisted and killed.7##8## The MIR debug instructions have been modified by hand in order to check they9## can be killed.10##11## Check DBG_PHIs are deleted rather than hoisted (implicit-check-not).12##13## Check DBG_LABELs are hoisted and not modified (and don't cause a crash).14 15# CHECK: bb.016# CHECK: CALL64pcrel32 @f, csr_64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp, implicit-def $rax17## --- Start splice from bb.2.if.else (and debug instructions from bb.1.if.then) ---18# CHECK-NEXT: DBG_LABEL 019# CHECK-NEXT: DBG_VALUE $noreg, $noreg, ![[#]], !DIExpression(), debug-location ![[#]]20# CHECK-NEXT: DBG_LABEL 121# CHECK-NEXT: DBG_VALUE $noreg, $noreg, ![[#]], !DIExpression(), debug-location ![[#]]22# CHECK-NEXT: $edi = MOV32r0 implicit-def dead $eflags, debug-instr-number 2, debug-location !DILocation(line: 0, scope: ![[#]])23# CHECK-NEXT: DBG_VALUE $noreg, $noreg, ![[#]], !DIExpression(DW_OP_LLVM_arg, 0), debug-location ![[#]]24# CHECK-NEXT: DBG_VALUE $noreg, $noreg, ![[#]], !DIExpression(DW_OP_LLVM_arg, 0), debug-location ![[#]]25## --- End splice ------------------------------------------------------------------26# CHECK-NEXT: TEST64rr killed renamable $rax, renamable $rax, implicit-def $eflags27# CHECK-NEXT: JCC_1 %bb.2, 9, implicit killed $eflags28# CHECK: bb.129 30--- |31 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"32 target triple = "x86_64-unknown-linux-gnu"33 34 declare dso_local noundef i64 @f() local_unnamed_addr35 36 define dso_local noundef i32 @g() local_unnamed_addr !dbg !7 {37 %call = tail call noundef i64 @f()38 %cmp1 = icmp sgt i64 0, %call39 %conv2 = trunc i64 0 to i3240 br i1 %cmp1, label %if.then, label %if.else41 42 if.then: ; preds = %043 #dbg_value(i64 0, !11, !DIExpression(), !13)44 tail call void @_Z3fooii(i32 noundef %conv2, i32 noundef 0), !dbg !1445 #dbg_value(i64 1, !11, !DIExpression(), !13)46 br label %if.end, !dbg !1547 48 if.else: ; preds = %049 #dbg_value(i64 2, !11, !DIExpression(), !13)50 tail call void @_Z3barii(i32 noundef %conv2, i32 noundef 1), !dbg !1651 #dbg_value(i64 3, !11, !DIExpression(), !13)52 br label %if.end, !dbg !1753 54 if.end: ; preds = %if.else, %if.then55 ret i32 256 }57 58 declare void @_Z3fooii(i32 noundef, i32 noundef) local_unnamed_addr59 60 declare void @_Z3barii(i32 noundef, i32 noundef) local_unnamed_addr61 62 !llvm.module.flags = !{!0, !1}63 !llvm.ident = !{!2}64 !llvm.dbg.cu = !{!3}65 !llvm.debugify = !{!5, !6}66 67 !0 = !{i32 7, !"Dwarf Version", i32 5}68 !1 = !{i32 2, !"Debug Info Version", i32 3}69 !2 = !{!"clang version 21.0.0"}70 !3 = distinct !DICompileUnit(language: DW_LANG_C, file: !4, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)71 !4 = !DIFile(filename: "test.nodbg.ll", directory: "/")72 !5 = !{i32 15}73 !6 = !{i32 7}74 !7 = distinct !DISubprogram(name: "g", linkageName: "g", scope: null, file: !4, line: 1, type: !8, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !3, retainedNodes: !10)75 !8 = !DISubroutineType(types: !9)76 !9 = !{}77 !10 = !{!11}78 !11 = !DILocalVariable(name: "1", scope: !7, file: !4, line: 3, type: !12)79 !12 = !DIBasicType(name: "ty64", size: 64, encoding: DW_ATE_unsigned)80 !13 = !DILocation(line: 3, column: 1, scope: !7)81 !14 = !DILocation(line: 9, column: 1, scope: !7)82 !15 = !DILocation(line: 10, column: 1, scope: !7)83 !16 = !DILocation(line: 11, column: 1, scope: !7)84 !17 = !DILocation(line: 12, column: 1, scope: !7)85...86---87name: g88tracksRegLiveness: true89isSSA: false90body: |91 bb.0 (%ir-block.0):92 successors: %bb.1(0x40000000), %bb.2(0x40000000)93 94 frame-setup PUSH64r undef $rax, implicit-def $rsp, implicit $rsp95 frame-setup CFI_INSTRUCTION def_cfa_offset 1696 CALL64pcrel32 @f, csr_64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp, implicit-def $rax97 TEST64rr killed renamable $rax, renamable $rax, implicit-def $eflags98 JCC_1 %bb.2, 9, implicit killed $eflags99 JMP_1 %bb.1100 101 bb.1.if.then:102 successors: %bb.3(0x80000000)103 104 DBG_PHI $esp, 3105 DBG_LABEL 0106 DBG_VALUE $esi, $noreg, !11, !DIExpression(), debug-location !13107 $edi = MOV32r0 implicit-def dead $eflags, debug-instr-number 1, debug-location !14108 DBG_INSTR_REF !11, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(1, 0), debug-location !13109 $esi = MOV32r0 implicit-def dead $eflags, debug-location !14110 CALL64pcrel32 target-flags(x86-plt) @_Z3fooii, csr_64, implicit $rsp, implicit $ssp, implicit killed $edi, implicit killed $esi, implicit-def $rsp, implicit-def $ssp, debug-location !14111 JMP_1 %bb.3, debug-location !15112 113 bb.2.if.else:114 successors: %bb.3(0x80000000)115 116 DBG_PHI $esp, 4117 DBG_LABEL 1118 DBG_VALUE $esp, $noreg, !11, !DIExpression(), debug-location !13119 $edi = MOV32r0 implicit-def dead $eflags, debug-instr-number 2, debug-location !16120 DBG_INSTR_REF !11, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(2, 0), debug-location !13121 $esi = MOV32ri 1, debug-location !16122 CALL64pcrel32 target-flags(x86-plt) @_Z3barii, csr_64, implicit $rsp, implicit $ssp, implicit killed $edi, implicit killed $esi, implicit-def $rsp, implicit-def $ssp, debug-location !16123 124 bb.3.if.end:125 $eax = MOV32ri 2126 $rcx = frame-destroy POP64r implicit-def $rsp, implicit $rsp127 frame-destroy CFI_INSTRUCTION def_cfa_offset 8128 RET 0, $eax129...130