[llvm] Add a threshold to RegStackify to avoid register spills at runtime (PR #97283)
Ryan Hunt via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 1 10:16:48 PDT 2024
eqrion wrote:
> The job of RegStackify is to convert wasm locals into stack values. My understanding of how optimizing codegen in wasm engines work is that they generally first convert all wasm locals and all stack values into SSA values, do their optimizations, and then run regular register allocation against the SSA values. Thus, it shouldn't really matter whether the original values were in wasm locals or on the wasm stack, the amount of register pressure and spilling should be the same. Are you observing a difference in the register spilling on some engine? Can you say more about why it's happening?
>
> +cc some potentially-interested people (@jakobkummerow @eqrion @sunfishcode)
Yes, this is how it works in the SpiderMonkey optimizing compiler.
Our baseline compiler is a different story. There, roughly every local gets a stack slot that is the home for the value and local.get/set become loads/stores to that slot. Whereas for stack values, we do straightline naive register allocation, where if we run out of registers for an expression we spill everything. So maybe it's possible that really deep stack expressions have worse register allocation versus locals? But that would seem odd. And this is also in baseline, were performance is not a big deal.
https://github.com/llvm/llvm-project/pull/97283
More information about the llvm-commits
mailing list