Skip to content

Conversation

@willghatch
Copy link
Contributor

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.

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.
@llvmbot
Copy link
Member

llvmbot commented Oct 8, 2024

@llvm/pr-subscribers-backend-nvptx

Author: William G Hatch (willghatch)

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/111596.diff

1 Files Affected:

  • (modified) llvm/lib/Target/NVPTX/NVPTXRegisterInfo.cpp (+5)
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());

@willghatch willghatch merged commit 64a22b3 into main Oct 9, 2024
11 checks passed
@willghatch willghatch deleted the users/willghatch/ptx-depot-register-fix branch October 9, 2024 01:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants