-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rustc beta (1.28.0) generates unnecessary call instruction #52651
Comments
cc @rust-lang/compiler (I've not attempted a reproduction locally) |
This might be due to #49479, the time frame seems right and the code change observed here is precisely what MergeFunctions does. Some observations:
|
cc @nox |
@rkruppe Huh, I thought we used |
@eddyb Evidently we're not using it. I don't know of any reason to make promises here, but since we de facto don't merge addresses, who knows whether anyone in the wild is relying on it for crazy shenanigans 🤷♂️ |
Interestingly, the LLVM IR the sample code results in appears to be using both define void @bar(%A* noalias nocapture sret dereferenceable(16), %A* noalias nocapture readonly dereferenceable(16) %self) unnamed_addr #0 {
; ...
}
; ...
define void @foo(%A* noalias nocapture sret dereferenceable(16), %A* noalias nocapture readonly dereferenceable(16)) unnamed_addr #0 {
tail call void @bar(%A* noalias nocapture sret dereferenceable(16) %0, %A* noalias nocapture readonly dereferenceable(16) %1) #0
ret void
} |
The lack of a tail call is caused by the |
There is no attempt to alias
I will look into submitting a patch to LLVM. |
For the record, I've submitted a couple of patches for MergeFuncs to improve handling in some cases and add alias support. They're accepted, but not landed yet: https://reviews.llvm.org/D53262 The alias functionality will be behind a |
The patches have all landed upstream. After the next LLVM update, we can enable use of aliases by passing
|
If the Rust LLVM fork is used, enable the -mergefunc-use-aliases flag, which will create aliases for merged functions, rather than inserting a call from one to the other. A number of codegen tests needed to be adjusted, because functions that previously fell below the thunk limit are now being merged. Merging is prevented either using -C no-prepopulate-passes, or by making the functions non-identical. I expect that this is going to break something, somewhere, because it isn't able to deal with aliases properly, but we won't find out until we try :) This fixes rust-lang#52651.
Enable -mergefunc-use-aliases If the Rust LLVM fork is used, enable the -mergefunc-use-aliases flag, which will create aliases for merged functions, rather than inserting a call from one to the other. A number of codegen tests needed to be adjusted, because functions that previously fell below the thunk limit are now being merged. Merging is prevented in various ways now. I expect that this is going to break something, somewhere, because it isn't able to deal with aliases properly, but we won't find out until we try :) This fixes #52651. r? @rkruppe
For this code:
rustc beta (1.28.0) with
opt-level=3
generates:rustc 1.27.1 and rustc beta with
opt-level=s
generates:The beta with
opt-level=3
seems to be anti-inlining the identical functions.The text was updated successfully, but these errors were encountered: