-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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_codegen_ssa: Don't drop IncorrectCguReuseType
, make rustc_expected_cgu_reuse
attr work
#118973
Conversation
(rustbot has picked a reviewer for you, use r? to override) |
Spraying |
Great find, @Enselic! I'll take a look at this. |
Hm, so this does seem to have regressed. Quite a few CGUs go from |
Looks like not emitting the error was introduced in 706452e (merged Aug 31, 2022). I wonder when the test cases regressed though. |
These seem to start failing after #115964 (which refactors CGU reuse tracking). @bjorn3, any ideas where the change in behavior could come from? This one already fails before #115964:
However, there the change is from |
See the PR description:
It seems there were tests after all, but because of this bug didn't actually fail. It is still fragile to the exact implementation of ThinLTO though. The tests would also almost certainly fail for cg_gcc and definitively fail for cg_clif. |
Does that mean that post-LTO artifacts can never be re-used? |
cg_clif doesn't do any LTO, so post-lto reusing never happens. As for cg_gcc, GCC doesn't have ThinLTO, instead it has something closer to fat LTO except that it can split it into multiple independent modules. The exact heuristics for this are different from LLVM's ThinLTO and thus would likely cause the tests to fail. Also cg_gcc doesn't have anything like thin-local-lto yet, which these tests rely on. |
Sorry for the confusion. What I meant was: Does #115964 unconditionally turn off post-LTO artifact caching when using LLVM with ThinLTO? |
From what I can tell, #115964 only changes whether postLTO reuse is reported to the tracker, but does not change the reuse behavior itself. I wonder if we can restore the reporting. You're right that this depends on the implementation of ThinLTO in LLVM, but I think there's value in having at least some testing here, right? I.e. there are some simple cases that we expect to keep working. I'll open an issue about this. The testing situation could use some improvement here, also with respect to other backends. As it is right now, the tests are misleading because they don't reflect what's actually happening. |
No it does not. It merely hides post-lto caching from the cgu_reuse_tracker. Previously whenever a post-lto artifact was reused, this fact would be written into the
👍 |
@michaelwoerister I now have looked a bit into changing the I agree it is a good idea and that it would be nice to get it done. |
Adding
Hmm maybe we could change |
I've tried https://github.com/mystor/synstructure/blob/1079497eb2bea252433dac53afe41291d8779641/src/macros.rs#L64-L78 but didn't work too. |
|
Indeed, a derive macro cannot change the type it is attached to. An attribute macro could do that. But changing the diag macro is something that wg-diagnostics would need to decide, I'd say.
Interesting. Have you tried adding the attribute at different positions? That is: #[must_use]
#[derive(...)]
#[diag]
struct Foo {} vs #[derive(...)]
#[diag]
#[must_use]
struct Foo {} for example? But I actually think that making the |
c25589a
to
88b6ff7
Compare
cc @davidtwco, @compiler-errors, @TaKO8Ki Some changes occurred in compiler/rustc_codegen_gcc |
The I pushed commits now to make You'll want to review individual commits since the full diff is >1000 lines now (which is annoying and I would love to not have to do that if there is a way to avoid it). (I can't do it in a separate PR yet since it won't build without the fix in this PR.) |
This comment has been minimized.
This comment has been minimized.
88b6ff7
to
2f1a031
Compare
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
This comment has been minimized.
This comment has been minimized.
2f1a031
to
3c7f6b1
Compare
This comment has been minimized.
This comment has been minimized.
3c7f6b1
to
2ad44f8
Compare
Enums with |
This PR makes
require must_use. A natural follow-up is to also enforce this on
but let's wait with that until we know we want this at all. I'd rather not spend time on implementing that only to then have to throw it all in the bin. |
☔ The latest upstream changes (presumably #119063) made this pull request unmergeable. Please resolve the merge conflicts. |
I've opened #119076 to document that CGU reuse tracking only reports pre-LTO reuse.
I actually think that it would be better to
What do you think, @Enselic? |
2ad44f8
to
43491ec
Compare
To be clear, with the code I had it is impossible to forget must_use, because if you forget must_use on a struct you get this error at compile time:
but I completely agree we should get the original bugfix of this PR merged before we continue to iterate on the must_use-solution. I forced pushed away the must_use-commits now. |
Oh, you made the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggested comments linking to the issue.
Otherwise, this looks ready to merge, r=me. Thanks again for uncovering this, @Enselic!
tests/incremental/thinlto/independent_cgus_dont_affect_each_other.rs
Outdated
Show resolved
Hide resolved
tests/incremental/thinlto/independent_cgus_dont_affect_each_other.rs
Outdated
Show resolved
Hide resolved
tests/incremental/thinlto/independent_cgus_dont_affect_each_other.rs
Outdated
Show resolved
Hide resolved
tests/incremental/thinlto/independent_cgus_dont_affect_each_other.rs
Outdated
Show resolved
Hide resolved
In [100753], `IncorrectCguReuseType` accidentally stopped being emitted. Begin emitting it again rather than just blindly dropping it, and adjust tests accordingly. [100753]: rust-lang@706452e#diff-048389738ddcbe0f9765291a29db1fed9a5f03693d4781cfb5aaa97ffb3c7f84
38d40c2
to
d46df80
Compare
… r=michaelwoerister rustc_codegen_ssa: Don't drop `IncorrectCguReuseType` , make `rustc_expected_cgu_reuse` attr work In [100753], `IncorrectCguReuseType` accidentally stopped being emitted by removing `diag.span_err(...)`. Begin emitting it again rather than just blindly dropping it, and adjust tests accordingly. We assume that there are no bugs and that the currently actual CGU reuse is correct. If there are bugs, they will be discovered and fixed eventually, and the tests will then be updated. [100753]: rust-lang@706452e#diff-048389738ddcbe0f9765291a29db1fed9a5f03693d4781cfb5aaa97ffb3c7f84 Closes rust-lang#118972
…mpiler-errors Rollup of 7 pull requests Successful merges: - rust-lang#118691 (Add check for possible CStr literals in pre-2021) - rust-lang#118973 (rustc_codegen_ssa: Don't drop `IncorrectCguReuseType` , make `rustc_expected_cgu_reuse` attr work) - rust-lang#119071 (-Znext-solver: adapt overflow rules to avoid breakage) - rust-lang#119089 (effects: fix a comment) - rust-lang#119096 (Yeet unnecessary param envs) - rust-lang#119118 (Fix arm64e-apple-ios target) - rust-lang#119134 (resolve: Feed visibilities for unresolved trait impl items) r? `@ghost` `@rustbot` modify labels: rollup
…mpiler-errors Rollup of 7 pull requests Successful merges: - rust-lang#118691 (Add check for possible CStr literals in pre-2021) - rust-lang#118973 (rustc_codegen_ssa: Don't drop `IncorrectCguReuseType` , make `rustc_expected_cgu_reuse` attr work) - rust-lang#119071 (-Znext-solver: adapt overflow rules to avoid breakage) - rust-lang#119089 (effects: fix a comment) - rust-lang#119096 (Yeet unnecessary param envs) - rust-lang#119118 (Fix arm64e-apple-ios target) - rust-lang#119134 (resolve: Feed visibilities for unresolved trait impl items) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#118691 (Add check for possible CStr literals in pre-2021) - rust-lang#118973 (rustc_codegen_ssa: Don't drop `IncorrectCguReuseType` , make `rustc_expected_cgu_reuse` attr work) - rust-lang#119071 (-Znext-solver: adapt overflow rules to avoid breakage) - rust-lang#119089 (effects: fix a comment) - rust-lang#119094 (Add function ABI and type layout to StableMIR) - rust-lang#119102 (Add arm-none-eabi and armv7r-none-eabi platform-support documentation.) - rust-lang#119107 (subtype_predicate: remove unnecessary probe) Failed merges: - rust-lang#119135 (Fix crash due to `CrateItem::kind()` not handling constructors) - rust-lang#119141 (Add method to get instance instantiation arguments) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#118973 - Enselic:fix-IncorrectCguReuseType, r=michaelwoerister rustc_codegen_ssa: Don't drop `IncorrectCguReuseType` , make `rustc_expected_cgu_reuse` attr work In [100753], `IncorrectCguReuseType` accidentally stopped being emitted by removing `diag.span_err(...)`. Begin emitting it again rather than just blindly dropping it, and adjust tests accordingly. We assume that there are no bugs and that the currently actual CGU reuse is correct. If there are bugs, they will be discovered and fixed eventually, and the tests will then be updated. [100753]: rust-lang@706452e#diff-048389738ddcbe0f9765291a29db1fed9a5f03693d4781cfb5aaa97ffb3c7f84 Closes rust-lang#118972
In 100753,
IncorrectCguReuseType
accidentally stopped being emitted by removingdiag.span_err(...)
. Begin emitting it again rather than just blindly dropping it, and adjust tests accordingly.We assume that there are no bugs and that the currently actual CGU reuse is correct. If there are bugs, they will be discovered and fixed eventually, and the tests will then be updated.
Closes #118972