Skip to content

[NVPTX][NFC] Update NVPTXLowerAlloca comments to use opaque pointer syntax#190573

Open
balaji-krishna-atukuri wants to merge 1 commit intollvm:mainfrom
balaji-krishna-atukuri:nvptx-lower-alloca-opaque-ptr
Open

[NVPTX][NFC] Update NVPTXLowerAlloca comments to use opaque pointer syntax#190573
balaji-krishna-atukuri wants to merge 1 commit intollvm:mainfrom
balaji-krishna-atukuri:nvptx-lower-alloca-opaque-ptr

Conversation

@balaji-krishna-atukuri
Copy link
Copy Markdown
Contributor

@balaji-krishna-atukuri balaji-krishna-atukuri commented Apr 6, 2026

Modernize the header comment IR examples in NVPTXLowerAlloca.cpp to use opaque pointer syntax (ptr instead of i32*, i32 addrspace(5)*, etc.), matching the LLVM-wide move to opaque pointers in LLVM 17+.

Changes:

  • Update IR examples from typed pointers (i32*, i32 addrspace(5)*) to opaque pointer syntax (ptr, ptr addrspace(5))
  • Fix grammar: "For all alloca instructions, and add a pair of cast" → "add a pair of casts"
  • Fix incorrect variable reference: second addrspacecast was using %A (the alloca result) instead of %Local (the result of the first addrspacecast to local address space)

Flow:

 ┌──────────┐    ┌──────────────────┐    ┌──────────────────┐
 │ Frontend │--->│ NVPTXLowerAlloca  │--->│ InferAddrSpaces  │
 └──────────┘    │  (comments only)  │    └──────────────────┘
                 │    <- MODIFIED    │
                 └──────────────────┘

IR (comment fix — before vs after):

Before (typed pointers, incorrect variable):
  %A     = alloca i32
  %Local = addrspacecast i32* %A to i32 addrspace(5)*
  %Generic = addrspacecast i32 addrspace(5)* %A to i32*
                                              ^^ wrong: should be %Local

After (opaque pointers, correct variable):
  %A     = alloca i32
  %Local = addrspacecast ptr %A to ptr addrspace(5)
  %Generic = addrspacecast ptr addrspace(5) %Local to ptr
                                            ^^^^^^ fixed

Files changed: 1 file, +5/-5 lines

Comment-only change, no functional impact.

…yntax

Modernize the header comment IR examples to use opaque pointer syntax
(ptr instead of i32*, i32 addrspace(5)*, etc.), matching the LLVM-wide
move to opaque pointers in LLVM 17+. Also fix a grammar issue in the
comment.
@llvmbot
Copy link
Copy Markdown
Member

llvmbot commented Apr 6, 2026

@llvm/pr-subscribers-backend-nvptx

Author: Balaji Krishna Yugandhar Atukuri (balaji-krishna-atukuri)

Changes

Modernize the header comment IR examples in NVPTXLowerAlloca.cpp to use opaque pointer syntax (ptr instead of i32*, i32 addrspace(5)*, etc.), matching the LLVM-wide move to opaque pointers in LLVM 17+.

Also fix a grammar issue: "For all alloca instructions, and add a pair of cast" → "For all alloca instructions, add a pair of casts".

Comment-only change, no functional impact.


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

1 Files Affected:

  • (modified) llvm/lib/Target/NVPTX/NVPTXLowerAlloca.cpp (+5-5)
diff --git a/llvm/lib/Target/NVPTX/NVPTXLowerAlloca.cpp b/llvm/lib/Target/NVPTX/NVPTXLowerAlloca.cpp
index 1583d45eeb3a6..2262decfc3c76 100644
--- a/llvm/lib/Target/NVPTX/NVPTXLowerAlloca.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXLowerAlloca.cpp
@@ -6,18 +6,18 @@
 //
 //===----------------------------------------------------------------------===//
 //
-// For all alloca instructions, and add a pair of cast to local address for
+// For all alloca instructions, add a pair of casts to local address for
 // each of them. For example,
 //
 //   %A = alloca i32
-//   store i32 0, i32* %A ; emits st.u32
+//   store i32 0, ptr %A ; emits st.u32
 //
 // will be transformed to
 //
 //   %A = alloca i32
-//   %Local = addrspacecast i32* %A to i32 addrspace(5)*
-//   %Generic = addrspacecast i32 addrspace(5)* %A to i32*
-//   store i32 0, i32 addrspace(5)* %Generic ; emits st.local.u32
+//   %Local = addrspacecast ptr %A to ptr addrspace(5)
+//   %Generic = addrspacecast ptr addrspace(5) %Local to ptr
+//   store i32 0, ptr %Generic ; emits st.local.u32
 //
 // And we will rely on NVPTXInferAddressSpaces to combine the last two
 // instructions.

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.

2 participants