Skip to content

Commit f59cdbb

Browse files
authored
[CIR][CUDA] Fix address space values for NVPTX (#1445)
Based on https://github.com/llvm/clangir/blob/7f66a204c4ba1f674cfe0e16e2c9c6b65ca70bc8/clang/lib/Basic/Targets/NVPTX.h#L27, the current address space values are incorrect. This PR fixes these values.
1 parent a26ebb4 commit f59cdbb

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

clang/lib/CIR/Dialect/Transforms/TargetLowering/Targets/NVPTX.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ class NVPTXTargetLoweringInfo : public TargetLoweringInfo {
5252
case Kind::offload_global:
5353
return 1;
5454
case Kind::offload_constant:
55-
return 2;
56-
case Kind::offload_generic:
5755
return 4;
56+
case Kind::offload_generic:
57+
return 0;
5858
default:
5959
cir_cconv_unreachable("Unknown CIR address space for this target");
6060
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include "../Inputs/cuda.h"
2+
3+
// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fclangir \
4+
// RUN: -fcuda-is-device -emit-llvm -target-sdk-version=12.3 \
5+
// RUN: %s -o %t.ll
6+
// RUN: FileCheck --check-prefix=LLVM-DEVICE --input-file=%t.ll %s
7+
8+
9+
__shared__ int a;
10+
11+
// LLVM-DEVICE: @a = addrspace(3) {{.*}}
12+
13+
__device__ int b;
14+
15+
// LLVM-DEVICE: @b = addrspace(1) {{.*}}
16+
17+
// __constant__ int c;
18+
19+
// XFAIL-LLVM-DEVICE: @c = addrspace(4) {{.*}}

0 commit comments

Comments
 (0)