|
| 1 | +;; This tests diagnostic emission whenever printf's format string argument |
| 2 | +;; is taken from the argument list of a user wrapper function and no |
| 3 | +;; inlining is performed prior to the address space mutation pass. |
| 4 | + |
| 5 | +;; The IR for test purposes is based on the following source/compilation (custom |
| 6 | +;; build of SYCL Clang with SYCLMutatePrintfAddrspacePass turned off): |
| 7 | +;; clang++ -fsycl -fsycl-device-only Inputs/experimental-printf-bad-inline-test.cpp -S -D__SYCL_USE_NON_VARIADIC_SPIRV_OCL_PRINTF__ -O0 |
| 8 | + |
| 9 | +; RUN: not opt < %s --SYCLMutatePrintfAddrspace -S --enable-new-pm=0 2>&1 | FileCheck %s |
| 10 | +; RUN: not opt < %s --passes=SYCLMutatePrintfAddrspace -S 2>&1 | FileCheck %s |
| 11 | +; CHECK: error: experimental::printf requires format string to reside in constant address space. The compiler wasn't able to automatically convert your format string into constant address space when processing builtin _ZN2cl4sycl3ext6oneapi12experimental6printf{{.*}} called in function {{.*}}custom_wrapper{{.*}}. |
| 12 | +; CHECK-NEXT: Consider simplifying the code by passing format strings directly into experimental::printf calls, avoiding indirection via wrapper function arguments. |
| 13 | + |
| 14 | +target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64" |
| 15 | +target triple = "spir64-unknown-unknown" |
| 16 | + |
| 17 | +%"class.cl::sycl::range" = type { %"class.cl::sycl::detail::array" } |
| 18 | +%"class.cl::sycl::detail::array" = type { [1 x i64] } |
| 19 | +%"class.cl::sycl::id" = type { %"class.cl::sycl::detail::array" } |
| 20 | +%class.anon = type { %"class.cl::sycl::accessor" } |
| 21 | +%"class.cl::sycl::accessor" = type { %"class.cl::sycl::detail::AccessorImplDevice" } |
| 22 | +%"class.cl::sycl::detail::AccessorImplDevice" = type { %"class.cl::sycl::id", %"class.cl::sycl::range", %"class.cl::sycl::range" } |
| 23 | +%"class.cl::sycl::detail::accessor_common" = type { i8 } |
| 24 | + |
| 25 | +$_ZN2cl4sycl3ext6oneapi12experimental6printfIcJEEEiPKT_DpT0_ = comdat any |
| 26 | + |
| 27 | +; Function Attrs: convergent mustprogress noinline norecurse optnone |
| 28 | +define dso_local spir_func void @_Z14custom_wrapperPKc(i8 addrspace(4)* %S) #0 { |
| 29 | +entry: |
| 30 | + %S.addr = alloca i8 addrspace(4)*, align 8 |
| 31 | + %S.addr.ascast = addrspacecast i8 addrspace(4)** %S.addr to i8 addrspace(4)* addrspace(4)* |
| 32 | + store i8 addrspace(4)* %S, i8 addrspace(4)* addrspace(4)* %S.addr.ascast, align 8 |
| 33 | + %0 = load i8 addrspace(4)*, i8 addrspace(4)* addrspace(4)* %S.addr.ascast, align 8 |
| 34 | + %call = call spir_func i32 @_ZN2cl4sycl3ext6oneapi12experimental6printfIcJEEEiPKT_DpT0_(i8 addrspace(4)* %0) #9 |
| 35 | + ret void |
| 36 | +} |
| 37 | + |
| 38 | +; Function Attrs: convergent mustprogress noinline norecurse optnone |
| 39 | +define linkonce_odr dso_local spir_func i32 @_ZN2cl4sycl3ext6oneapi12experimental6printfIcJEEEiPKT_DpT0_(i8 addrspace(4)* %__format) #1 comdat { |
| 40 | +entry: |
| 41 | + %retval = alloca i32, align 4 |
| 42 | + %__format.addr = alloca i8 addrspace(4)*, align 8 |
| 43 | + %retval.ascast = addrspacecast i32* %retval to i32 addrspace(4)* |
| 44 | + %__format.addr.ascast = addrspacecast i8 addrspace(4)** %__format.addr to i8 addrspace(4)* addrspace(4)* |
| 45 | + store i8 addrspace(4)* %__format, i8 addrspace(4)* addrspace(4)* %__format.addr.ascast, align 8 |
| 46 | + %0 = load i8 addrspace(4)*, i8 addrspace(4)* addrspace(4)* %__format.addr.ascast, align 8 |
| 47 | + %call = call spir_func i32 @_Z18__spirv_ocl_printfIJEEiPKcDpT_(i8 addrspace(4)* %0) #9 |
| 48 | + ret i32 %call |
| 49 | +} |
| 50 | + |
| 51 | +; Function Attrs: convergent |
| 52 | +declare dso_local spir_func i32 @_Z18__spirv_ocl_printfIJEEiPKcDpT_(i8 addrspace(4)*) #2 |
| 53 | + |
| 54 | +attributes #0 = { convergent mustprogress noinline norecurse optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "sycl-module-id"="experimental-printf-bad-inline-test.cpp" } |
| 55 | +attributes #1 = { convergent mustprogress noinline norecurse optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" } |
| 56 | +attributes #2 = { convergent "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" } |
| 57 | +attributes #3 = { convergent mustprogress noinline norecurse optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "sycl-module-id"="experimental-printf-bad-inline-test.cpp" "uniform-work-group-size"="true" } |
| 58 | +attributes #4 = { convergent noinline norecurse optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" } |
| 59 | +attributes #5 = { argmemonly nofree nounwind willreturn } |
| 60 | +attributes #6 = { argmemonly nofree nounwind willreturn writeonly } |
| 61 | +attributes #7 = { convergent noinline norecurse nounwind optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" } |
| 62 | +attributes #8 = { convergent mustprogress noinline norecurse nounwind optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" } |
| 63 | +attributes #9 = { convergent } |
| 64 | + |
| 65 | +!llvm.module.flags = !{!0, !1} |
| 66 | +!opencl.spir.version = !{!2} |
| 67 | +!spirv.Source = !{!3} |
| 68 | +!llvm.ident = !{!4} |
| 69 | + |
| 70 | +!0 = !{i32 1, !"wchar_size", i32 4} |
| 71 | +!1 = !{i32 7, !"frame-pointer", i32 2} |
| 72 | +!2 = !{i32 1, i32 2} |
| 73 | +!3 = !{i32 4, i32 100000} |
| 74 | +!4 = !{!"clang version 14.0.0"} |
| 75 | +!5 = !{i32 -1, i32 -1, i32 -1, i32 -1} |
| 76 | +!6 = distinct !{!6, !7, !8} |
| 77 | +!7 = !{!"llvm.loop.mustprogress"} |
| 78 | +!8 = !{!"llvm.loop.unroll.enable"} |
0 commit comments