Repository navigation
fix(mir-importer): lower array constants - #183
Merged
Merged
Conversation
Signed-off-by: nik <[email protected]>
… value constants Layered on top of the contributor PR: - replace the U+2014 em-dash in the translate_array_value_constant doc comment (tracked files must not contain em-dashes) - supported-features: note bare/nested array value constants are materialized, and that struct/ADT array-element constants are not yet
nihalpasham
force-pushed
the
prepare-array-constants
branch
from
June 17, 2026 04:27
bd744a0 to
bbf938f
Compare
Collaborator
|
LGTM.
|
meefs
pushed a commit
to meefs/cuda-oxide
that referenced
this pull request
Sep 30, 2026
meefs
pushed a commit
to meefs/cuda-oxide
that referenced
this pull request
Sep 30, 2026
…t arch (NVIDIA#185) Follow-ups to NVIDIA#183 (issue NVIDIA#172): - Extract redist archives with --skip-old-files --warning=existing-file: cross-archive path collisions become first-wins and visible in the build log instead of silently taking whichever archive extracted last. Reorder libnvvm ahead of cuda_nvcc so canonical nvvm/ files win under first-wins, and document that the list order now matters. - Assert bin/tileiras and nvvm/lib64/libnvvm.so exist after assembly so the exe-relative-lookup failure mode from NVIDIA#172 cannot silently regress on a future version bump. - Derive the Debian multiarch driver directory from uname -m instead of enumerating per-arch triplets: shorter, searches the host arch first, and covers future architectures without edits. - Point the hash bookkeeping at NVIDIA's redistrib_13.3.0.json manifest for future version bumps. Signed-off-by: Melih Elibol <[email protected]>
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.
Closes #182.
Problem
The MIR importer could lower pointer-to-array constants such as
&[T; N], but bare array value constants such asconst TABLE: [T; N]could still fall through as unsupported when indexed by runtime values. Nested constants such as[[T; M]; N]also lacked recursive array construction, so only flat primitive arrays were effectively covered.Fix
Array constant lowering now has one shared value-construction path. Pointer-to-array constants decode the array value through that helper and then wrap it in
MirRefOp; bare array constants return the constructedMirConstructArrayOpvalue directly. The helper recursively handles nested arrays whose leaves are primitive scalar elements.Unsupported element types are rejected explicitly. The supported byte-lowered array leaves are integer, f16, f32, and f64 values, plus nested arrays of those leaves. Byte-backed constants with uninitialized bytes are now diagnosed instead of silently zero-filled.
Diligence
Checked the sibling pointer-to-array path and routed it through the same array-value helper so bare arrays and
&[T; N]cannot drift. Kept the existing scalar constant and aggregate paths separate, but hardened the sharedconstant_byteshelper used by byte-backed constants so unsupported uninitialized bytes are not hidden.Struct/ADT array elements remain unsupported in this PR because they need layout-aware recursive field decoding rather than the primitive byte-slicing rule used here.
Tests
Added
crates/rustc-codegen-cuda/examples/array_constantscovering:[f32; 4]constants indexed by runtime thread id,[[u32; 3]; 2]constants with runtime row/column selection,&[u32; 4]constants to preserve existing behavior.Validation
Passed local targeted validation:
cargo fmt -p mir-importer -- --check cargo fmt --manifest-path crates/rustc-codegen-cuda/examples/array_constants/Cargo.toml -- --check scripts/smoketest.sh --compile-only --no-color --only '^array_constants$'