[clang] [CUDA][HIP] Mangle language address spaces by name on the device (PR #245364)
Artem Belevich via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 27 18:51:41 PST 2026
================
@@ -925,7 +925,11 @@ static bool isAddrSpaceMapManglingEnabled(const TargetInfo &TI,
const LangOptions &LangOpts) {
switch (LangOpts.getAddressSpaceMapMangling()) {
case LangOptions::ASMM_Target:
- return TI.useAddressSpaceMapMangling();
+ // In CUDA and HIP, the host registers kernels with their device names, so
+ // the host and the device must mangle them in the same way. The host
+ // doesn't know which numbers the device maps language address spaces to,
+ // so both sides mangle them by name.
----------------
Artem-B wrote:
Nit: `getDeviceSideName` also covers registered `__device__`/`__constant__`/`__managed__` variables (e.g., `cudaMemcpyToSymbol`) and `__builtin_get_device_side_mangled_name`, not just kernels. It would also be helpful to mention the multi-target fatbin rationale (e.g., AMDGPU vs. SPIR-V mapping `opencl_constant` to AS `4` vs. `2` and `opencl_private` to `5` vs. `0`), since that explains why the host can't simply mirror a single device's map.
```suggestion
// In CUDA and HIP, the host registers kernels and device variables with
// their device names, so host and device must mangle them identically.
// Device targets can map the same language address space to different
// numbers (e.g., AMDGPU vs. SPIR-V), so both sides mangle them by name.
```
https://github.com/llvm/llvm-project/pull/245364
More information about the cfe-commits
mailing list