|
| 1 | +;; This test is derived from generic_as_variadic_no_opt.ll. |
| 2 | +;; This test ensures that when SYCLMutatePrintfAddrspace analyzes a load |
| 3 | +;; of the format pointer for a printf, it will not crash if a |
| 4 | +;; corresponding store is not found. |
| 5 | + |
| 6 | +; RUN: not opt < %s -passes=SYCLMutatePrintfAddrspace -S 2>&1 | FileCheck %s |
| 7 | + |
| 8 | +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" |
| 9 | +target triple = "spir64-unknown-unknown" |
| 10 | + |
| 11 | +$_ZN2cl4sycl3ext6oneapi12experimental6printfIcJfEEEiPKT_DpT0_ = comdat any |
| 12 | + |
| 13 | +; 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 _Z18__spirv_ocl_printf{{.*}} called in function {{.*}}. |
| 14 | + |
| 15 | +; Function Attrs: convergent mustprogress noinline norecurse optnone |
| 16 | +define linkonce_odr dso_local spir_func i32 @_ZN2cl4sycl3ext6oneapi12experimental6printfIcJfEEEiPKT_DpT0_(ptr addrspace(4) %__format, float %args) #2 comdat { |
| 17 | +entry: |
| 18 | + %retval = alloca i32, align 4 |
| 19 | + %__format.addr = alloca ptr addrspace(4), align 8 |
| 20 | + %args.addr = alloca float, align 4 |
| 21 | + %retval.ascast = addrspacecast ptr %retval to ptr addrspace(4) |
| 22 | + %__format.addr.ascast = addrspacecast ptr %__format.addr to ptr addrspace(4) |
| 23 | + %args.addr.ascast = addrspacecast ptr %args.addr to ptr addrspace(4) |
| 24 | +; Remove store to ensure SYCLMutatePrintfAddrspace will not crash. |
| 25 | +; store ptr addrspace(4) %__format, ptr addrspace(4) %__format.addr.ascast, align 8 |
| 26 | + store float %args, ptr addrspace(4) %args.addr.ascast, align 4 |
| 27 | + %0 = load ptr addrspace(4), ptr addrspace(4) %__format.addr.ascast, align 8 |
| 28 | + %1 = load float, ptr addrspace(4) %args.addr.ascast, align 4 |
| 29 | + %call = call spir_func i32 (ptr addrspace(4), ...) @_Z18__spirv_ocl_printfPKcz(ptr addrspace(4) %0, float %1) #8 |
| 30 | + ret i32 %call |
| 31 | +} |
| 32 | + |
| 33 | +; Function Attrs: convergent |
| 34 | +declare dso_local spir_func i32 @_Z18__spirv_ocl_printfPKcz(ptr addrspace(4), ...) #7 |
| 35 | + |
| 36 | +attributes #2 = { convergent mustprogress noinline norecurse optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" } |
| 37 | +attributes #7 = { convergent "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" } |
| 38 | +attributes #8 = { convergent } |
| 39 | + |
| 40 | +!llvm.module.flags = !{!0, !1} |
| 41 | +!opencl.spir.version = !{!2} |
| 42 | +!spirv.Source = !{!3} |
| 43 | + |
| 44 | +!0 = !{i32 1, !"wchar_size", i32 4} |
| 45 | +!1 = !{i32 7, !"frame-pointer", i32 2} |
| 46 | +!2 = !{i32 1, i32 2} |
| 47 | +!3 = !{i32 4, i32 100000} |
0 commit comments