Support multiple indices in OpCompositeExtract and OpCompositeInsert - #1
Merged
Merged
Conversation
LLVM emits these for insertvalue/extractvalue with a multi-level index list, e.g. when building a struct that contains a tuple. OpCompositeInsert rejected them, while OpCompositeExtract silently used only the first index and read the wrong member. Follow every index to render the full member path instead.
Pointer leaves of aggregates are stored as integers, and OpCompositeInsert casts pointers to that integer type on the way in. OpCompositeExtract didn't cast back, so extracting a pointer member produced an integer-to-pointer conversion that OpenCL C compilers reject.
maleadt
force-pushed
the
tb/composite-indices
branch
from
September 26, 2026 10:05
671853b to
bff3713
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
LLVM emits
OpCompositeInsert/OpCompositeExtractwith several indices forinsertvalue/extractvaluewith a multi-level index list, e.g. when building a struct that contains a tuple:OpCompositeInsertrejected these withUNIMPLEMENTED OpCompositeInsert with multiple indices.OpCompositeExtractwas worse: it silently used only the first index and read the wrong member. Both now follow every index through struct members, (struct-wrapped) array elements and vector components, rendering e.g.v.m1.m1.e[1].s3.The member path gives us the leaf type, so a second commit also fixes extracting a pointer member. Pointer leaves are stored as
ulongandOpCompositeInsertalready casts to that on the way in, butOpCompositeExtractnever cast back, producing an integer-to-pointer conversion that OpenCL C compilers reject.Both are covered by new lit tests (
composite_multiple_indices.spt,composite_extract_pointer_leaf.spt). The first came up in JuliaGPU/OpenCL.jl#504, whose newnested aggregatestest fails on every source-mode (PoCL-C, NVIDIA) CI job. With this branch, OpenCL.jl's fullpoclctest suite passes.