Repository navigation
Codegen: a Range's inclusive flag lowers as the bool it is; audit:codegen agrees with MIR on range places (#1413) - #1523
Merged
Conversation
This was referenced Sep 23, 2026
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: |
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
force-pushed
the
fix-1413-range-flag-bool
branch
from
September 23, 2026 19:40
714c9f2 to
f3beff4
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.
analyze audit:allfailed 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'snew_field_place(range_place, 2, ty_bool), the NK_RANGE aggregate'sint_const_operand(range_inclusive, ty_bool)), while both LLVM layouts ofTY_RANGE (Codegen.sema_type_to_llvm, CodegenDispatch.mir_sema_type_to_llvm)
pushed
wl_i8_typefor field 2. The layout was the odd one out: every otherbool 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-allswept over test/, examples/, lib/std (3188 files) with base stage2 (main f1e3bd2) vs the stack's stage2.