aarch64/llvm: Improve compatibility #15962
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The previous experiment (lowering all tail calls to branch) worked really well, but at IR level we lack the flexibility to solve some problems. A common one is that we would clobber our own data due to cyclic assignments on very large functions with high register pressure. For example
After several variations attempted, I came to the conclusion that this approach will never work at IR level. LLVM can be "dumb" sometimes even when register clobbering information is communicated properly.
A simpler approach is to let the link register overwrite happen and simply reload it on return. This was not an option previously due to the way the stack behaved in earlier iterations, but the shape of the current calls ensures this is not a problem:
A side effect of this is that the dummy movs disappeared and we don't need to post-process the machine code for to fix them up anymore. This makes the codegen much smaller and there is a small perf boost to go along with that.