-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Add LLVM attributes in batches instead of individually #94221
Conversation
This should improve performance.
b9cd8ff
to
30d3ce0
Compare
This comment has been minimized.
This comment has been minimized.
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit 30d3ce0 with merge 39292fbc75cdc462390b8b3c63d59cb5a6b00539... |
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.
Looks great. As the CI failure indicates, AttributeMask is new in LLVM 14, previously AttrBuilder was used.
fn get_attrs<'ll>( | ||
this: &ArgAttributes, | ||
cx: &CodegenCx<'ll, '_>, | ||
) -> SmallVec<impl smallvec::Array<Item = &'ll Attribute>> { |
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.
First time I'm seeing this SmallVec pattern.
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 avoids exposing the size in the signature. But it looks like we aren't concerned about that elsewhere, and it is compiler-internal anyways, so removed this
} | ||
attributes::apply_to_llfn(llfn, llvm::AttributePlace::Function, &{ func_attrs }); |
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.
Why does this need braces?
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.
Not necessary, but causes the SmallVec to be moved, which makes func_attrs.push()
after this point an error.
☀️ Try build successful - checks-actions |
Queued 39292fbc75cdc462390b8b3c63d59cb5a6b00539 with parent 6f681a8, future comparison URL. |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (39292fbc75cdc462390b8b3c63d59cb5a6b00539): comparison url. Summary: This benchmark run did not return any relevant results. 7 results were found to be statistically significant but too small to be relevant. If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. 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 led to changes in compiler perf. @bors rollup=never |
Doesn't seem to do much for performance, but I think this still makes sense in terms of general design, by separating attribute creation and addition. For example, this allows reusing the same code when applying function and callsite attributes. @bors r+ |
📌 Commit 0d0cc4f has been approved by |
☀️ Test successful - checks-actions |
Finished benchmarking commit (2bd9656): comparison url. Summary: This benchmark run did not return any relevant results. 19 results were found to be statistically significant but too small to be relevant. If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: -perf-regression |
Remove LLVM attribute removal This was necessary before, because `declare_raw_fn` would always apply the default optimization attributes to every declared function. Then `attributes::from_fn_attrs` would have to remove the default attributes in the case of, e.g. `#[optimize(speed)]` in a `-Os` build. (see [`src/test/codegen/optimize-attr-1.rs`](https://github.com/rust-lang/rust/blob/03a8cc7df1d65554a4d40825b0490c93ac0f0236/src/test/codegen/optimize-attr-1.rs#L33)) However, every relevant callsite of `declare_raw_fn` (i.e. where we actually generate code for the function, and not e.g. a call to an intrinsic, where optimization attributes don't [?] matter) calls `from_fn_attrs`, so we can remove the attribute setting from `declare_raw_fn`, and rely on `from_fn_attrs` to apply the correct attributes all at once. r? `@ghost` (blocked on rust-lang#94221) `@rustbot` label S-blocked
This should improve performance.
r? @ghost (blocked on #94127)