[llvm] [SPIR-V] Lower undef nested in a constant aggregate (PR #204377)
Dmitry Sidorov via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 19 08:04:47 PDT 2026
================
@@ -0,0 +1,25 @@
+; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown --spirv-ext=+SPV_INTEL_function_pointers %s -o - | FileCheck %s
+; %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown --spirv-ext=+SPV_INTEL_function_pointers %s -o - -filetype=obj | spirv-val %}
+
+; Check that a void-returning indirect call whose argument is an aggregate
+; doesn't crash while the aggregate argument type is temporarily mutated.
+
+; CHECK-DAG: OpCapability FunctionPointersINTEL
+; CHECK-DAG: OpExtension "SPV_INTEL_function_pointers"
+
+; CHECK: %[[#Int32Ty:]] = OpTypeInt 32 0
+; CHECK: %[[#AggTy:]] = OpTypeStruct %[[#Int32Ty]] %[[#Int32Ty]]
+; CHECK: %[[#VoidTy:]] = OpTypeVoid
+; CHECK: %[[#CalleeTy:]] = OpTypeFunction %[[#VoidTy]] %[[#AggTy]]
+; CHECK: %[[#CalleePtrTy:]] = OpTypePointer Generic %[[#CalleeTy]]
+
+; CHECK: %[[#Fp:]] = OpFunctionParameter %[[#CalleePtrTy]]
+; CHECK: %[[#Arg:]] = OpFunctionParameter %[[#AggTy]]
+; CHECK: OpFunctionPointerCallINTEL %[[#VoidTy]] %[[#Fp]] %[[#Arg]]
+
+%agg = type { i32, i32 }
+
+define spir_func void @caller(ptr addrspace(4) %fp, %agg %a) {
----------------
MrSidims wrote:
Sorry, it's a leaked test from [another patch](https://github.com/llvm/llvm-project/pull/204377#issuecomment-4752006036) :)
But since we are here: I don't see any problems with recursions here, something like this:
```
define spir_func void @rec_direct(%agg %a) {
call spir_func void @rec_direct(%agg %a)
ret void
}
define spir_func void @rec_indirect(ptr addrspace(4) %fp, %agg %a) {
call addrspace(4) void %fp(ptr addrspace(4) %fp, %agg %a)
ret void
}
```
is lowered to SPIR-V (by the backend) just fine.
https://github.com/llvm/llvm-project/pull/204377
More information about the llvm-commits
mailing list