-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Introduce NullOp::AlignOf #88839
Introduce NullOp::AlignOf #88839
Conversation
Some changes occured to rustc_codegen_cranelift cc @bjorn3 Some changes occurred in src/tools/clippy. cc @rust-lang/clippy |
r? @nagisa (rust-highfive has picked a reviewer for you, use r? to override) |
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit 52124553f7fb8a336b36f0de95aab8ea74f9d18b with merge 80cc2c0293bdf08aa9c0fd853e7507ce1a0272ba... |
☀️ Try build successful - checks-actions |
Queued 80cc2c0293bdf08aa9c0fd853e7507ce1a0272ba with parent 4e880f8, future comparison URL. |
Finished benchmarking commit (80cc2c0293bdf08aa9c0fd853e7507ce1a0272ba): comparison url. Summary: This benchmark run did not return any relevant changes. 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 |
6ef80f9
to
14e0cef
Compare
@@ -2278,6 +2278,8 @@ impl BinOp { | |||
pub enum NullOp { | |||
/// Returns the size of a value of that type | |||
SizeOf, | |||
/// Returns the minimum alignment of a type | |||
AlignOf, |
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.
Maybe call this MinAlignOf
to distinguish it from the preferred alignment?
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.
Given that preferred alignment is never used in the library and hardly used in the compiler (in fact the only usage of preferred alignment is in cg_clif), and the name we expose min_align_of
to the user is align_of
, I think the name align_of/AlignOf
is not ambiguous. I doubt if we'll ever add a PrefAlignOf
nullary operator.
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.
Huh, indeed. Should we remove preferred alignment then if it isn't used anyway?
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.
Should we remove preferred alignment then if it isn't used anyway?
Yeah it might be time to remove that intrinsic... @eddyb or do you think that will ever be useful again in the future?
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.
Broadly LGTM, r=me with exhaustive matches back.
@@ -270,18 +270,23 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { | |||
M::box_alloc(self, &dest)?; | |||
} | |||
|
|||
NullaryOp(mir::NullOp::SizeOf, ty) => { | |||
NullaryOp(null_op, ty) => { |
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.
Please match mir::NullOp::SizeOf | mir::NullOp::AlignOf
here. so that the match remains properly exhaustive and will catch additional NullOp
additions in the future.
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.
How about change the _ arm below matching null_op to a NullOp::Box arm instead? This way we still get exhaustive match and is IMO cleaner.
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.
I don't have a strong opinion either way.
@@ -525,6 +511,27 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { | |||
let operand = OperandRef { val: OperandValue::Immediate(val), layout: box_layout }; | |||
(bx, operand) | |||
} | |||
|
|||
mir::Rvalue::NullaryOp(null_op, ty) => { |
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.
mir::Rvalue::NullaryOp(null_op, ty) => { | |
mir::Rvalue::NullaryOp(null_op@mir::NullOp::SizeOf | null_op@mir::NullOp::AlignOf, ty) => { |
@@ -726,15 +726,20 @@ fn codegen_stmt<'tcx>( | |||
let ptr = fx.bcx.inst_results(call)[0]; | |||
lval.write_cvalue(fx, CValue::by_val(ptr, box_layout)); | |||
} | |||
Rvalue::NullaryOp(NullOp::SizeOf, ty) => { | |||
Rvalue::NullaryOp(null_op, ty) => { |
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.
Rvalue::NullaryOp(null_op, ty) => { | |
Rvalue::NullaryOp(null_op@NullOp::SizeOf | null_op@NullOp::AlignOf, ty) => { |
@bors r+ |
📌 Commit cdec87c has been approved by |
☀️ Test successful - checks-actions |
Finished benchmarking commit (96dee28): comparison url. Summary: This benchmark run did not return any relevant changes. If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: -perf-regression |
Remove implementation of `min_align_of` intrinsic Since rust-lang#88839 `min_align_of` is lowered to AlignOf operator.
Remove implementation of `min_align_of` intrinsic Since rust-lang#88839 `min_align_of` is lowered to AlignOf operator.
Remove implementation of `min_align_of` intrinsic Since rust-lang#88839 `min_align_of` is lowered to AlignOf operator.
Remove implementation of `min_align_of` intrinsic Since rust-lang#88839 `min_align_of` is lowered to AlignOf operator.
Remove implementation of `min_align_of` intrinsic Since rust-lang#88839 `min_align_of` is lowered to AlignOf operator.
Remove implementation of `min_align_of` intrinsic Since rust-lang#88839 `min_align_of` is lowered to AlignOf operator.
Introduce NullOp::AlignOf This PR introduces `Rvalue::NullaryOp(NullOp::AlignOf, ty)`, which will be lowered from `align_of`, similar to `size_of` lowering to `Rvalue::NullaryOp(NullOp::SizeOf, ty)`. The changes are originally part of rust-lang#88700 but since it's not dependent on other changes and could have performance impact on its own, it's separated into its own PR.
Introduce NullOp::AlignOf This PR introduces `Rvalue::NullaryOp(NullOp::AlignOf, ty)`, which will be lowered from `align_of`, similar to `size_of` lowering to `Rvalue::NullaryOp(NullOp::SizeOf, ty)`. The changes are originally part of rust-lang#88700 but since it's not dependent on other changes and could have performance impact on its own, it's separated into its own PR.
This PR introduces
Rvalue::NullaryOp(NullOp::AlignOf, ty)
, which will be lowered fromalign_of
, similar tosize_of
lowering toRvalue::NullaryOp(NullOp::SizeOf, ty)
.The changes are originally part of #88700 but since it's not dependent on other changes and could have performance impact on its own, it's separated into its own PR.