[all-commits] [llvm/llvm-project] b55367: [CIR] Cast global addresses to their declared addr...

David Rivera via All-commits all-commits at lists.llvm.org
Thu Oct 1 17:52:39 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b55367c5102184b493edcde61fb2c7ec8a8e0f76
      https://github.com/llvm/llvm-project/commit/b55367c5102184b493edcde61fb2c7ec8a8e0f76
  Author: David Rivera <davidriverg at gmail.com>
  Date:   2026-10-01 (Thu, 01 Oct 2026)

  Changed paths:
    M clang/lib/CIR/CodeGen/CIRGenDecl.cpp
    M clang/lib/CIR/CodeGen/CIRGenExpr.cpp
    M clang/lib/CIR/CodeGen/CIRGenModule.cpp
    M clang/lib/CIR/CodeGen/CIRGenModule.h
    M clang/test/CIR/CodeGen/amdgpu-array-addrspace.cpp
    M clang/test/CIR/CodeGenCUDA/address-spaces.cu
    A clang/test/CIR/CodeGenCUDA/global-addrspace-cast.cu

  Log Message:
  -----------
  [CIR] Cast global addresses to their declared address space (#226649)

Opened to address a portion of
https://github.com/llvm/llvm-project/issues/226629


In CUDA, `__shared__ int sh` has type `int` but lives in AS 3. Classic
codegen casts the address to the declared type's AS where it's formed,
so users just see a generic pointer. We weren't doing that, so things
like `return &sh;` bitcast the slot instead, and NVPTX never got a
`cvta.shared`. This patch does the same cast in `getAddrOfGlobalVar` and
wherever static locals are fetched.

This also drops the comment claiming lowering would emit the cast for
us. That's only true for OpenCL, where the declared type already carries
the AS. LowerToLLVM never inserts casts on its own.

Assisted-by: Claude / Opus 5.5


  Commit: 6c1d1068a26d789f0a7d0a4b40dc77189a0042ab
      https://github.com/llvm/llvm-project/commit/6c1d1068a26d789f0a7d0a4b40dc77189a0042ab
  Author: David Rivera <davidriverg at gmail.com>
  Date:   2026-10-01 (Thu, 01 Oct 2026)

  Changed paths:
    M clang/lib/CIR/CodeGen/CIRGenAsm.cpp
    M clang/lib/CIR/CodeGen/CIRGenBuilder.h
    M clang/lib/CIR/CodeGen/CIRGenBuiltinNVPTX.cpp
    M clang/lib/CIR/CodeGen/CIRGenExpr.cpp
    M clang/lib/CIR/Dialect/IR/CIRDialect.cpp
    A clang/test/CIR/CodeGen/get-member-addrspace.cpp
    A clang/test/CIR/CodeGenHIP/inline-asm-multi-output-addrspace.hip
    M clang/test/CIR/CodeGenSYCL/kernel-caller-address-space.cpp
    M clang/test/CIR/IR/invalid-struct.cir

  Log Message:
  -----------
  [CIR] Propagate the record address space to get_member (#226650)

Addresses: https://github.com/llvm/llvm-project/issues/226629

A member lives in its record's address space, but a few `get_member`
builders always produced a default-AS pointer. On SPIR-V that's private,
so a SYCL kernel was reading its captured pointer through a private
pointer. This patch takes the AS from the base and adds a verifier check
so we catch any stragglers.

Assisted-by: Claude / Opus 5.5


Compare: https://github.com/llvm/llvm-project/compare/5c8e5ed14687...6c1d1068a26d

To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list