Repository navigation
Conversation
vchuravy
force-pushed
the
vc/jc-20-target-layouts
branch
from
October 19, 2026 17:08
ec3e0cd to
bd35ca5
Compare
Julia lays out structs with the host's alignments, e.g. `Int128` aligned to
16 bytes. A target whose data layout doesn't say otherwise aligns `i128` to
8 (SPIR-V, Metal, BPF), so `{ float, i128 }` has 24 bytes there, where the
Julia struct has 32, and the layout check rejected such structs.
Such a struct is now a packed struct with the fields at Julia's offsets
and byte arrays as padding (`<{ float, [12 x i8], i128 }>`). The field
indices skip the padding, and constants zero it.
Found by GPUCompiler's corpus for `codegen=:juliacodegen`. Native code uses
`{ float, i128 }` there and addresses the fields by byte offset, copying 32
bytes into a 24-byte alloca. `test_module_ir` takes a `datalayout` for
targets whose back end LLVM lacks.
Assisted-by: Claude Code (Opus 5.5)
vchuravy
force-pushed
the
vc/jc-20-target-layouts
branch
from
October 19, 2026 17:35
bd35ca5 to
81d56e6
Compare
vchuravy
force-pushed
the
vc/jc-19-jit
branch
from
October 19, 2026 17:35
903a59d to
821fbc5
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.
Stacked on #20. GPUCompiler's corpus for
codegen=:juliacodegenfound this gap.Julia lays out structs with the host's alignments, e.g.
Int128aligned to 16 bytes. A target whose data layout doesn't specifyi128aligns it to 8 (SPIR-V, Metal, BPF). There,{ float, i128 }has 24 bytes while the Julia struct has 32, and the layout check rejected the struct withUnsupported.When the LLVM struct's size or field offsets differ from Julia's, the layout is now a packed struct with the fields at Julia's offsets and byte arrays as padding, e.g.
<{ float, [12 x i8], i128 }>. The field indices skip the padding, and constants zero it. Host layouts are unchanged.Native code keeps
{ float, i128 }there and addresses fields by byte offset, which means it copies 32 bytes into a 24-byte alloca.Tests (
test/repr.jl):test_module_irnow takes adatalayout).The full suite passes locally on 1.12 and nightly.
🤖 Generated with Claude Code