| Issue |
185412
|
| Summary |
[SPIRV] Backend generates invalid SPIRV code with function pointers used in struct
|
| Labels |
bug,
backend:SPIR-V
|
| Assignees |
|
| Reporter |
jmmartinez
|
## Overview
Bug found in https://github.com/llvm/llvm-project/pull/182549#issuecomment-4006625005.
LLVM-IR coming from `llvm/test/CodeGen/SPIRV/extensions/SPV_INTEL_function_pointers/fp_no_return.ll`.
With `spirv-val` (with this patch applied https://github.com/KhronosGroup/SPIRV-Tools/pull/6232), `spirv-val` fails with error:
```bash
error: line 41: OpConstantComposite Constituent '18[%18]' type does not match the Result Type '14[%struct_ident_t]'s member type.
%23 = OpConstantComposite %struct_ident_t %21 %uint_2 %21 %uint_22 %18
```
## Steps to reproduce
```bash
llc -verify-machineinstrs -O0 --spirv-ext=+SPV_INTEL_function_pointers CodeGen/SPIRV/extensions/SPV_INTEL_function_pointers/fp_no_return.ll -o - -mtriple spirv64-- | spirv-val
```
```llvm
%struct.ident_t = type { i32, i32, i32, i32, ptr addrspace(4) }
@0 = addrspace(1) constant %struct.ident_t { i32 0, i32 2, i32 0, i32 22, ptr addrspace(4) addrspacecast (ptr addrspace(1) null to ptr addrspace(4)) }
define spir_func void @foo(ptr addrspace(4) %Ident) addrspace(9) {
entry:
br label %do.body
do.body: ; preds = %do.body, %entry
%0 = load ptr addrspace(9), ptr addrspace(4) null, align 8
call spir_func addrspace(9) void %0(i32 0, i32 0)
br label %do.body
}
define spir_func void @bar() addrspace(9) {
entry:
ret void
}
```
This generates the following extract:
```asm
%5 = OpTypeInt 8 0
%6 = OpTypePointer Generic %5
%14 = OpTypeStruct %9 %9 %9 %9 %6 ; {i32, i32, i32, i32, addrspace(generic) i8*}
%16 = OpTypeInt 64 0
%18 = OpConstantNull %16
%19 = OpConstant %9 22
%20 = OpConstant %9 2
%21 = OpConstantNull %9
%23 = OpConstantComposite %14 %21 %20 %21 %19 %18 ; { i32 0, i32 2, i32 0, i32 22, i64 null }
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs