bytecodealliance / bytecodealliance/wasmtime

Cranelift: DCE unused stack slots

Open
#6,661 2 comments 0 reactions 0 assignees View on GitHub
cranelift cranelift:goal:optimize-speed
Dominant language
Rust
Stars
18.6k
Forks
1.8k
Avg merge
1d 19h
Merged PRs (30d)
121

Description

If there are explicit stack slots that are never used (say because of some earlier optimization making it dead) then we will never DCE the stack slot itself, and will always allocate stack space for that slot. This can then lead to code that might otherwise not have been emitted, like stack limit checks and stack probes.

Example:

```wat
function %f(i64 vmctx, i32) -> i32 {
gv0 = vmctx
stack_limit = gv0

;; Comment out this unused stack slot and we won't allocate any stack space
;; and therefore won't emit any stack-limit checks. Leave it in and we
;; unnecessarily do those things, even though nothing uses this stack slot.
ss0 = explicit_slot 8

block0(v0: i64, v1: i32):
return v1
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.