Skip to content

Codegen: a Range's inclusive flag lowers as the bool it is; audit:codegen agrees with MIR on range places (#1413) - #1523

Merged
ehartford merged 1 commit into
fix-1411-scope-cleanup-typesfrom
fix-1413-range-flag-bool
Sep 23, 2026
Merged

ehartford merged 1 commit into
fix-1411-scope-cleanup-typesfrom
fix-1413-range-flag-bool

Conversation

@ehartford

@ehartford ehartford commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

analyze audit:all failed on every program that iterates a stored range:
"place 5 in count_range: projection lowers to LLVM type i8 but its MIR
type 13 (bool) lowers to i1; base _3: Range[i32] ... proj[0]=kind0:2".
MIR builds and reads the flag as bool (lower_for_range_var's
new_field_place(range_place, 2, ty_bool), the NK_RANGE aggregate's
int_const_operand(range_inclusive, ty_bool)), while both LLVM layouts of
TY_RANGE (Codegen.sema_type_to_llvm, CodegenDispatch.mir_sema_type_to_llvm)
pushed wl_i8_type for field 2. The layout was the odd one out: every other
bool field lowers through the bool type, to i1. It does here too now.

The layout does not move: an i1 field occupies one byte like the i8 did
(TypeLayout's TY_RANGE size already counts one flag byte), and no runtime
or C boundary takes a Range.

Matrix (audit:all, base stage1 vs this stage1): spec_ss04_7_range_values.w
2 violations -> 0, spec_ss04_7_ranges.w 1 -> 0, behav_range_value.w 2 -> 0;
behav_range_value runs.

Fixture: test/behavior/behav_1413_range_flag_audit.w runs a program over
stored Range and RangeInclusive values (iteration, membership, the
inclusive flag) and audits it clean.

Closes #1413

Stack #1528, bottom to top: #1522 (#1411) → #1523 (#1413) → #1524 (#1429) → #1525 (#1414) → #1526 (#1372) → #1527 (#1417). Each layer holds only its own commit.

Verification (iterate tier; no battery yet — draft until the seed-driven battery is green): stage1 and stage2 built from the stack top on darwin-aarch64 (SDKROOT CLT 15.4) and on native Windows 10 x64; fixtures below pass on both; check --validate-all swept over test/, examples/, lib/std (3188 files) with base stage2 (main f1e3bd2) vs the stack's stage2.

@ehartford

Copy link
Copy Markdown
Contributor Author

Stack #1528 battery (seed-driven, new seed, cold c_import cache, with :drop-audit/:move-audit) on main + #1522 → … → #1527 (head 33e6ba5; every PR head is a tested commit): build ok, :fixpoint ok, :drop-audit ok, :move-audit ok, :test ok (no reds), :test-green ok, :last-green ok. Merges cleanly into main. Merge the stack: gh stack merge 1527 --squash.

@ehartford
ehartford marked this pull request as ready for review September 23, 2026 16:45
…egen agrees with MIR on range places (#1413)

`analyze audit:all` failed on every program that iterates a stored range:
"place 5 in count_range: projection lowers to LLVM type i8 but its MIR
type 13 (bool) lowers to i1; base _3: Range[i32] ... proj[0]=kind0:2".
MIR builds and reads the flag as `bool` (lower_for_range_var's
`new_field_place(range_place, 2, ty_bool)`, the NK_RANGE aggregate's
`int_const_operand(range_inclusive, ty_bool)`), while both LLVM layouts of
TY_RANGE (Codegen.sema_type_to_llvm, CodegenDispatch.mir_sema_type_to_llvm)
pushed `wl_i8_type` for field 2. The layout was the odd one out: every other
bool field lowers through the bool type, to i1. It does here too now.

The layout does not move: an i1 field occupies one byte like the i8 did
(TypeLayout's TY_RANGE size already counts one flag byte), and no runtime
or C boundary takes a Range.

Matrix (audit:all, base stage1 vs this stage1): spec_ss04_7_range_values.w
2 violations -> 0, spec_ss04_7_ranges.w 1 -> 0, behav_range_value.w 2 -> 0;
behav_range_value runs.

Fixture: test/behavior/behav_1413_range_flag_audit.w runs a program over
stored Range and RangeInclusive values (iteration, membership, the
inclusive flag) and audits it clean.
@ehartford
ehartford force-pushed the fix-1413-range-flag-bool branch from 714c9f2 to f3beff4 Compare September 23, 2026 19:40
@ehartford
ehartford removed this pull request from stack #1528 September 23, 2026 19:43
@ehartford
ehartford added this pull request to stack #1563 September 23, 2026 19:43
@ehartford
ehartford merged commit b22ae8b into main Sep 23, 2026
@ehartford
ehartford deleted the fix-1413-range-flag-bool branch September 24, 2026 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

audit:codegen: Range's bool field projects as i8 but MIR types it bool (i1)

1 participant