bytecodealliance / bytecodealliance/wasmtime
Cranelift: develop a bounds-check elimination pass
- Dominant language
- Rust
- Stars
- 18.6k
- Forks
- 1.8k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 121
Description
When using explicit bounds checks for "dynamic" heaps, Cranelift generated code currently includes a comparison and conditional branch for every access (as well as the Spectre-mitigation conditional move if enabled).
In some cases, it should be able to prove that subsequent accesses are "superseded" by the first: they occur at the same or earlier addresses. In such cases, we can only reach the second access if the first bounds-check succeeded (or else we would have trapped), and heaps can never shrink, so the second is unnecessary.
We should develop such an analysis initially with a simple "same index SSA-value" test, and later enhance it with a value range analysis.
Contributor guide
Assessment
This issue has not been assessed yet.