brintos

brintos / llvm-project-archived public Read only

0
0
Text · 8.2 KiB · ab57a96 Raw
159 lines · plain
1# These tests check that DBG_VALUE intervals are correctly coalesced (or not) in2# LiveDebugVariables.3# NOTE: We do not currently handle partially overlapping fragments in LDV.4#5# The IR in this file has been modified by hand, generated from this source:6# void escape(int *);7# extern int global;8# void f(int x) {9#   escape(&x);10#   x = 1;11#   global = x;12#   x = 2;13#   escape(&x);14# }15 16# RUN: llc %s -start-before=machine-scheduler -stop-after=virtregrewriter -o - -experimental-debug-variable-locations=false \17# RUN:     | FileCheck %s --implicit-check-not=DBG_VALUE18 19# Verify that DBG_VALUEs with same { Variable, Fragment } but different DIExpressions20# are not coalesced.21#22# DV1 %0 "x" (deref) --+-- Do not coalesce these because DV2 refers to the same bits.23# DV2 %0 "x" ()        |24# DV3 %0 "x" (deref) --+25#26# CHECK: name: f127# CHECK: DBG_VALUE %stack.0.x.addr, $noreg, ![[VAR:[0-9]+]], !DIExpression(DW_OP_deref)28# CHECK: DBG_VALUE %stack.0.x.addr, $noreg, ![[VAR]],        !DIExpression()29# CHECK: DBG_VALUE %stack.0.x.addr, $noreg, ![[VAR]],        !DIExpression(DW_OP_deref)30 31# Verify that DBG_VALUEs with same { Variable, Fragment } and { Location, DIExpression } are32# coalesced if there are no intervening DBG_VALUEs with the same { Variable, Fragment }.33#34# DV1 %0 "x" (fragment 00 16) --+-- Coalesce these because DV2 refers to different bits.35# DV2 %0 "x" (fragment 16 16)   |36# DV3 %0 "x" (fragment 00 16) --+37#38# CHECK: name: f239# CHECK: DBG_VALUE %stack.0.x.addr, $noreg, ![[VAR:[0-9]+]], !DIExpression(DW_OP_deref, DW_OP_LLVM_fragment, 0, 16)40# CHECK: DBG_VALUE %stack.0.x.addr, $noreg, ![[VAR]],        !DIExpression(DW_OP_LLVM_fragment, 16, 16)41 42--- |43  target triple = "x86_64-unknown-linux-gnu"44 45  @global = external global i32, align 446  declare void @llvm.dbg.value(metadata, metadata, metadata)47  declare void @escape(ptr)48 49  define void @f1(i32 %x) !dbg !6 {50  entry:51    %x.addr = alloca i32, align 452    store i32 %x, ptr %x.addr, align 453    call void @llvm.dbg.value(metadata ptr %x.addr, metadata !11, metadata !DIExpression(DW_OP_deref)), !dbg !1254    call void @escape(ptr %x.addr), !dbg !1255    call void @llvm.dbg.value(metadata ptr %x.addr, metadata !11, metadata !DIExpression()), !dbg !1256    store i32 1, ptr @global, align 4, !dbg !1257    call void @llvm.dbg.value(metadata ptr %x.addr, metadata !11, metadata !DIExpression(DW_OP_deref)), !dbg !1258    store i32 2, ptr %x.addr, align 4, !dbg !1259    call void @escape(ptr %x.addr), !dbg !1260    ret void, !dbg !1261  }62 63  define void @f2(i32 %x) !dbg !13 {64  entry:65    %x.addr = alloca i32, align 466    store i32 %x, ptr %x.addr, align 467    call void @llvm.dbg.value(metadata ptr %x.addr, metadata !14, metadata !DIExpression(DW_OP_deref, DW_OP_LLVM_fragment, 0, 16)), !dbg !1568    call void @escape(ptr %x.addr)69    call void @llvm.dbg.value(metadata ptr %x.addr, metadata !14, metadata !DIExpression(DW_OP_LLVM_fragment, 16, 16)), !dbg !1570    store i32 1, ptr @global, align 471    call void @llvm.dbg.value(metadata ptr %x.addr, metadata !14, metadata !DIExpression(DW_OP_deref, DW_OP_LLVM_fragment, 0, 16)), !dbg !1572    store i32 2, ptr %x.addr, align 473    call void @escape(ptr %x.addr)74    ret void75  }76 77  !llvm.dbg.cu = !{!0}78  !llvm.module.flags = !{!3, !4}79  !llvm.ident = !{!5}80 81  !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 11.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)82  !1 = !DIFile(filename: "test.c", directory: "")83  !2 = !{}84  !3 = !{i32 2, !"Dwarf Version", i32 4}85  !4 = !{i32 2, !"Debug Info Version", i32 3}86  !5 = !{!"clang version 11.0.0 "}87  !6 = distinct !DISubprogram(name: "f1", scope: !1, file: !1, line: 3, type: !7, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !10)88  !7 = !DISubroutineType(types: !8)89  !8 = !{null, !9}90  !9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)91  !10 = !{!11}92  !11 = !DILocalVariable(name: "x", arg: 1, scope: !6, file: !1, line: 3, type: !9)93  !12 = !DILocation(line: 3, column: 12, scope: !6)94  !13 = distinct !DISubprogram(name: "f2", scope: !1, file: !1, line: 20, type: !7, scopeLine: 20, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !{!14})95  !14 = !DILocalVariable(name: "x", arg: 1, scope: !13, file: !1, line: 21, type: !9)96  !15 = !DILocation(line: 23, column: 12, scope: !13)97 98...99---100name:            f1101tracksRegLiveness: true102frameInfo:103  adjustsStack:    true104stack:105  - { id: 0, name: x.addr, type: default, offset: 0, size: 4, alignment: 4,106      stack-id: default, callee-saved-register: '', callee-saved-restored: true,107      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }108body:             |109  bb.0.entry:110    liveins: $edi111    %0:gr32 = COPY $edi112    MOV32mr %stack.0.x.addr, 1, $noreg, 0, $noreg, %0 :: (store (s32) into %ir.x.addr)113    DBG_VALUE %stack.0.x.addr, $noreg, !11, !DIExpression(DW_OP_deref), debug-location !12114    ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp, debug-location !12115    %1:gr64 = LEA64r %stack.0.x.addr, 1, $noreg, 0, $noreg116    $rdi = COPY %1, debug-location !12117    CALL64pcrel32 @escape, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp, debug-location !12118    ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp, debug-location !12119    DBG_VALUE %stack.0.x.addr, $noreg, !11, !DIExpression(), debug-location !12120    MOV32mi $rip, 1, $noreg, @global, $noreg, 1, debug-location !12 :: (store (s32) into @global)121    DBG_VALUE %stack.0.x.addr, $noreg, !11, !DIExpression(DW_OP_deref), debug-location !12122    MOV32mi %stack.0.x.addr, 1, $noreg, 0, $noreg, 2, debug-location !12 :: (store (s32) into %ir.x.addr)123    ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp, debug-location !12124    $rdi = COPY %1, debug-location !12125    CALL64pcrel32 @escape, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp, debug-location !12126    ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp, debug-location !12127    RET 0, debug-location !12128...129---130name:            f2131tracksRegLiveness: true132frameInfo:133  adjustsStack:    true134stack:135  - { id: 0, name: x.addr, type: default, offset: 0, size: 4, alignment: 4,136      stack-id: default, callee-saved-register: '', callee-saved-restored: true,137      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }138body:             |139  bb.0.entry:140    liveins: $edi141    %0:gr32 = COPY $edi142    MOV32mr %stack.0.x.addr, 1, $noreg, 0, $noreg, %0 :: (store (s32) into %ir.x.addr)143    DBG_VALUE %stack.0.x.addr, $noreg, !14, !DIExpression(DW_OP_deref, DW_OP_LLVM_fragment, 0, 16), debug-location !15144    ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp145    %1:gr64 = LEA64r %stack.0.x.addr, 1, $noreg, 0, $noreg146    $rdi = COPY %1147    CALL64pcrel32 @escape, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp148    ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp149    DBG_VALUE %stack.0.x.addr, $noreg, !14, !DIExpression(DW_OP_LLVM_fragment, 16, 16), debug-location !15150    MOV32mi $rip, 1, $noreg, @global, $noreg, 1 :: (store (s32) into @global)151    DBG_VALUE %stack.0.x.addr, $noreg, !14, !DIExpression(DW_OP_deref, DW_OP_LLVM_fragment, 0, 16), debug-location !15152    MOV32mi %stack.0.x.addr, 1, $noreg, 0, $noreg, 2 :: (store (s32) into %ir.x.addr)153    ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp154    $rdi = COPY %1155    CALL64pcrel32 @escape, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp156    ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp157    RET 0158...159