[clang] clang/OpenCL: Add baseline test showing broken codegen (PR #138862)
Artem Belevich via cfe-commits
cfe-commits at lists.llvm.org
Wed May 7 10:55:03 PDT 2025
================
@@ -109,3 +109,48 @@ void func2(void) {
void func3(void) {
float a[16][1] = {{0.}};
}
+
+// CL12-LABEL: define dso_local void @wrong_store_type_private_pointer_alloca(
+// CL12-SAME: ) #[[ATTR0]] {
+// CL12-NEXT: [[ENTRY:.*:]]
+// CL12-NEXT: [[PLONG:%.*]] = alloca i64, align 8, addrspace(5)
+// CL12-NEXT: [[PLONGP:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5)
+// CL12-NEXT: [[GLONGP:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5)
+// CL12-NEXT: store i64 5, ptr addrspace(5) [[PLONG]], align 8
+// CL12-NEXT: store ptr addrspace(5) [[PLONG]], ptr addrspace(5) [[PLONGP]], align 4
+// CL12-NEXT: [[TMP0:%.*]] = load ptr addrspace(5), ptr addrspace(5) [[PLONGP]], align 4
+// CL12-NEXT: store i64 8, ptr addrspace(5) [[TMP0]], align 8
+// CL12-NEXT: store ptr addrspace(5) [[PLONG]], ptr addrspace(5) [[GLONGP]], align 4
+// CL12-NEXT: [[TMP1:%.*]] = load ptr addrspace(5), ptr addrspace(5) [[GLONGP]], align 4
+// CL12-NEXT: store i64 9, ptr addrspace(5) [[TMP1]], align 8
+// CL12-NEXT: ret void
+//
+// CL20-LABEL: define dso_local void @wrong_store_type_private_pointer_alloca(
+// CL20-SAME: ) #[[ATTR0]] {
+// CL20-NEXT: [[ENTRY:.*:]]
+// CL20-NEXT: [[PLONG:%.*]] = alloca i64, align 8, addrspace(5)
+// CL20-NEXT: [[PLONGP:%.*]] = alloca ptr addrspace(5), align 4, addrspace(5)
+// CL20-NEXT: [[GLONGP:%.*]] = alloca ptr, align 8, addrspace(5)
+// CL20-NEXT: [[PLONG_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[PLONG]] to ptr
+// CL20-NEXT: [[PLONGP_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[PLONGP]] to ptr
+// CL20-NEXT: [[GLONGP_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[GLONGP]] to ptr
+// CL20-NEXT: store i64 5, ptr [[PLONG_ASCAST]], align 8
+// CL20-NEXT: store ptr [[PLONG_ASCAST]], ptr [[PLONGP_ASCAST]], align 4
+// CL20-NEXT: [[TMP0:%.*]] = load ptr addrspace(5), ptr [[PLONGP_ASCAST]], align 4
+// CL20-NEXT: store i64 8, ptr addrspace(5) [[TMP0]], align 8
+// CL20-NEXT: store ptr [[PLONG_ASCAST]], ptr [[GLONGP_ASCAST]], align 8
+// CL20-NEXT: [[TMP1:%.*]] = load ptr, ptr [[GLONGP_ASCAST]], align 8
+// CL20-NEXT: store i64 9, ptr [[TMP1]], align 8
+// CL20-NEXT: ret void
+//
+void wrong_store_type_private_pointer_alloca() {
+ long plong = 5;
+
+ // This needs to write an addrspace(5) pointer to the temporary alloca
+ __private long *plongp = &plong;
+ *plongp = 8;
+
+ // This needs to write an addrspace(0) pointer to the temporary alloca in CL2.0
----------------
Artem-B wrote:
It would be useful to mention what we're currently doing wrong, as a FIXME/TODO.
One could dig through the IR checks, but it's much easier when one knows what to look for, specifically.
https://github.com/llvm/llvm-project/pull/138862
More information about the cfe-commits
mailing list