bytecodealliance / bytecodealliance/wasmtime
Remove the `global_value` CLIF instruction
- Dominant language
- Rust
- Stars
- 18.6k
- Forks
- 1.8k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 121
Description
This would force us to translate all unnecessary uses of `ir::Global` into regular CLIF instructions.
Note: We have to keep `cranelift_codegen::ir::Global`s around for special things like the stack limit check, which are not (and can't ever really be) represented in regular CLIF instructions, since they happen inside of function prologues or what not.
However, we end up using `ir::Global`s in lots of other places where we could just use regular CLIF instructions instead. For example, we use them to represent Wasm globals in our Wasm to CLIF translation layer. This is annoying because now we have to fit Wasm globals into different kinds of `ir::Global`s, and it would just be easier to emit the CLIF instructions to get/set the Wasm global directly. These unnecessary `ir::Global` uses just introduce extra abstraction layers that don't buy us anything, add instructions that require legalization processing in the mid-end, make it harder to follow code through the compiler pipeline because there are extra and unnecessary rewrites, etc...
I propose that we remove the `global_value` CLIF instruction (the instruction that turns an `ir::Global` into an `ir::Value`). Every use of `global_value` could instead just be the constant or (chained) load that it would otherwise be legalized into, and emitting that already-legalized code will be easier to follow and also mildly more efficient since it doesn't need that legalization anymore. It also means we can remove the associated legalization code.
Contributor guide
Assessment
This issue has not been assessed yet.