|
| 1 | +; Modified from: https://github.com/KhronosGroup/SPIRV-LLVM-Translator/test/extensions/INTEL/SPV_INTEL_variable_length_array/vla_spec_const.ll |
| 2 | + |
| 3 | +; RUN: llc -O0 -mtriple=spirv32-unknown-unknown --spirv-extensions=SPV_INTEL_variable_length_array %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV |
| 4 | +; TODO: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-unknown --spirv-extensions=SPV_INTEL_variable_length_array %s -o - -filetype=obj | spirv-val %} |
| 5 | + |
| 6 | +; CHECK-SPIRV: Capability VariableLengthArrayINTEL |
| 7 | +; CHECK-SPIRV: Extension "SPV_INTEL_variable_length_array" |
| 8 | +; CHECK-SPIRV: OpDecorate %[[SpecConst:.*]] SpecId 0 |
| 9 | +; CHECK-SPIRV-DAG: %[[Long:.*]] = OpTypeInt 64 0 |
| 10 | +; CHECK-SPIRV-DAG: %[[Int:.*]] = OpTypeInt 32 0 |
| 11 | +; CHECK-SPIRV-DAG: %[[IntPtr:.*]] = OpTypePointer {{[a-zA-Z]+}} %[[Int]] |
| 12 | +; CHECK-SPIRV: %[[SpecConst]] = OpSpecConstant %[[Long]] |
| 13 | +; CHECK-SPIRV-LABEL: FunctionEnd |
| 14 | +; CHECK-SPIRV: %[[SpecConstVal:.*]] = OpFunctionCall %[[Long]] |
| 15 | +; CHECK-SPIRV: OpSaveMemoryINTEL |
| 16 | +; CHECK-SPIRV: OpVariableLengthArrayINTEL %[[IntPtr]] %[[SpecConstVal]] |
| 17 | +; CHECK-SPIRV: OpRestoreMemoryINTEL |
| 18 | + |
| 19 | +; CHECK-SPIRV: OpFunction %[[Long]] |
| 20 | +; CHECK-SPIRV: ReturnValue %[[SpecConst]] |
| 21 | + |
| 22 | +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" |
| 23 | +target triple = "spir64-unknown-linux" |
| 24 | + |
| 25 | +%"class._ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEEUlvE_.anon" = type { %"class._ZTSN2cl4sycl12experimental13spec_constantIm13MyUInt64ConstEE.cl::sycl::experimental::spec_constant" } |
| 26 | +%"class._ZTSN2cl4sycl12experimental13spec_constantIm13MyUInt64ConstEE.cl::sycl::experimental::spec_constant" = type { i8 } |
| 27 | + |
| 28 | +$_ZTS17SpecializedKernel = comdat any |
| 29 | + |
| 30 | +$_ZNK2cl4sycl12experimental13spec_constantIm13MyUInt64ConstE3getEv = comdat any |
| 31 | + |
| 32 | +; Function Attrs: norecurse |
| 33 | +define weak_odr dso_local spir_kernel void @_ZTS17SpecializedKernel() #0 comdat !kernel_arg_addr_space !4 !kernel_arg_access_qual !4 !kernel_arg_type !4 !kernel_arg_base_type !4 !kernel_arg_type_qual !4 { |
| 34 | +entry: |
| 35 | + %p = alloca %"class._ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEEUlvE_.anon", align 1 |
| 36 | + call void @llvm.lifetime.start.p0(i64 1, ptr %p) #4 |
| 37 | + %p4 = addrspacecast ptr %p to ptr addrspace(4) |
| 38 | + call spir_func void @"_ZZZ4mainENK3$_0clERN2cl4sycl7handlerEENKUlvE_clEv"(ptr addrspace(4) %p4) |
| 39 | + call void @llvm.lifetime.end.p0(i64 1, ptr %p) #4 |
| 40 | + ret void |
| 41 | +} |
| 42 | + |
| 43 | +; Function Attrs: argmemonly nounwind willreturn |
| 44 | +declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1 |
| 45 | + |
| 46 | +; Function Attrs: inlinehint norecurse |
| 47 | +define internal spir_func void @"_ZZZ4mainENK3$_0clERN2cl4sycl7handlerEENKUlvE_clEv"(ptr addrspace(4) %this) #2 align 2 { |
| 48 | +entry: |
| 49 | + %this.addr = alloca ptr addrspace(4), align 8 |
| 50 | + %saved_stack = alloca ptr, align 8 |
| 51 | + %__vla_expr0 = alloca i64, align 8 |
| 52 | + store ptr addrspace(4) %this, ptr %this.addr, align 8, !tbaa !5 |
| 53 | + %this1 = load ptr addrspace(4), ptr %this.addr, align 8 |
| 54 | + %call = call spir_func i64 @_ZNK2cl4sycl12experimental13spec_constantIm13MyUInt64ConstE3getEv(ptr addrspace(4) %this1) |
| 55 | + %p = call ptr @llvm.stacksave.p0() |
| 56 | + store ptr %p, ptr %saved_stack, align 8 |
| 57 | + %vla = alloca i32, i64 %call, align 4 |
| 58 | + store i64 %call, ptr %__vla_expr0, align 8 |
| 59 | + store i32 42, ptr %vla, align 4, !tbaa !9 |
| 60 | + %torestore = load ptr, ptr %saved_stack, align 8 |
| 61 | + call void @llvm.stackrestore.p0(ptr %torestore) |
| 62 | + ret void |
| 63 | +} |
| 64 | + |
| 65 | +; Function Attrs: argmemonly nounwind willreturn |
| 66 | +declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1 |
| 67 | + |
| 68 | +; Function Attrs: norecurse |
| 69 | +define linkonce_odr dso_local spir_func i64 @_ZNK2cl4sycl12experimental13spec_constantIm13MyUInt64ConstE3getEv(ptr addrspace(4) %this) #3 comdat align 2 { |
| 70 | +entry: |
| 71 | + %this.addr = alloca ptr addrspace(4), align 8 |
| 72 | + %TName = alloca ptr addrspace(4), align 8 |
| 73 | + store ptr addrspace(4) %this, ptr %this.addr, align 8, !tbaa !5 |
| 74 | + call void @llvm.lifetime.start.p0(i64 8, ptr %TName) #4 |
| 75 | + %p = call i64 @_Z20__spirv_SpecConstantix(i32 0, i64 0), !SYCL_SPEC_CONST_SYM_ID !11 |
| 76 | + call void @llvm.lifetime.end.p0(i64 8, ptr %TName) #4 |
| 77 | + ret i64 %p |
| 78 | +} |
| 79 | + |
| 80 | +; Function Attrs: nounwind |
| 81 | +declare ptr @llvm.stacksave.p0() #4 |
| 82 | + |
| 83 | +; Function Attrs: nounwind |
| 84 | +declare void @llvm.stackrestore.p0(ptr) #4 |
| 85 | + |
| 86 | +declare i64 @_Z20__spirv_SpecConstantix(i32, i64) |
| 87 | + |
| 88 | +attributes #0 = { norecurse "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "sycl-module-id"="/work/intel/vla_spec_const.cpp" "uniform-work-group-size"="true" "unsafe-fp-math"="false" "use-soft-float"="false" } |
| 89 | +attributes #1 = { argmemonly nounwind willreturn } |
| 90 | +attributes #2 = { inlinehint norecurse "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } |
| 91 | +attributes #3 = { norecurse "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } |
| 92 | +attributes #4 = { nounwind } |
| 93 | + |
| 94 | +!llvm.module.flags = !{!0} |
| 95 | +!opencl.spir.version = !{!1} |
| 96 | +!spirv.Source = !{!2} |
| 97 | +!llvm.ident = !{!3} |
| 98 | + |
| 99 | +!0 = !{i32 1, !"wchar_size", i32 4} |
| 100 | +!1 = !{i32 1, i32 2} |
| 101 | +!2 = !{i32 4, i32 100000} |
| 102 | +!3 = !{!"clang version 12.0.0"} |
| 103 | +!4 = !{} |
| 104 | +!5 = !{!6, !6, i64 0} |
| 105 | +!6 = !{!"any pointer", !7, i64 0} |
| 106 | +!7 = !{!"omnipotent char", !8, i64 0} |
| 107 | +!8 = !{!"Simple C++ TBAA"} |
| 108 | +!9 = !{!10, !10, i64 0} |
| 109 | +!10 = !{!"int", !7, i64 0} |
| 110 | +!11 = !{!"_ZTS13MyUInt64Const", i32 0} |
0 commit comments