|
| 1 | +; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown --spirv-ext=+SPV_INTEL_function_pointers %s -o - | FileCheck %s |
| 2 | +; TODO: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %} |
| 3 | + |
| 4 | +; CHECK: OpFunction |
| 5 | + |
| 6 | +%classid = type { %arrayid } |
| 7 | +%arrayid = type { [1 x i64] } |
| 8 | +%struct.obj_storage_t = type { %storage } |
| 9 | +%storage = type { [8 x i8] } |
| 10 | + |
| 11 | +@_ZTV12IncrementBy8 = linkonce_odr dso_local unnamed_addr addrspace(1) constant { [3 x ptr addrspace(4)] } { [3 x ptr addrspace(4)] [ptr addrspace(4) null, ptr addrspace(4) null, ptr addrspace(4) addrspacecast (ptr @_ZN12IncrementBy89incrementEPi to ptr addrspace(4))] }, align 8 |
| 12 | +@_ZTV13BaseIncrement = linkonce_odr dso_local unnamed_addr addrspace(1) constant { [3 x ptr addrspace(4)] } { [3 x ptr addrspace(4)] [ptr addrspace(4) null, ptr addrspace(4) null, ptr addrspace(4) addrspacecast (ptr @_ZN13BaseIncrement9incrementEPi to ptr addrspace(4))] }, align 8 |
| 13 | +@_ZTV12IncrementBy4 = linkonce_odr dso_local unnamed_addr addrspace(1) constant { [3 x ptr addrspace(4)] } { [3 x ptr addrspace(4)] [ptr addrspace(4) null, ptr addrspace(4) null, ptr addrspace(4) addrspacecast (ptr @_ZN12IncrementBy49incrementEPi to ptr addrspace(4))] }, align 8 |
| 14 | +@_ZTV12IncrementBy2 = linkonce_odr dso_local unnamed_addr addrspace(1) constant { [3 x ptr addrspace(4)] } { [3 x ptr addrspace(4)] [ptr addrspace(4) null, ptr addrspace(4) null, ptr addrspace(4) addrspacecast (ptr @_ZN12IncrementBy29incrementEPi to ptr addrspace(4))] }, align 8 |
| 15 | + |
| 16 | +define weak_odr dso_local spir_kernel void @foo(ptr addrspace(1) noundef align 8 %_arg_StorageAcc, ptr noundef byval(%classid) align 8 %_arg_StorageAcc3, i32 noundef %_arg_TestCase, ptr addrspace(1) noundef align 4 %_arg_DataAcc) { |
| 17 | +entry: |
| 18 | + %0 = load i64, ptr %_arg_StorageAcc3, align 8 |
| 19 | + %add.ptr.i = getelementptr inbounds %struct.obj_storage_t, ptr addrspace(1) %_arg_StorageAcc, i64 %0 |
| 20 | + %arrayidx.ascast.i = addrspacecast ptr addrspace(1) %add.ptr.i to ptr addrspace(4) |
| 21 | + %cmp.i = icmp ugt i32 %_arg_TestCase, 3 |
| 22 | + br i1 %cmp.i, label %entry.critedge, label %if.end.1 |
| 23 | + |
| 24 | +entry.critedge: ; preds = %entry |
| 25 | + %vtable.i.pre = load ptr addrspace(4), ptr addrspace(4) null, align 8 |
| 26 | + br label %exit |
| 27 | + |
| 28 | +if.end.1: ; preds = %entry |
| 29 | + switch i32 %_arg_TestCase, label %if.end.5 [ |
| 30 | + i32 0, label %if.end.2 |
| 31 | + i32 1, label %if.end.3 |
| 32 | + i32 2, label %if.end.4 |
| 33 | + ] |
| 34 | + |
| 35 | +if.end.5: ; preds = %if.end.1 |
| 36 | + store ptr addrspace(1) getelementptr inbounds inrange(-16, 8) (i8, ptr addrspace(1) @_ZTV12IncrementBy8, i64 16), ptr addrspace(1) %add.ptr.i, align 8 |
| 37 | + br label %exit |
| 38 | + |
| 39 | +if.end.4: ; preds = %if.end.1 |
| 40 | + store ptr addrspace(1) getelementptr inbounds inrange(-16, 8) (i8, ptr addrspace(1) @_ZTV12IncrementBy4, i64 16), ptr addrspace(1) %add.ptr.i, align 8 |
| 41 | + br label %exit |
| 42 | + |
| 43 | +if.end.3: ; preds = %if.end.1 |
| 44 | + store ptr addrspace(1) getelementptr inbounds inrange(-16, 8) (i8, ptr addrspace(1) @_ZTV12IncrementBy2, i64 16), ptr addrspace(1) %add.ptr.i, align 8 |
| 45 | + br label %exit |
| 46 | + |
| 47 | +if.end.2: ; preds = %if.end.1 |
| 48 | + store ptr addrspace(1) getelementptr inbounds inrange(-16, 8) (i8, ptr addrspace(1) @_ZTV13BaseIncrement, i64 16), ptr addrspace(1) %add.ptr.i, align 8 |
| 49 | + br label %exit |
| 50 | + |
| 51 | +exit: ; preds = %if.end.2, %if.end.3, %if.end.4, %if.end.5, %entry.critedge |
| 52 | + %vtable.i = phi ptr addrspace(4) [ %vtable.i.pre, %entry.critedge ], [ inttoptr (i64 ptrtoint (ptr addrspace(1) getelementptr inbounds inrange(-16, 8) (i8, ptr addrspace(1) @_ZTV12IncrementBy8, i64 16) to i64) to ptr addrspace(4)), %if.end.5 ], [ inttoptr (i64 ptrtoint (ptr addrspace(1) getelementptr inbounds inrange(-16, 8) (i8, ptr addrspace(1) @_ZTV12IncrementBy4, i64 16) to i64) to ptr addrspace(4)), %if.end.4 ], [ inttoptr (i64 ptrtoint (ptr addrspace(1) getelementptr inbounds inrange(-16, 8) (i8, ptr addrspace(1) @_ZTV12IncrementBy2, i64 16) to i64) to ptr addrspace(4)), %if.end.3 ], [ inttoptr (i64 ptrtoint (ptr addrspace(1) getelementptr inbounds inrange(-16, 8) (i8, ptr addrspace(1) @_ZTV13BaseIncrement, i64 16) to i64) to ptr addrspace(4)), %if.end.2 ] |
| 53 | + %retval.0.i = phi ptr addrspace(4) [ null, %entry.critedge ], [ %arrayidx.ascast.i, %if.end.5 ], [ %arrayidx.ascast.i, %if.end.4 ], [ %arrayidx.ascast.i, %if.end.3 ], [ %arrayidx.ascast.i, %if.end.2 ] |
| 54 | + %1 = addrspacecast ptr addrspace(1) %_arg_DataAcc to ptr addrspace(4) |
| 55 | + %2 = load ptr addrspace(4), ptr addrspace(4) %vtable.i, align 8 |
| 56 | + tail call spir_func addrspace(4) void %2(ptr addrspace(4) noundef align 8 dereferenceable_or_null(8) %retval.0.i, ptr addrspace(4) noundef %1) |
| 57 | + ret void |
| 58 | +} |
| 59 | + |
| 60 | +declare dso_local spir_func void @_ZN13BaseIncrement9incrementEPi(ptr addrspace(4) noundef align 8 dereferenceable_or_null(8), ptr addrspace(4) noundef) |
| 61 | +declare dso_local spir_func void @_ZN12IncrementBy29incrementEPi(ptr addrspace(4) noundef align 8 dereferenceable_or_null(8), ptr addrspace(4) noundef) |
| 62 | +declare dso_local spir_func void @_ZN12IncrementBy49incrementEPi(ptr addrspace(4) noundef align 8 dereferenceable_or_null(8), ptr addrspace(4) noundef) |
| 63 | +declare dso_local spir_func void @_ZN12IncrementBy89incrementEPi(ptr addrspace(4) noundef align 8 dereferenceable_or_null(8), ptr addrspace(4) noundef) |
0 commit comments