Closed SingleAccretion closed 5 months ago
@dotnet/nativeaot-llvm
Can we mark the call as LLVM
tailcc
convention?
No, it's not supported for WASM. This convention is used on other platforms for "must-tail" tail calls, in .NET parlance that would be the .tail
prefix (in Jit parlance these are "explicit" tail calls), tail calls that must be tail called for correctness purposes.
WASM has an extension for tail calls which enables this "must-tail" functionality, but it's not part of the default set.
You can mark a call in LLVM as simply "tail", which is more akin to the implicit tail calls in the Jit, but that too requires the tail call extension, and would result in actual, physical, tail call - something we would need stronger checking for (and, ideally, something integrated with the frontend).
Reading https://llvm.org/docs/CodeGenerator.html#tail-call-optimization, there appears to be some support in LLVM, is it the constraints we dont meet?
there appears to be some support in LLVM, is it the constraints we dont meet?
We do meet them (or can check for them), the problem is The ‘tail-call’ target attribute is enabled
: the support is spotty at best at the moment:
And it's not a critical feature to have outside of the .tail
support.
Closes #2213.
Calls in a tail position in methods without implicitly live shadow state can be tail-called, i. e. called on the caller's shadow frame. This is both a code size and performance optimization, the latter because GC needs to do less work.
Diffs: