[llvm] [NVPTX] fix debug register encoding of special %Depot register (PR #111596)

William G Hatch via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 8 15:18:33 PDT 2024


https://github.com/willghatch created https://github.com/llvm/llvm-project/pull/111596

cuda-gdb doesn't seem to be able to read the `%Depot` register, but because we always copy it to `%SP` in lowering, simply switching to use it fixes the problem.

>From 24f7157a575e7867247716b78a852b1af6f98d83 Mon Sep 17 00:00:00 2001
From: William G Hatch <william at hatch.uno>
Date: Tue, 8 Oct 2024 20:54:01 +0000
Subject: [PATCH] [NVPTX] fix debug register encoding of special %Depot
 register

cuda-gdb doesn't seem to be able to read the `%Depot` register, but because we always copy it to `%SP` in lowering, simply switching to use it fixes the problem.
---
 llvm/lib/Target/NVPTX/NVPTXRegisterInfo.cpp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/llvm/lib/Target/NVPTX/NVPTXRegisterInfo.cpp b/llvm/lib/Target/NVPTX/NVPTXRegisterInfo.cpp
index c30372fed1832d..dc2584645b314c 100644
--- a/llvm/lib/Target/NVPTX/NVPTXRegisterInfo.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXRegisterInfo.cpp
@@ -176,6 +176,11 @@ void NVPTXRegisterInfo::addToDebugRegisterMap(
 int64_t NVPTXRegisterInfo::getDwarfRegNum(MCRegister RegNum, bool isEH) const {
   if (Register::isPhysicalRegister(RegNum)) {
     std::string name = NVPTXInstPrinter::getRegisterName(RegNum.id());
+    // In NVPTXFrameLowering.cpp, we do arrange for %Depot to be accessible from
+    // %SP. Using the %Depot register doesn't provide any debug info in
+    // cuda-gdb, but switching it to %SP does.
+    if (RegNum.id() == NVPTX::VRDepot)
+      name = "%SP";
     return encodeRegisterForDwarf(name);
   }
   uint64_t lookup = debugRegisterMap.lookup(RegNum.id());



More information about the llvm-commits mailing list