================ @@ -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 + long *glongp = &plong; + *glongp = 9; ---------------- Artem-B wrote:
I'd split it into two separate tests -- one for generic pointer, and one for private. That is, unless the issue is when both pointers are needed to reproduce the issue. Right now the checks have way too many `[PG]LONGP?` that require an effort to keep track of. It may be the case where semantically sensible naming in the source code that uses prefix/suffix makes things harder to read when it comes to the test checks. It's a nit. If the test in the current shape works for you I'm OK with it. I just found it to be not quite "painfully obvious". How about something like this: ``` long data = 5; // This needs to write an addrspace(5) pointer to the temporary alloca __private long *pvtp = &data; *pvtp = 8; long *genp = &data; *genp = 9; ``` Maybe, also make genp and pvtp static, so their own allocas do not clutter the test checks. In the checks themselves, I'd also rename generic `_ASCAST` so it reflects the AS we cast to. E.g. `_GEN` or `_PVT`, so the reader does not have to back-track to where the value is captured. https://github.com/llvm/llvm-project/pull/138862 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits