Expand description
Β§Micro-pass: remove the dynamic checks for array/slice bounds, overflow, and division by zero.
Note that from a semantic point of view, an out-of-bound access or a division by zero must lead to a panic in Rust (which is why those checks are always present, even when compiling for release). In our case, we take this into account in the semantics of our array/slice manipulation and arithmetic functions, on the verification side.
StructsΒ§
- Pending
Shift πCheck - A shift overflow check whose shift operation is not in the same block: rustc evaluates the
shift operands (which is when it emits the overflow check) before computing the destination
place, so when that computation involves a function call (e.g.
out[i] = x >> ythrough an overloadedIndexMut), the check ends up separated from the shift by the call terminator. See issue #1041. These asserts are only ever emitted by the compiler, so instead of following the control flow we record the check and find the matching shift over the whole body in resolve_pending_shift_check. - Transform
FunctionsΒ§
- compute_
uses π - Compute for each block the locals that are assumed to have been initialized/defined before entering it.
- equiv_
op π - Check if the two operands are equivalent: either theyβre the same constant, or they represent the same place (regardless of whether the operand is a move or a copy)
- make_
binop_ πoverflow_ panic - make_
unop_ πoverflow_ panic - remove_
dynamic_ πchecks - Rustc inserts dynamic checks during MIR lowering. They all end in an
Assertstatement (and this is the only use of this statement). - resolve_
pending_ πshift_ check - Resolve a PendingShiftCheck whose shift landed in a different block. We remove the check and compute the shift early, promoted to panic-on-overflow, into a fresh local placed where the check used to be; the fresh local then carries the result to the original destination.
- uses_
local π - Whether the value uses the given local in a place.
Type AliasesΒ§
- Local
Uses π