Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improvements to call site register worklist
Summary: This fixes PR44118. For cases where we have a chain like this: R8 = R1 (entry value) R0 = R8 call @foo R0 the code that emits call site entries using entry values would not follow that chain, instead emitting a call site entry with R8 as location rather than R0. Such a case was discovered when originally adding dbgcall-site-orr-moves.mir. This patch fixes that issue. This is done by changing the ForwardedRegWorklist set to a map in which the worklist registers always map to the parameter registers that they describe. Another thing this patch fixes is that worklist registers now can describe more than one parameter register at a time. Such a case occurred in dbgcall-site-interpretation.mir, resulting in a call site entry not being emitted for one of the parameters. Reviewers: djtodoro, NikolaPrica, aprantl, vsk Reviewed By: vsk Subscribers: hiraditya, llvm-commits Tags: #debug-info, #llvm Differential Revision: https://reviews.llvm.org/D73168
- Loading branch information
Showing
6 changed files
with
258 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
llvm/test/DebugInfo/MIR/X86/dbgcall-site-partial-describe.mir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# RUN: llc -debug-entry-values -start-before=livedebugvalues -filetype=obj -o - %s \ | ||
# RUN: | llvm-dwarfdump - | FileCheck %s --implicit-check-not=DW_TAG_GNU_call_site_parameter | ||
|
||
--- | | ||
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" | ||
target triple = "x86_64-unknown-linux-gnu" | ||
|
||
; Function Attrs: nounwind uwtable | ||
define void @foo() #0 !dbg !12 { | ||
entry: | ||
call void @call(i32 123, i32 undef), !dbg !15 | ||
ret void, !dbg !16 | ||
} | ||
|
||
declare !dbg !4 void @call(i32, i32) | ||
|
||
attributes #0 = { nounwind uwtable } | ||
|
||
!llvm.dbg.cu = !{!0} | ||
!llvm.module.flags = !{!8, !9, !10} | ||
!llvm.ident = !{!11} | ||
|
||
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 11.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, splitDebugInlining: false, nameTableKind: None) | ||
!1 = !DIFile(filename: "clobber.c", directory: "/") | ||
!2 = !{} | ||
!3 = !{!4} | ||
!4 = !DISubprogram(name: "call", scope: !1, file: !1, line: 1, type: !5, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2) | ||
!5 = !DISubroutineType(types: !6) | ||
!6 = !{null, !7, !7} | ||
!7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) | ||
!8 = !{i32 7, !"Dwarf Version", i32 4} | ||
!9 = !{i32 2, !"Debug Info Version", i32 3} | ||
!10 = !{i32 1, !"wchar_size", i32 4} | ||
!11 = !{!"clang version 11.0.0"} | ||
!12 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 3, type: !13, scopeLine: 3, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2) | ||
!13 = !DISubroutineType(types: !14) | ||
!14 = !{null} | ||
!15 = !DILocation(line: 5, scope: !12) | ||
!16 = !DILocation(line: 6, scope: !12) | ||
|
||
... | ||
--- | ||
name: foo | ||
callSites: | ||
- { bb: 0, offset: 4, fwdArgRegs: | ||
- { arg: 0, reg: '$edi' } | ||
- { arg: 1, reg: '$esi' } } | ||
body: | | ||
bb.0.entry: | ||
frame-setup PUSH64r undef $rax, implicit-def $rsp, implicit $rsp | ||
CFI_INSTRUCTION def_cfa_offset 16 | ||
$esi = MOV32ri 123, debug-location !15 | ||
$edi = MOV32rr $esi, implicit-def $esi, debug-location !15 | ||
CALL64pcrel32 @call, csr_64, implicit $rsp, implicit $ssp, implicit killed $edi, implicit undef $esi, implicit-def $rsp, implicit-def $ssp, debug-location !15 | ||
$rax = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !16 | ||
CFI_INSTRUCTION def_cfa_offset 8, debug-location !16 | ||
RETQ debug-location !16 | ||
... | ||
|
||
# In this test an implicit-def has been added to the MOV32rr instruction to | ||
# simulate a situation where one instruction defines two call site worklist | ||
# registers, and where we end up with one of the registers being described by | ||
# the previous value of the other register that is clobbered by this | ||
# instruction. | ||
# | ||
# In this reproducer we should end up with only one call site entry, with that | ||
# being for $rdi. | ||
# | ||
# This test uses an implicit CHECK-NOT to verify that only one call site | ||
# parameter entry is emitted. | ||
# | ||
# A somewhat more realistic scenario would for example be the following in a | ||
# made-up ISA: | ||
# | ||
# $r1 = mv 123 | ||
# $r0, $r1 = mvri $r1, <undescribable value> | ||
# call @foo, $r0, $r1 | ||
|
||
# CHECK: DW_TAG_GNU_call_site_parameter | ||
# CHECK-NEXT: DW_AT_location (DW_OP_reg5 RDI) | ||
# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_constu 0x7b) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# RUN: llc -debug-entry-values -start-before=livedebugvalues -filetype=obj -o - %s \ | ||
# RUN: | llvm-dwarfdump - | FileCheck %s --implicit-check-not=DW_TAG_GNU_call_site_parameter | ||
|
||
--- | | ||
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" | ||
target triple = "x86_64-unknown-linux-gnu" | ||
|
||
; Function Attrs: nounwind uwtable | ||
define void @move_around_args(i32 %a) #0 !dbg !12 { | ||
entry: | ||
call void @call2(i32 123, i32 %a), !dbg !15 | ||
ret void, !dbg !16 | ||
} | ||
|
||
declare !dbg !4 dso_local void @call2(i32, i32) | ||
|
||
attributes #0 = { nounwind uwtable } | ||
|
||
!llvm.dbg.cu = !{!0} | ||
!llvm.module.flags = !{!8, !9, !10} | ||
!llvm.ident = !{!11} | ||
|
||
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 11.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, splitDebugInlining: false, nameTableKind: None) | ||
!1 = !DIFile(filename: "worklist.c", directory: "/") | ||
!2 = !{} | ||
!3 = !{!4} | ||
!4 = !DISubprogram(name: "call2", scope: !1, file: !1, line: 1, type: !5, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2) | ||
!5 = !DISubroutineType(types: !6) | ||
!6 = !{null, !7, !7} | ||
!7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) | ||
!8 = !{i32 7, !"Dwarf Version", i32 4} | ||
!9 = !{i32 2, !"Debug Info Version", i32 3} | ||
!10 = !{i32 1, !"wchar_size", i32 4} | ||
!11 = !{!"clang version 11.0.0"} | ||
!12 = distinct !DISubprogram(name: "move_around_args", scope: !1, file: !1, line: 3, type: !13, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2) | ||
!13 = !DISubroutineType(types: !14) | ||
!14 = !{null, !7} | ||
!15 = !DILocation(line: 4, scope: !12) | ||
!16 = !DILocation(line: 5, scope: !12) | ||
|
||
... | ||
--- | ||
name: move_around_args | ||
liveins: | ||
- { reg: '$edi' } | ||
callSites: | ||
- { bb: 0, offset: 12, fwdArgRegs: | ||
- { arg: 0, reg: '$edi' } | ||
- { arg: 1, reg: '$esi' } } | ||
body: | | ||
bb.0.entry: | ||
liveins: $edi | ||
frame-setup PUSH64r undef $rax, implicit-def $rsp, implicit $rsp | ||
CFI_INSTRUCTION def_cfa_offset 16 | ||
$esi = MOV32ri 123 | ||
; Move the values around between different registers. | ||
$edx = MOV32rr $edi | ||
$edi = MOV32rr $esi | ||
$esi = MOV32rr $edx | ||
$edx = MOV32rr $edi | ||
$eax = MOV32rr $esi | ||
$esi = MOV32rr $edx | ||
$edx = MOV32rr $eax | ||
$edi = MOV32rr $esi | ||
$esi = MOV32rr $edx | ||
CALL64pcrel32 @call2, csr_64, implicit $rsp, implicit $ssp, implicit $edi, implicit $esi, implicit-def $rsp, implicit-def $ssp, debug-location !15 | ||
$rax = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !16 | ||
CFI_INSTRUCTION def_cfa_offset 8, debug-location !16 | ||
RETQ debug-location !16 | ||
... | ||
|
||
# Verify that we emit correct call site parameter entries even after moving | ||
# around the call site values between different registers. | ||
# | ||
# This test uses an implicit CHECK-NOT to verify that only two call site | ||
# parameter entries are emitted. | ||
|
||
# CHECK: DW_TAG_GNU_call_site_parameter | ||
# CHECK-NEXT: DW_AT_location (DW_OP_reg5 RDI) | ||
# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_constu 0x7b) | ||
|
||
# CHECK: DW_TAG_GNU_call_site_parameter | ||
# CHECK-NEXT: DW_AT_location (DW_OP_reg4 RSI) | ||
# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_GNU_entry_value(DW_OP_reg5 RDI)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters