RISC-V no-panic (part 2)#736
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR continues the effort to make the RISC-V vector interpreter codebase no-panic compatible by removing panicking paths (e.g., expect) and adding no_panic annotations, plus a CI tweak to allow more inlining for the analysis to succeed.
Changes:
- Replace some
expect(...)-based invariants withunwrap_unchecked()guarded by explicit safety comments in widen/narrow helpers. - Add
#[cfg_attr(feature = "no-panic", no_panic_const::no_panic)]to a number of vector helper entrypoints that previously had TODO markers. - Refactor mul/div helpers to use
widening_mulandwrapping_{div,rem}; increase CI inline threshold for the no-panic job.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/execution/ab-riscv-interpreter/src/v/zvexx/widen_narrow/zvexx_widen_narrow_helpers.rs | Switch sign-extension helpers to take Vsew; remove expect in favor of unwrap_unchecked; add no_panic attribute to execute helpers. |
| crates/execution/ab-riscv-interpreter/src/v/zvexx/widen_narrow.rs | Update callers to new sign_extend_bits signature (notably XLEN scalar handling). |
| crates/execution/ab-riscv-interpreter/src/v/zvexx/store/zvexx_store_helpers.rs | Add no_panic attribute to store execute helpers (replacing TODO markers). |
| crates/execution/ab-riscv-interpreter/src/v/zvexx/reduction/zvexx_reduction_helpers.rs | Add no_panic attribute to reduction execute helpers (replacing TODO markers). |
| crates/execution/ab-riscv-interpreter/src/v/zvexx/perm/zvexx_perm_helpers.rs | Add no_panic attribute to permute/slide/merge/compress helpers (replacing TODO markers). |
| crates/execution/ab-riscv-interpreter/src/v/zvexx/muldiv/zvexx_muldiv_helpers.rs | Refactor multiply-high/div/rem helpers to reduce panic potential and use widening ops; add no_panic attributes. |
| crates/execution/ab-riscv-interpreter/src/v/zvexx/mask/zvexx_mask_helpers.rs | Add no_panic attribute to mask helpers (replacing TODO markers). |
| crates/execution/ab-riscv-interpreter/src/v/zvexx/load/zvexx_load_helpers.rs | Add no_panic attribute to load helpers (replacing TODO markers). |
| crates/execution/ab-riscv-interpreter/src/v/zvexx/fixed_point/zvexx_fixed_point_helpers.rs | Add no_panic attribute to fixed-point helpers (replacing TODO markers). |
| crates/execution/ab-riscv-interpreter/src/v/zvexx/config/zvexx_config_helpers.rs | Add no_panic attribute to vsetvl/vsetivli config helpers (replacing TODO markers). |
| crates/execution/ab-riscv-interpreter/src/v/zvexx/carry/zvexx_carry_helpers.rs | Add no_panic attribute to carry/borrow helpers (replacing TODO markers). |
| crates/execution/ab-riscv-interpreter/src/v/zvexx/arith/zvexx_arith_helpers.rs | Add no_panic attribute to arithmetic/compare helpers (replacing TODO markers). |
| crates/execution/ab-riscv-interpreter/src/lib.rs | Enable the widening_mul nightly feature gate. |
| crates/execution/ab-riscv-interpreter/Cargo.toml | Update feature-notes comment (removing now-addressed TODO item). |
| .github/workflows/rust.yml | Increase LLVM inline threshold for the no-panic check job. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
nazar-pc
force-pushed
the
riscv-no-panic-part-2
branch
from
July 21, 2026 08:59
22399de to
4482527
Compare
nazar-pc
force-pushed
the
riscv-no-panic-part-2
branch
from
July 21, 2026 09:04
4482527 to
7ca92fc
Compare
nazar-pc
force-pushed
the
riscv-no-panic-part-2
branch
from
July 21, 2026 09:08
7ca92fc to
2835c50
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 16 out of 16 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
crates/execution/ab-riscv-primitives/src/instructions/v.rs:515
Vsew::from_xlenis annotated with#[cfg_attr(feature = "no-panic", no_panic_const::no_panic)]but still contains apanic!()path. BecauseReg::XLENis not statically proven to be only 32/64 for allRegisterimpls, this will likely fail the no-panic check (and contradicts the goal of the PR). Consider making the “impossible” arm panic-free underfeature="no-panic"(while keeping a panic in normal builds).
64 => Self::E64,
_ => {
// TODO: Should have been `unreachable!()`:
// https://github.com/rust-lang/rust/issues/159645
panic!("Invalid register width")
nazar-pc
force-pushed
the
riscv-no-panic-part-2
branch
from
July 21, 2026 09:18
2835c50 to
c3715fb
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.
More things were already panic-free, just needed a higher inlining limits. Others required minor changes and clarifications to nudge compiler towards the correct conclusion.