Skip to content
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

Remove incorrect use of nocapture attribute #137726

Closed
wants to merge 1 commit into from

Conversation

tmiasko
Copy link
Contributor

@tmiasko tmiasko commented Feb 27, 2025

When using indirect pass mode, a callee can obtain an address of an
argument and capture it. The nocapture attribute promises this does not
happen and so it cannot be added unconditionally.

Fixes #137668.

@rustbot
Copy link
Collaborator

rustbot commented Feb 27, 2025

r? @petrochenkov

rustbot has assigned @petrochenkov.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 27, 2025
@tmiasko
Copy link
Contributor Author

tmiasko commented Feb 27, 2025

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 27, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 27, 2025
Remove incorrect use of nocapture attribute

When using indirect pass mode, a callee can obtain an address of an
argument and capture it. The nocapture attribute promises this does not
happen and so it cannot be added unconditionally.
@bors
Copy link
Contributor

bors commented Feb 27, 2025

⌛ Trying commit 43b0a27 with merge 4edc0f4...

@bors
Copy link
Contributor

bors commented Feb 27, 2025

☀️ Try build successful - checks-actions
Build commit: 4edc0f4 (4edc0f4ac10507c5d091002ff1250b256646f06b)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (4edc0f4): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

This is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.

mean range count
Regressions ❌
(primary)
0.4% [0.2%, 0.6%] 20
Regressions ❌
(secondary)
0.6% [0.1%, 1.5%] 49
Improvements ✅
(primary)
-9.2% [-27.0%, -0.2%] 3
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.9% [-27.0%, 0.6%] 23

Max RSS (memory usage)

Results (secondary 4.9%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
4.9% [4.9%, 4.9%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Cycles

Results (primary 0.8%, secondary 6.7%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
1.9% [0.8%, 4.7%] 26
Regressions ❌
(secondary)
6.7% [2.4%, 15.8%] 24
Improvements ✅
(primary)
-28.6% [-28.6%, -28.6%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.8% [-28.6%, 4.7%] 27

Binary size

Results (primary 0.0%, secondary 0.1%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.1% [0.0%, 0.1%] 13
Regressions ❌
(secondary)
0.1% [0.1%, 0.2%] 37
Improvements ✅
(primary)
-0.1% [-0.2%, -0.0%] 6
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.0% [-0.2%, 0.1%] 19

Bootstrap: 770.531s -> 772.441s (0.25%)
Artifact size: 361.97 MiB -> 362.10 MiB (0.04%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Feb 27, 2025
@petrochenkov
Copy link
Contributor

r? @nikic

@rustbot rustbot assigned nikic and unassigned petrochenkov Feb 27, 2025
When using an indirect pass mode, a callee can obtain an address of an
argument and capture it. The nocapture attribute promises this does not
happen and so cannot be used unconditionally.
@tmiasko
Copy link
Contributor Author

tmiasko commented Mar 10, 2025

I looked into deducing argument attributes based on optimized MIR. While in built MIR those attributes are easy to infer, those opportunities disappear after move propagation optimizations (CopyProp and GVN + copy to move promotion
in DSE). I don't think we can recover performance that way.

LLVM 21 introduces fine grained captures attribute that will allow us to describe that provenance of those pointers is not captured, even though their address might be.

Should we land this now or wait for LLVM 21? What do you think @nikic?

@nikic
Copy link
Contributor

nikic commented Mar 10, 2025

I don't think there's a particular need to fix this quickly, and there are some significant check build regressions, so I'd probably wait for LLVM 21 and see if it will have less impact there.

@tmiasko tmiasko closed this Mar 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
perf-regression Performance regression. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LLVM nocapture attribute is used incorrectly
7 participants