[llvm] Add a threshold to RegStackify to avoid register spills at runtime (PR #97283)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 2 01:40:02 PDT 2024
jakobkummerow wrote:
I don't think V8 cares about stack vs locals. If there's a specific case where it seems otherwise, I'd like to hear about it.
One point that comes to mind is that our baseline compiler reserves a slot on the physical stack for every local. So in a pathological case where a function has many short-lived locals, that function's stack frame will be big, whereas it could be much smaller if the locals were replaced with stack values. I'm not aware of that being observed as an issue in practice though.
(A related earlier discussion this reminds me of is that sometimes it's helpful when the toolchain hoists computations out of loops rather than relying on the engine to do that; that typically means assigning the value to a local before the loop and reading that local in the loop, whereas the non-hoisted version wouldn't need a local and could just keep the value on the stack. In that case, it's not the difference between local and stack that's relevant, but the act of moving a couple of machine instructions out of a particularly hot path. The tradeoff is that hoisting extends life ranges, which can cause more spilling, which can eat up the benefits of avoiding repeated computations; it's one of those cases where it's exceedingly hard to come up with good heuristics that get that balance right.)
https://github.com/llvm/llvm-project/pull/97283
More information about the llvm-commits
mailing list