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

Describe lifetime of call argument temporaries passed indirectly #138489

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tmiasko
Copy link
Contributor

@tmiasko tmiasko commented Mar 14, 2025

Fixes #132014.

@rustbot
Copy link
Collaborator

rustbot commented Mar 14, 2025

r? @oli-obk

rustbot has assigned @oli-obk.
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 Mar 14, 2025
@rustbot
Copy link
Collaborator

rustbot commented Mar 14, 2025

Some changes occurred in compiler/rustc_codegen_ssa

cc @WaffleLapkin

@tmiasko tmiasko force-pushed the call-tmps-lifetime branch from 5e8a92c to dad5f19 Compare March 14, 2025 11:25
@tmiasko tmiasko force-pushed the call-tmps-lifetime branch from dad5f19 to 653bbb9 Compare March 22, 2025 21:23
@tmiasko
Copy link
Contributor Author

tmiasko commented Mar 22, 2025

r? codegen

@rustbot rustbot assigned workingjubilee and unassigned oli-obk Mar 22, 2025
@@ -1049,7 +1049,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
(args, None)
};

let mut copied_constant_arguments = vec![];
// Keeps track of temporary allocas whose liftime need to be ended after the call.
Copy link
Member

@workingjubilee workingjubilee Mar 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo, also slightly confusing wording to me, and often comments like this are written in the imperative, so perhaps this could be more like

Suggested change
// Keeps track of temporary allocas whose liftime need to be ended after the call.
// Keep track of temporary allocas with lifetimes that end after this call

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exact phrasing isn't too important tho' and I don't necessarily insist on the imperative, please feel free to revise as you see fit.

@@ -1049,7 +1049,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
(args, None)
};

let mut copied_constant_arguments = vec![];
// Keeps track of temporary allocas whose liftime need to be ended after the call.
let mut lifetime_ends_after_call: Vec<(Bx::Value, Size)> = Vec::new();
Copy link
Member

@workingjubilee workingjubilee Mar 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also comments should generally prefer to include "why": probably this?

Suggested change
let mut lifetime_ends_after_call: Vec<(Bx::Value, Size)> = Vec::new();
// because we want to later emit things like `@llvm.lifetime.end` for them.
let mut lifetime_ends_after_call: Vec<(Bx::Value, Size)> = Vec::new();

Comment on lines -1052 to +1053
let mut copied_constant_arguments = vec![];
// Keeps track of temporary allocas whose liftime need to be ended after the call.
let mut lifetime_ends_after_call: Vec<(Bx::Value, Size)> = Vec::new();
Copy link
Member

@workingjubilee workingjubilee Mar 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also one thing we kinda lose here with this rename is that most of the entities in this list are arguments or owned by the effective arguments: that's why we accumulate them through codegen_argument calls, then actually handle emitting llvm.lifetime.end intrinsics and the like in do_call. Without this explicitly being called out in the identifier's name, you have to then go read another few hundred lines of code to extract that. We could probably spare a line of commentary here on that subject.

@workingjubilee
Copy link
Member

I wonder
@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 Mar 24, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 24, 2025
Describe lifetime of call argument temporaries passed indirectly

Fixes rust-lang#132014.
@bors
Copy link
Collaborator

bors commented Mar 24, 2025

⌛ Trying commit 653bbb9 with merge 9f0b7ad...

@bors
Copy link
Collaborator

bors commented Mar 24, 2025

☀️ Try build successful - checks-actions
Build commit: 9f0b7ad (9f0b7ad5494592153b6b7b686a00930bd3b8cf6d)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (9f0b7ad): comparison URL.

Overall result: no relevant changes - no action needed

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.

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

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

This benchmark run did not return any relevant results for this metric.

Cycles

Results (primary 1.8%)

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.8% [1.8%, 1.8%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.8% [1.8%, 1.8%] 1

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: missing data
Artifact size: 365.54 MiB -> 365.55 MiB (0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 24, 2025
@workingjubilee
Copy link
Member

Cool. I was just checking for regressions in other cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

Unmerged stack slots under Windows
6 participants