fix: refactor if-statement codegen and enhance test runner#257
Merged
LunaStev merged 1 commit intowavefnd:masterfrom Dec 26, 2025
Merged
fix: refactor if-statement codegen and enhance test runner#257LunaStev merged 1 commit intowavefnd:masterfrom
LunaStev merged 1 commit intowavefnd:masterfrom
Conversation
Refactor the LLVM IR generation for `If` statements to fix control flow
ordering and improve robustness, alongside significant improvements to
the integration test runner.
Changes:
- Codegen (`statement.rs`):
- Implement explicit type coercion for conditions: automatically
converts Integers, Floats, and Pointers to `i1` (boolean) for LLVM
branch instructions.
- Fix BasicBlock ordering and termination logic for `else if` and
`else` chains to ensure correct control flow.
- Ensure all code paths properly terminate by branching to the merge block.
- Tools (`run_tests.py`):
- Add a background thread to send a UDP packet for `test61.wave`,
allowing the network listener test to pass without timing out.
- Introduce a `SKIP` status for known interactive tests (e.g.,
`test22.wave`) to prevent false-positive failures in CI.
- Update output formatting and summary to distinguish skipped tests.
- Config:
- Remove custom funding link from `.github/FUNDING.yml`.
Signed-off-by: LunaStev <luna@lunastev.org>
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.
This PR addresses critical issues in the code generation logic for
ifstatements and significantly upgrades the integration testing infrastructure. The changes ensure that control flow is generated correctly for complex conditional chains and that the automated test suite can handle networking and interactive scenarios without manual intervention.Key Changes
1. Robust
IfStatement Codegeni1(boolean) types. This allows the Wave compiler to support C-style truthiness (e.g.,if (pointer)) while satisfying LLVM's strict branching requirements.else ifandelseBasicBlock generation to ensure correct linear ordering in the IR.mergeblock, leading to "terminator found in the middle of a block" errors.2. Test Runner (
run_tests.py) Enhancementstest61.wave. This allows the network listener test to receive data and exit successfully instead of hanging until a timeout.SKIPstatus for tests that require manual user input (e.g.,test22.waveforinput()verification). This prevents the CI/CD pipeline from reporting false-positive failures for tests that cannot be fully automated.3. Maintenance
.github/FUNDING.yml.Examples of Improved Codegen Behavior
Benefits
ifcondition behavior closer to industry standards (C/C++, Rust).