-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Missing optimization around __rust_alloc and unknown functions if panic=unwind #46515
Comments
@eddyb suggested I try |
Aha! I think I got it. In the IR for the Rust program, the unwinding branch calls So, to fix this, we'd have to remove this |
Box<T> drop glue is pretty simple and should not lead to blow-up problems. Moreover, not inlining it leads to LLVM pessimizing some pointer-based optimizations because it thinks the pointer passed to the drop glue could be escaped. Fixes rust-lang#46515. However, this is not a great fix -- the problem still exists for other smart pointers besides `Box`.
CC @nox, @rust-lang/wg-codegen |
Could this be preventing other optimisations than pointer equality folding? Cc @rust-lang/compiler |
@nox definitely. My guess is that alias analysis is being overly conservative here and is declaring pointers to be |
However, pointer equality optimizations and aliasing information are (AFAIK) mostly unrelated -- in particular, optimizing equalities based on int foo(restrict int *x, restrict int *y) {
// The restrict will compile to noalias in LLVM. However, C does not let you
// optimize the following unless both x and y are actually dereferenced.
(x == y) ? 1 : 0
} |
Triage: this optimization still does not happen. |
Revert "Auto merge of rust-lang#92419 - erikdesjardins:coldland, r=nagisa" Should fix (untested) rust-lang#94390 Reopens rust-lang#46515, rust-lang#87055 r? `@ehuss`
@nagisa @erikdesjardins Oh no, #95338 ended up triggering LLVM to close this again. |
…=nikic Rebased: Mark drop calls in landing pads cold instead of noinline I noticed that certain inlining optimizations were missing while staring at some compiled code output. I'd like to see this relanded, so I rebased the PR from ``@erikdesjardins`` (PR rust-lang#94823). This PR reapplies rust-lang#92419, which was reverted in rust-lang#94402 due to rust-lang#94390. Fixes rust-lang#46515, fixes rust-lang#87055. Update: fixes rust-lang#97217.
…ikic Rebased: Mark drop calls in landing pads cold instead of noinline I noticed that certain inlining optimizations were missing while staring at some compiled code output. I'd like to see this relanded, so I rebased the PR from `@erikdesjardins` (PR rust-lang#94823). This PR reapplies rust-lang#92419, which was reverted in rust-lang#94402 due to rust-lang#94390. Fixes rust-lang#46515, fixes rust-lang#87055. Update: fixes rust-lang#97217.
Rebased: Mark drop calls in landing pads cold instead of noinline I noticed that certain inlining optimizations were missing while staring at some compiled code output. I'd like to see this relanded, so I rebased the PR from `@erikdesjardins` (PR #94823). This PR reapplies rust-lang/rust#92419, which was reverted in rust-lang/rust#94402 due to rust-lang/rust#94390. Fixes rust-lang/rust#46515, fixes rust-lang/rust#87055. Update: fixes #97217.
The following code gets optimized as expected:
becomes
However, if I let the code call an unknown function instead of return, the optimization disappears:
becomes
That seems wrong, why should the optimization stop kicking in? The corresponding C code does not have any problem:
becomes
(I briefly thought maybe unwinding is the problem, but C should have the same kind of unwinding here.)
The text was updated successfully, but these errors were encountered: