[all-commits] [llvm/llvm-project] fe1bfb: [SPIR-V] Lower nested aggregate insertvalue operan...

Tim Besard via All-commits all-commits at lists.llvm.org
Fri Aug 7 01:41:32 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: fe1bfb32edc80cbe287342d6b350d6d6622493cc
      https://github.com/llvm/llvm-project/commit/fe1bfb32edc80cbe287342d6b350d6d6622493cc
  Author: Tim Besard <tim.besard at gmail.com>
  Date:   2026-08-07 (Fri, 07 Aug 2026)

  Changed paths:
    M llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp
    A llvm/test/CodeGen/SPIRV/instructions/insertvalue-nested-extractvalue.ll

  Log Message:
  -----------
  [SPIR-V] Lower nested aggregate insertvalue operands (#204239)

Fix a crash in the SPIR-V backend when an aggregate `extractvalue`
result is used as the base of a later `insertvalue`.

The failing pattern is:

```llvm
%e = extractvalue [1 x [1 x i64]] %a, 0
%i = insertvalue [1 x i64] %e, i64 %x, 0
%r = insertvalue [1 x [1 x i64]] %a, [1 x i64] %i, 0
```

`SPIRVPrepareFunctions` rewrites aggregate function arguments and
returns to `i32` SPIR-V value IDs. The `llvm.spv.insertv` intrinsic also
models its composite operand as an `i32` value ID. However, an
intermediate aggregate `extractvalue` could still be rewritten to
`llvm.spv.extractv` with an LLVM aggregate result type. Passing that
aggregate-typed value to `llvm.spv.insertv` made
`IRBuilder::CreateIntrinsic` create a call with a mismatched signature
and assert.

This patch mutates aggregate-result `llvm.spv.extractv` values that feed
`insertvalue` to `i32`, while preserving the original aggregate type in
the existing aggregate type metadata path. Selection then emits the
expected SPIR-V:

```spirv
%inner = OpCompositeExtract %Inner %outer 0
%new_inner = OpCompositeInsert %Inner %x %inner 0
%new_outer = OpCompositeInsert %Outer %new_inner %outer 0
```

Co-authored-by: Codex <noreply at openai.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list