-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Set dead_on_return attribute for indirect arguments #145093
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
base: master
Are you sure you want to change the base?
Conversation
r? @nnethercote rustbot has assigned @nnethercote. Use |
I don't really expect this to have any appreciate impact in practice, but let's check... @bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Set dead_on_return attribute for indirect arguments
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (7642ceb): comparison URL. Overall result: no relevant changes - 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 countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)Results (secondary 2.6%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary 2.9%)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: 465.538s -> 465.32s (-0.05%) |
tests/codegen-llvm/dead_on_return.rs
Outdated
pub fn test(mut s: String) { | ||
// CHECK-LABEL: @test | ||
// CHECK: __rust_dealloc | ||
// CHECK-NOT: store | ||
s = String::new(); | ||
} |
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.
This test passing indicates that this fixes (part of) #96497, specifically #96497 (comment)
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.
Ah yes, I wasn't aware we had an issue for this.
r=me. The only question is does this fix all of #96497, or just the comment that @erikdesjardins linked to? |
Set the dead_on_return attribute (added in LLVM 21) for arguments that are passed indirectly, but not byval. This indicates that the value of the argument on return does not matter, enabling additional dead store elimination.
I've added two more cases from the issue as tests. One case that's not fixed is the Vec::fill one (https://rust.godbolt.org/z/zPj3nrfbh). So I've adjusted the PR description to not close the issue yet. |
Great, thank you. r=me, merge when you are ready. |
@bors r=nnethercote |
Set dead_on_return attribute for indirect arguments Set the dead_on_return attribute (added in LLVM 21) for arguments that are passed indirectly, but not byval. This indicates that the value of the argument on return does not matter, enabling additional dead store elimination. From LangRef: > This attribute indicates that the memory pointed to by the argument is dead upon function return, both upon normal return and if the calls unwinds, meaning that the caller will not depend on its contents. Stores that would be observable either on the return path or on the unwind path may be elided. > > Specifically, the behavior is as-if any memory written through the pointer during the execution of the function is overwritten with a poison value upon function return. The caller may access the memory, but any load not preceded by a store will return poison. > > This attribute does not imply aliasing properties. For pointer arguments that do not alias other memory locations, noalias attribute may be used in conjunction. Conversely, this attribute always implies dead_on_unwind. > > This attribute cannot be applied to return values. This fixes parts of #96497.
The job Click to see the possible cause of the failure (guessed by this bot)
|
💔 Test failed - checks-actions |
@bors retry Not super clear what actually failed there, but it looks spurious. |
Set dead_on_return attribute for indirect arguments Set the dead_on_return attribute (added in LLVM 21) for arguments that are passed indirectly, but not byval. This indicates that the value of the argument on return does not matter, enabling additional dead store elimination. From LangRef: > This attribute indicates that the memory pointed to by the argument is dead upon function return, both upon normal return and if the calls unwinds, meaning that the caller will not depend on its contents. Stores that would be observable either on the return path or on the unwind path may be elided. > > Specifically, the behavior is as-if any memory written through the pointer during the execution of the function is overwritten with a poison value upon function return. The caller may access the memory, but any load not preceded by a store will return poison. > > This attribute does not imply aliasing properties. For pointer arguments that do not alias other memory locations, noalias attribute may be used in conjunction. Conversely, this attribute always implies dead_on_unwind. > > This attribute cannot be applied to return values. This fixes parts of #96497.
The job Click to see the possible cause of the failure (guessed by this bot)
|
💔 Test failed - checks-actions |
Set the dead_on_return attribute (added in LLVM 21) for arguments that are passed indirectly, but not byval.
This indicates that the value of the argument on return does not matter, enabling additional dead store elimination.
From LangRef:
This fixes parts of #96497.