Do not deduce parameter attributes during CTFE#151842
Do not deduce parameter attributes during CTFE#151842eggyal wants to merge 2 commits intorust-lang:mainfrom
Conversation
5650820 to
ea095f5
Compare
This comment has been minimized.
This comment has been minimized.
This comment was marked as outdated.
This comment was marked as outdated.
|
Reminder, once the PR becomes ready for a review, use |
ea095f5 to
de839fc
Compare
|
Note that ABI "adjustments" typically do more than just deducing parameter attributes. So if "unadjusted" just refers to the attributes, that's confusing naming. Also, having the full signature might be relevant for the UB checking that const-eval and Miri are doing. So it's at least slightly concerning that we shouldn't be able to access some of that info any more. What exactly is the difference between the signatures we obtain this way? |
This comment was marked as outdated.
This comment was marked as outdated.
|
Looking at #151748, it seems like the underlying issue is that fn_sig_of_instance looks at the body of the function. That is indeed somewhat sus -- at least all the UB-relevant information should be deducible without the body. Please extend the PR description to explain this; it currently takes a bit of digging to fiure out what problem you're actually solving. If we end up resolving this by splitting the query, it is very important that the queries have good documentation explaining their relationship. We want to avoid someone changing this code in the future in a way that removes too much information from the "unadjusted" signature. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
de839fc to
6a5ec89
Compare
This comment has been minimized.
This comment has been minimized.
6a5ec89 to
132a633
Compare
|
That name and PR description are much better, thank you! |
|
@bors try |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…tfe, r=<try> Do not deduce parameter attributes during CTFE
|
I gave some feedback on the comments. I have not looked at the actual code changes at all. |
I think the compile time impact for debug and incremental is because |
This comment has been minimized.
This comment has been minimized.
|
When deduced attributes are ignored, i.e., |
This comment has been minimized.
This comment has been minimized.
1077d1e to
53e5caf
Compare
This comment has been minimized.
This comment has been minimized.
53e5caf to
4acdb3a
Compare
|
Some changes occurred in src/tools/cargo cc @ehuss |
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
This comment has been minimized.
This comment has been minimized.
|
Ugh. I appear to have messed up that rebase. Apologies... @rustbot label: -A-LLVM |
`fn_abi_of_instance` can look at function bodies to deduce codegen optimization attributes (namely `ArgAttribute::ReadOnly` and `ArgAttribute::CapturesNone`) of indirectly-passed parameters. This can lead to cycles when performed during typeck, when such attributes are irrelevant. This patch breaks a subquery out from `fn_abi_of_instance`, `fn_abi_of_instance_no_deduced_attrs`, which returns the ABI before such parameter attributes are deduced; and that new subquery is used in CTFE instead.
As a performance optimization, we altogether avoid ever invoking the `fn_abi_of_instance_no_deduced_attrs` query in cases where the build will not deduce parameter attributes.
4acdb3a to
b5f8205
Compare
This comment was marked as resolved.
This comment was marked as resolved.
|
@bors try |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…tfe, r=<try> Avoid generating by-move coroutine MIR during parameter deduction
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (2a788d9): comparison URL. Overall result: ✅ improvements - no action neededBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (secondary -0.8%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary 0.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 480.915s -> 480.739s (-0.04%) |
Ever since #103172,
fn_abi_of_instancemight look at a function's body to deduce certain codegen optimization attributes for its indirectly-passed parameters beyond what can be determined purely from its signature (namely todayArgAttribute::ReadOnlyandArgAttribute::CapturesNone). Since #130201, looking at a function's body in this way entails generating, for any coroutine-closures, additional by-move MIR bodies (which aren't represented in the HIR)—but this requires knowing the types of their context and consequently cycles can ensue if such bodies are generated before typeck is complete (such as during CTFE).Since they have no bearing on the evaluation result, this patch breaks a subquery out from
fn_abi_of_instance,fn_abi_of_instance_no_deduced_attrs, which returns the ABI before such parameter attributes are deduced; and that new subquery is used in CTFE instead (however, since parameter attributes are only deduced in optimized builds, as a performance optimization we avoid calling the new subquery unless we are performing such a build).Fixes #151748
Fixes #152497