[llvm] [NVPTX] Change the alloca address space in NVPTXLowerAlloca (PR #154814)

Artem Belevich via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 21 16:00:29 PDT 2025


================
@@ -1484,7 +1484,8 @@ void NVPTXAsmPrinter::setAndEmitFunctionVirtualRegisters(
   if (NumBytes) {
     O << "\t.local .align " << MFI.getMaxAlign().value() << " .b8 \t"
       << DEPOTNAME << getFunctionNumber() << "[" << NumBytes << "];\n";
-    if (static_cast<const NVPTXTargetMachine &>(MF.getTarget()).is64Bit()) {
+    if (static_cast<const NVPTXTargetMachine &>(MF.getTarget())
+            .getPointerSize(ADDRESS_SPACE_LOCAL) == 8) {
----------------
Artem-B wrote:

We also have the "--nvptx-short-ptr" option which controls whether local/shared pointers are 32-bit or 64-bit, so using `getPointerSize(ADDRESS_SPACE_LOCAL) == 8` here is not the right source of the info.
I think you want to make the call about pointer size separately for the generic pointer and for the local pointer. The original code choice happened to be correct for generic pointer (though obtained indirectly via compilation mode), and happened to work for the local pointer because we can always put 32-bit local pointer into a 64bit register.

https://github.com/llvm/llvm-project/pull/154814


More information about the llvm-commits mailing list