Skip to content

Fix freestanding helper attributes, literal truthiness, and array returns - #922

Merged
LunaStev merged 1 commit into
wavefnd:masterfrom
LunaStev:fix/freestanding-and-value-semantics
Oct 13, 2026
Merged

LunaStev merged 1 commit into
wavefnd:masterfrom
LunaStev:fix/freestanding-and-value-semantics

Conversation

@LunaStev

Copy link
Copy Markdown
Member

Summary

Fix three reproduced compiler defects:

  • Apply the existing target and freestanding function attributes to late-created arithmetic helpers, preventing AMD64 red-zone spills in freestanding code.
  • Preserve untyped integer values before truthiness checks. if (4294967296) now takes the branch, consistently with an explicit bool cast; logical operands no longer borrow each other's arithmetic width.
  • Load fixed-array values at return boundaries, so returning an initialized array variable or parameter builds successfully instead of producing E9001.

Motivation

Closes #912
Closes #913
Closes #914

The audit reproduced missing helper attributes in AMD64 disassembly, a silently false nonzero literal condition at O0/O2, and array returns that passed semantic checking but failed during LLVM lowering. Regression coverage includes those triggers and their compatibility boundaries.

Target and compatibility impact

LLVM remains the default and the existing --whale selection is unchanged. Preserve explicit integer narrowing and wrapping, ordered conversions, short-circuit evaluation, and ordinary array address/indexing behavior. No dependency, version, CLI or target-coverage changes.

The Whale regression uses verified textual IR and the bounded upstream integer interpreter. It does not add native Whale execution or integers wider than the adapter's supported subset. Design items #918, #919 and #920 remain separate.

Validation

Passed with Rust 1.89.0 and LLVM 21.1.8:

LLVM_SYS_211_PREFIX=/usr/lib64/llvm21 cargo +1.89 test --locked --offline --jobs 2 --workspace --all-targets --target-dir /tmp/wave-alpha-nine-target
LLVM_SYS_211_PREFIX=/usr/lib64/llvm21 cargo +1.89 clippy --locked --offline --jobs 2 --workspace --all-targets --target-dir /tmp/wave-alpha-nine-target -- -D warnings
cargo +1.89 fmt --all -- --check
git diff --check
  • 407 Rust tests passed across 46 suites.
  • New shared cases test140.wave and test141.wave ran on Linux amd64 at O0/O2 and wasm64 at O2. They cover literal conditions/casts/logical-not, loop conditions, skipped invalid shifts, and local/parameter/literal/grouped/nested/empty array returns.
  • Both cases generated IR and objects for Linux amd64/arm64/riscv64/loongarch64, macOS amd64/arm64, Windows amd64/arm64, FreeBSD amd64 and wasm64: 20 successful builds.
  • AMD64 O0/O2 arithmetic-helper disassembly no longer contains the reproduced red-zone stack accesses. IR regressions also check CPU/features and hosted behavior.
  • Native execution on the other operating systems and Linux architectures remains for CI; cross-object generation is not execution validation.

Checklist

  • Commits include a DCO Signed-off-by line.
  • Tests cover new behavior or the PR explains why no test is needed.
  • User-facing changes include documentation or diagnostics updates. Array returns no longer report an internal error; these are corrections to existing behavior.
  • The change preserves the license boundary between the compiler and std/.

Fix late-created helper attributes, untyped integer truthiness, and array value returns. Add native, HIR, and bounded Whale oracle regressions for wavefnd#912, wavefnd#913 and wavefnd#914.

Signed-off-by: LunaStev <luna@lunastev.org>
@LunaStev
LunaStev merged commit e0952ed into wavefnd:master Oct 13, 2026
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant