Skip to content

Commit 16fed31

Browse files
authored
[AMDGPU] Fix debug line table for MSG_DEALLOC_VGPRS optimization (#88924)
Deallocating VGPRs interferes with doing a context save, which is needed for GDB to report a breakpoint. So, in this sequence: s_sendmsg MSG_DEALLOC_VGPRS s_endpgm We now use the debug location of the s_endpgm for the s_sendmsg, so a breakpoint set in the debugger at the end of a shader will be hit before deallocating VGPRs.
1 parent e6ee191 commit 16fed31

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed

llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2665,10 +2665,11 @@ bool SIInsertWaitcnts::runOnMachineFunction(MachineFunction &MF) {
26652665
// instructions.
26662666
for (MachineInstr *MI : ReleaseVGPRInsts) {
26672667
if (ST->requiresNopBeforeDeallocVGPRs()) {
2668-
BuildMI(*MI->getParent(), MI, DebugLoc(), TII->get(AMDGPU::S_NOP))
2668+
BuildMI(*MI->getParent(), MI, MI->getDebugLoc(), TII->get(AMDGPU::S_NOP))
26692669
.addImm(0);
26702670
}
2671-
BuildMI(*MI->getParent(), MI, DebugLoc(), TII->get(AMDGPU::S_SENDMSG))
2671+
BuildMI(*MI->getParent(), MI, MI->getDebugLoc(),
2672+
TII->get(AMDGPU::S_SENDMSG))
26722673
.addImm(AMDGPU::SendMsg::ID_DEALLOC_VGPRS_GFX11Plus);
26732674
Modified = true;
26742675
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2+
# RUN: llc -mtriple=amdgcn -mcpu=gfx1100 -run-pass=si-insert-waitcnts -o - %s | FileCheck %s
3+
4+
# Verify that si-insert-waitcnts copies debug locations from the s_endpgm to the
5+
# "dealloc vgprs" s_sendmsg. If these are not present, the debugger will be
6+
# unable to break at the end of the shader.
7+
8+
--- |
9+
define amdgpu_ps void @test() !dbg !5 { ret void, !dbg !8 }
10+
11+
!llvm.dbg.cu = !{!0}
12+
!llvm.debugify = !{!2, !3}
13+
!llvm.module.flags = !{!4}
14+
15+
!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
16+
!1 = !DIFile(filename: "t.ll", directory: "/")
17+
!2 = !{i32 1}
18+
!3 = !{i32 0}
19+
!4 = !{i32 2, !"Debug Info Version", i32 3}
20+
!5 = distinct !DISubprogram(name: "test", linkageName: "test", scope: null, file: !1, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0)
21+
!6 = !DISubroutineType(types: !7)
22+
!7 = !{}
23+
!8 = !DILocation(line: 1, column: 1, scope: !5)
24+
...
25+
26+
---
27+
name: test
28+
machineFunctionInfo:
29+
isEntryFunction: true
30+
body: |
31+
bb.0:
32+
; CHECK-LABEL: name: test
33+
; CHECK: GLOBAL_STORE_DWORD undef renamable $vgpr0_vgpr1, killed renamable $vgpr1, 0, 4, implicit $exec
34+
; CHECK-NEXT: S_NOP 0, debug-location !8
35+
; CHECK-NEXT: S_SENDMSG 3, implicit $exec, implicit $m0, debug-location !8
36+
; CHECK-NEXT: S_ENDPGM 0, debug-location !8
37+
GLOBAL_STORE_DWORD undef renamable $vgpr0_vgpr1, killed renamable $vgpr1, 0, 4, implicit $exec
38+
S_ENDPGM 0, debug-location !8
39+
...
40+

0 commit comments

Comments
 (0)