-
Notifications
You must be signed in to change notification settings - Fork 0
fix: resolve CSE and simplify_locals Z3 verification failures #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
avrabe
wants to merge
13
commits into
main
Choose a base branch
from
fix/cse-simplify-locals-verification
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
- CSE: extend locals dynamically in verify.rs for optimizer-added locals - CSE: only cache constants, not LocalGet (values can change) - simplify_locals: skip equivalence substitution with control flow - Result: 25/25 fixtures pass with Z3 verification (was 16/24)
Convert local.set; local.get patterns to local.tee for efficiency. Updates tests to count both LocalSet and LocalTee as stores.
- Remove ignore from test_cse_phase4_duplicate_constants (now passes) - Add find_modified_globals() for LICM global tracking - Add GlobalGet to is_loop_invariant check - Add tests for global.get hoisting in loops
Phase 2 LICM now hoists single invariant instructions from anywhere in loop bodies, not just from the start: - global.get when global not modified in loop - local.get when local not modified in loop - constants (i32/i64/f32/f64) Each hoisted value is stored to a new local before the loop, and replaced with local.get inside the loop.
Enhances LICM Phase 2 to hoist entire invariant expression trees, not just single instructions. Uses stack simulation to identify complete expressions that are loop-invariant.
Adds VerificationCoverage struct and VerificationResult enum to track what percentage of functions are Z3-verified vs skipped. Includes compute_verification_coverage() for module-level metrics.
Implement precise memory verification using Z3 Array theory instead of imprecise symbolic values: - Add Array[BitVec32 -> BitVec8] for byte-addressable memory - Implement I32Load/I32Store with little-endian byte encoding - Implement I64Load/I64Store with little-endian byte encoding - Remove I32Load, I64Load, I32Store, I64Store from skip list - Update contains_memory_instructions to only flag unverifiable ops - Add test_memory_load_store_verification test Also fixes pre-existing clippy warnings in lib.rs.
Implement selective loop verification that allows simple loops to be verified using bounded unrolling while still skipping complex loops: - Rename contains_loops to contains_complex_loops - Add is_complex_loop() to identify loops that are too complex: - Nested loops (loops within loops) - Loops with unverifiable instructions - Loops with > 50 instructions - Add contains_any_loop() for nested loop detection - Add count_instructions() for loop body size checking - Add test_simple_loop_verification test Simple loops without nesting, unverifiable ops, or excessive size are now verified using MAX_LOOP_UNROLL=3 bounded unrolling instead of being skipped entirely.
Show the coverage tracking output in README example. Details about what's verified vs skipped are in FORMAL_VERIFICATION_GUIDE.md, keeping the README evergreen.
- Remove dotnet/android/ghc to free ~10GB disk space - Exclude verification feature from coverage (tested separately in z3-verification) - Z3 compilation + LLVM instrumentation together exhaust runner disk
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.
Summary
Bugs Fixed
1. CSE LocalTee index out of bounds (verify.rs)
2. Unsafe LocalGet CSE (lib.rs)
3. SimplifyLocals equivalence bug (lib.rs)
Test plan