From ed7249f58358b9b5841aa53ef58522a73600b1f0 Mon Sep 17 00:00:00 2001 From: Marcos Maronas Date: Wed, 21 May 2025 17:01:16 +0200 Subject: [PATCH 1/3] Fix crash in CompileTimePropertiesPass when pointer parameter of a function is annotated. --- llvm/lib/SYCLLowerIR/CompileTimePropertiesPass.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/lib/SYCLLowerIR/CompileTimePropertiesPass.cpp b/llvm/lib/SYCLLowerIR/CompileTimePropertiesPass.cpp index 40af89ddcf26f..8d4d40f187060 100644 --- a/llvm/lib/SYCLLowerIR/CompileTimePropertiesPass.cpp +++ b/llvm/lib/SYCLLowerIR/CompileTimePropertiesPass.cpp @@ -947,7 +947,7 @@ bool CompileTimePropertiesPass::transformSYCLPropertiesAnnotation( if (CacheProp) { LLVMContext &Ctx = M.getContext(); unsigned MDKindID = Ctx.getMDKindID(SPIRV_DECOR_MD_KIND); - if (!FPGAProp) { + if (!FPGAProp && llvm::isa(IntrInst->getArgOperand(0))) { // If there are no annotations other than cache controls we can apply the // controls to the pointer and remove the intrinsic. auto PtrInstr = cast(IntrInst->getArgOperand(0)); From 3b649bf1b5cc4ae8023f74ea6e25b8e53ea81b29 Mon Sep 17 00:00:00 2001 From: Marcos Maronas Date: Wed, 21 May 2025 17:34:22 +0200 Subject: [PATCH 2/3] Add new test. --- .../properties/properties_cache_control.cpp | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/sycl/test/check_device_code/extensions/properties/properties_cache_control.cpp b/sycl/test/check_device_code/extensions/properties/properties_cache_control.cpp index cf853d2a6c7ac..fa28bb13192f1 100644 --- a/sycl/test/check_device_code/extensions/properties/properties_cache_control.cpp +++ b/sycl/test/check_device_code/extensions/properties/properties_cache_control.cpp @@ -81,6 +81,15 @@ void cache_control_read_write_func() { }); } +// Test that annotated pointer parameter functions don't crash. +SYCL_EXTERNAL void annotated_ptr_func_param_test(float *p) { + *(store_hint{p /*+1*/}) = 42.0f; +} + +// CHECK-IR: spir_func{{.*}}annotated_ptr_func_param_test +// CHECK-IR: {{.*}}call ptr addrspace(4) @llvm.ptr.annotation.p4.p1{{.*}}!spirv.Decorations [[WHINT:.*]] +// CHECK-IR: ret void + // CHECK-IR: spir_kernel{{.*}}cache_control_read_hint_func // CHECK-IR: {{.*}}addrspacecast ptr addrspace(1){{.*}}!spirv.Decorations [[RHINT:.*]] // CHECK-IR: ret void @@ -90,13 +99,19 @@ void cache_control_read_write_func() { // CHECK-IR: ret void // CHECK-IR: spir_kernel{{.*}}cache_control_write_hint_func -// CHECK-IR: {{.*}}addrspacecast ptr addrspace(1){{.*}}!spirv.Decorations [[WHINT:.*]] +// CHECK-IR: {{.*}}addrspacecast ptr addrspace(1){{.*}}!spirv.Decorations [[WHINT]] // CHECK-IR: ret void // CHECK-IR: spir_kernel{{.*}}cache_control_read_write_func // CHECK-IR: {{.*}}addrspacecast ptr addrspace(1){{.*}}!spirv.Decorations [[RWHINT:.*]] // CHECK-IR: ret void +// CHECK-IR: [[WHINT]] = !{[[WHINT1:.*]], [[WHINT2:.*]], [[WHINT3:.*]], [[WHINT4:.*]]} +// CHECK-IR: [[WHINT1]] = !{i32 6443, i32 3, i32 3} +// CHECK-IR: [[WHINT2]] = !{i32 6443, i32 0, i32 1} +// CHECK-IR: [[WHINT3]] = !{i32 6443, i32 1, i32 2} +// CHECK-IR: [[WHINT4]] = !{i32 6443, i32 2, i32 2} + // CHECK-IR: [[RHINT]] = !{[[RHINT1:.*]], [[RHINT2:.*]], [[RHINT3:.*]]} // CHECK-IR: [[RHINT1]] = !{i32 6442, i32 1, i32 0} // CHECK-IR: [[RHINT2]] = !{i32 6442, i32 2, i32 0} @@ -107,12 +122,6 @@ void cache_control_read_write_func() { // CHECK-IR: [[RASSERT2]] = !{i32 6442, i32 2, i32 3} // CHECK-IR: [[RASSERT3]] = !{i32 6442, i32 0, i32 4} -// CHECK-IR: [[WHINT]] = !{[[WHINT1:.*]], [[WHINT2:.*]], [[WHINT3:.*]], [[WHINT4:.*]]} -// CHECK-IR: [[WHINT1]] = !{i32 6443, i32 3, i32 3} -// CHECK-IR: [[WHINT2]] = !{i32 6443, i32 0, i32 1} -// CHECK-IR: [[WHINT3]] = !{i32 6443, i32 1, i32 2} -// CHECK-IR: [[WHINT4]] = !{i32 6443, i32 2, i32 2} - // CHECK-IR: [[RWHINT]] = !{[[RWHINT1:.*]], [[RWHINT2:.*]], [[RWHINT3:.*]]} // CHECK-IR: [[RWHINT1]] = !{i32 6442, i32 2, i32 1} // CHECK-IR: [[RWHINT2]] = !{i32 6442, i32 3, i32 4} From d9abe2ff77eb762a319587cac58b90e223062ca3 Mon Sep 17 00:00:00 2001 From: Marcos Maronas Date: Thu, 22 May 2025 09:31:06 +0100 Subject: [PATCH 3/3] Update sycl/test/check_device_code/extensions/properties/properties_cache_control.cpp Co-authored-by: aelovikov-intel --- .../extensions/properties/properties_cache_control.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/test/check_device_code/extensions/properties/properties_cache_control.cpp b/sycl/test/check_device_code/extensions/properties/properties_cache_control.cpp index fa28bb13192f1..6042363056b88 100644 --- a/sycl/test/check_device_code/extensions/properties/properties_cache_control.cpp +++ b/sycl/test/check_device_code/extensions/properties/properties_cache_control.cpp @@ -83,7 +83,7 @@ void cache_control_read_write_func() { // Test that annotated pointer parameter functions don't crash. SYCL_EXTERNAL void annotated_ptr_func_param_test(float *p) { - *(store_hint{p /*+1*/}) = 42.0f; + *(store_hint{p}) = 42.0f; } // CHECK-IR: spir_func{{.*}}annotated_ptr_func_param_test