[llvm] [WebAssembly] Enable a limited amount of stackification for debug code (PR #136510)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 26 12:26:13 PDT 2025
SingleAccretion wrote:
> Does the code you're testing come from C#/CLR or somewhere else?
It is indeed C#/IL, mostly from the standard library, compiled with our LLVM-based compiler. It differs from typical C/C++ WASM in that it has a lot of `if (x != null) CallThrowMethod()` code sequences, and passes around an additional first argument (our own shadow stack) so it also has a lot of `x + 12`-like expressions.
I expect these wins to translate very well to C/C++ code as well (most any code, really). Compiling [this little GC implementation](https://github.com/dotnet/runtime/blob/main/src/coreclr/gc/gc.cpp), I see a 45% reduction in code size (600Kb -> 335Kb).
> With clang's O0 compilation, basically all of the C locals do live on the stack, and are written back on every sequence point, so I would actually not expect this to have much of an effect on debugging for such code, but it might improve code size
Indeed. In `-O0 -g`, the only actual local that matters is the frame base, everything else is computed based on it. So all these thousands of locals are not very useful.
(The same is true for our compiler, so to test the location coverage, I forced a mode where it would emit `dbg.value`s instead of `dbg.declare`s with optimized LLVM IR which is then ran through `llc -O0`.)
https://github.com/llvm/llvm-project/pull/136510
More information about the llvm-commits
mailing list