brintos

brintos / llvm-project-archived public Read only

0
0
Text · 9.0 KiB · 12f9361 Raw
201 lines · plain
1# RUN: llc %s -o - -mtriple=x86_64-unknown-unknown \2# RUN:    -experimental-debug-variable-locations -run-pass=livedebugvalues \3# RUN:    | FileCheck %s --check-prefix=CHECK4#5# Test that, in a scenario where tail duplication has duplicated DBG_PHI6# instructions, we can reconstruct the value to refer to. This includes cases7# where the DBG_PHIs refer to the same value, to values that later merge, and8# value that become unavailable.9--- |10  ; ModuleID = 'before.mir'11  source_filename = "test.c"12  target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"13  target triple = "x86_64-unknown-linux-gnu"14 15  define dso_local i32 @foo(i64 %bar, i64 %baz) !dbg !7 {16  entry:17    call void @llvm.dbg.value(metadata i64 %bar, metadata !12, metadata !DIExpression()), !dbg !1318    call void @llvm.dbg.value(metadata i64 %baz, metadata !14, metadata !DIExpression()), !dbg !1319    call void @ext(i64 %bar), !dbg !1520    %add = add nsw i64 %bar, 12, !dbg !1621    call void @llvm.dbg.value(metadata i64 %add, metadata !12, metadata !DIExpression()), !dbg !1322    call void @ext(i64 %add), !dbg !1723    %add1 = add nsw i64 %baz, 1, !dbg !1824    call void @llvm.dbg.value(metadata i64 %add1, metadata !14, metadata !DIExpression()), !dbg !1325    %call = call i64 @getlong(), !dbg !1926    %tobool = icmp ne i64 %call, 0, !dbg !1927    br i1 %tobool, label %if.then, label %if.else, !dbg !2128 29  if.then:                                          ; preds = %entry30    %add2 = add nsw i64 %add, 1, !dbg !2231    call void @llvm.dbg.value(metadata i64 %add2, metadata !12, metadata !DIExpression()), !dbg !1332    br label %if.end, !dbg !2433 34  if.else:                                          ; preds = %entry35    %add3 = add nsw i64 %add, 2, !dbg !2536    call void @llvm.dbg.value(metadata i64 %add3, metadata !12, metadata !DIExpression()), !dbg !1337    br label %if.end38 39  if.end:                                           ; preds = %if.else, %if.then40    %bar.addr.0 = phi i64 [ %add2, %if.then ], [ %add3, %if.else ], !dbg !2741    call void @llvm.dbg.value(metadata i64 %bar.addr.0, metadata !12, metadata !DIExpression()), !dbg !1342    %add4 = add nsw i64 %bar.addr.0, %add1, !dbg !2843    call void @llvm.dbg.value(metadata i64 %add4, metadata !12, metadata !DIExpression()), !dbg !1344    call void @ext(i64 %add4), !dbg !2945    %conv = trunc i64 %add4 to i32, !dbg !3046    ret i32 %conv, !dbg !3147  }48 49  ; Function Attrs: nounwind readnone speculatable willreturn50  declare void @llvm.dbg.declare(metadata, metadata, metadata)51 52  declare dso_local void @ext(i64)53 54  declare dso_local i64 @getlong()55 56  ; Function Attrs: nounwind readnone speculatable willreturn57  declare void @llvm.dbg.value(metadata, metadata, metadata)58 59  !llvm.dbg.cu = !{!0}60  !llvm.module.flags = !{!3, !4, !5}61  !llvm.ident = !{!6}62 63  !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)64  !1 = !DIFile(filename: "test.c", directory: ".")65  !2 = !{}66  !3 = !{i32 7, !"Dwarf Version", i32 4}67  !4 = !{i32 2, !"Debug Info Version", i32 3}68  !5 = !{i32 1, !"wchar_size", i32 4}69  !6 = !{!"clang"}70  !7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 3, type: !8, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)71  !8 = !DISubroutineType(types: !9)72  !9 = !{!10, !11, !11}73  !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)74  !11 = !DIBasicType(name: "long int", size: 64, encoding: DW_ATE_signed)75  !12 = !DILocalVariable(name: "bar", arg: 1, scope: !7, file: !1, line: 3, type: !11)76  !13 = !DILocation(line: 0, scope: !7)77  !14 = !DILocalVariable(name: "baz", arg: 2, scope: !7, file: !1, line: 3, type: !11)78  !15 = !DILocation(line: 4, column: 3, scope: !7)79  !16 = !DILocation(line: 5, column: 7, scope: !7)80  !17 = !DILocation(line: 6, column: 3, scope: !7)81  !18 = !DILocation(line: 7, column: 7, scope: !7)82  !19 = !DILocation(line: 9, column: 7, scope: !20)83  !20 = distinct !DILexicalBlock(scope: !7, file: !1, line: 9, column: 7)84  !21 = !DILocation(line: 9, column: 7, scope: !7)85  !22 = !DILocation(line: 10, column: 9, scope: !23)86  !23 = distinct !DILexicalBlock(scope: !20, file: !1, line: 9, column: 18)87  !24 = !DILocation(line: 11, column: 3, scope: !23)88  !25 = !DILocation(line: 12, column: 9, scope: !26)89  !26 = distinct !DILexicalBlock(scope: !20, file: !1, line: 11, column: 10)90  !27 = !DILocation(line: 0, scope: !20)91  !28 = !DILocation(line: 15, column: 7, scope: !7)92  !29 = !DILocation(line: 16, column: 3, scope: !7)93  !30 = !DILocation(line: 17, column: 10, scope: !7)94  !31 = !DILocation(line: 17, column: 3, scope: !7)95 96...97---98name:            foo99alignment:       16100tracksRegLiveness: true101debugInstrRef: true102liveins:103  - { reg: '$rdi' }104  - { reg: '$rsi' }105frameInfo:106  stackSize:       24107  offsetAdjustment: -24108  maxAlignment:    1109  adjustsStack:    true110  hasCalls:        true111  maxCallFrameSize: 0112  cvBytesOfCalleeSavedRegisters: 16113fixedStack:114  - { id: 0, type: spill-slot, offset: -24, size: 8, alignment: 8, callee-saved-register: '$rbx' }115  - { id: 1, type: spill-slot, offset: -16, size: 8, alignment: 16, callee-saved-register: '$r14' }116machineFunctionInfo: {}117body:             |118  bb.0.entry:119    successors: %bb.2, %bb.1120    liveins: $rdi, $rsi, $r14, $rbx121 122    frame-setup PUSH64r killed $r14, implicit-def $rsp, implicit $rsp123    CFI_INSTRUCTION def_cfa_offset 16124    frame-setup PUSH64r killed $rbx, implicit-def $rsp, implicit $rsp125    CFI_INSTRUCTION def_cfa_offset 24126    frame-setup PUSH64r undef $rax, implicit-def $rsp, implicit $rsp127    CFI_INSTRUCTION def_cfa_offset 32128    CFI_INSTRUCTION offset $rbx, -24129    CFI_INSTRUCTION offset $r14, -16130    $r14 = MOV64rr $rsi131    $rbx = MOV64rr $rdi132    CALL64pcrel32 @ext, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, debug-location !15133    renamable $rbx = ADD64ri32 killed renamable $rbx, 12, implicit-def $eflags, debug-location !16134    $rdi = MOV64rr $rbx, debug-location !17135    CALL64pcrel32 @ext, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, debug-location !17136    renamable $r14 = ADD64ri32 killed renamable $r14, 1, implicit-def $eflags, debug-location !18137    CALL64pcrel32 @getlong, csr_64, implicit $rsp, implicit $ssp, implicit-def $rax, debug-location !19138    CMP64ri8 killed renamable $rax, 0, implicit-def $eflags, debug-location !19139    JCC_1 %bb.1, 5, implicit $eflags, debug-location !21140 141  bb.2.if.else:142    liveins: $rbx, $r14, $rax143 144    renamable $rbx = ADD64ri32 killed renamable $rbx, 2, implicit-def $eflags, debug-location !25145    DBG_PHI $r14, 1146    DBG_PHI $rbx, 2147    DBG_PHI $rax, 3148    $rax = MOV64ri 0149    JMP_1 %bb.3150 151  bb.1.if.then:152    liveins: $rbx, $r14, $rax153 154    renamable $rbx = ADD64ri32 killed renamable $rbx, 1, implicit-def $eflags, debug-location !22155    DBG_PHI $r14, 1156    DBG_PHI $rbx, 2157    DBG_PHI $rax, 3158 159  bb.3.if.end:160    liveins: $rbx, $r14161 162    DBG_INSTR_REF !14, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(1, 0), debug-location !13163    DBG_INSTR_REF !12, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(2, 0), debug-location !13164    DBG_INSTR_REF !12, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(3, 0), debug-location !13165 166    ; Value number 1 is live-through the above control flow from the two167    ; DBG_PHIs:168    ; CHECK:       DBG_INSTR_REF {{.+}}, dbg-instr-ref(1, 0)169    ; CHECK-NEXT:  DBG_VALUE_LIST {{.+}} $r14170    ;171    ; While value number 2 has different defs that merge on entry to bb.3.172    ; These are both in $rbx though, and we should find its location:173    ; CHECK:       DBG_INSTR_REF {{.+}}, dbg-instr-ref(2, 0)174    ; CHECK-NEXT:  DBG_VALUE_LIST {{.+}} $rbx175    ;176    ; Value number 3 cannot be resolved because $rax is clobbered in bb.2,177    ; meaning the merged value in bb.3 is incorrect. It should produce a178    ; DBG_VALUE $noreg.179    ; CHECK:       DBG_INSTR_REF {{.+}}, dbg-instr-ref(3, 0)180    ; CHECK-NEXT:  DBG_VALUE_LIST {{.+}} $noreg181 182    renamable $rbx = ADD64rr killed renamable $rbx, killed renamable $r14, implicit-def $eflags, debug-location !28183    DBG_INSTR_REF !12, !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(2, 0), debug-location !13184 185    ; After clobbering rbx, the variable location should not be available.186    ; CHECK:       DBG_INSTR_REF {{.+}}, dbg-instr-ref(2, 0)187    ; CHECK-NEXT:  DBG_VALUE_LIST {{.+}} $noreg188 189    $rdi = MOV64rr $rbx, debug-location !29190    CALL64pcrel32 @ext, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, debug-location !29191    $eax = MOV32rr $ebx, implicit killed $rbx, debug-location !31192    $rsp = frame-destroy ADD64ri8 $rsp, 8, implicit-def dead $eflags, debug-location !31193    CFI_INSTRUCTION def_cfa_offset 24, debug-location !31194    $rbx = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !31195    CFI_INSTRUCTION def_cfa_offset 16, debug-location !31196    $r14 = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !31197    CFI_INSTRUCTION def_cfa_offset 8, debug-location !31198    RET64 implicit $eax, debug-location !31199 200...201