-
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
Remove ConstValue::Slice
#105653
Remove ConstValue::Slice
#105653
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @RalfJung (or someone else) soon. Please see the contribution instructions for more information. |
Some changes occurred to the CTFE / Miri engine cc @rust-lang/miri Some changes occurred in src/tools/clippy cc @rust-lang/clippy Some changes occurred to the CTFE / Miri engine cc @rust-lang/miri Some changes occurred in compiler/rustc_codegen_cranelift cc @bjorn3 |
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit d9b98ef0f3dd6dc20cf835a154c5bf3bee839767 with merge 45be547054cbb06ab494b34fe16bb68a559385b2... |
Immediate::ScalarPair(a, b) => ConstValue::ByRef { | ||
alloc: ecx.tcx.intern_const_alloc( |
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 is silly, we start with an MPlace, then get the immediate, and then intern again?
We should just make sure that try_as_immediate
is false
for ScalarPair
, then this match arm here is unreachable.
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.
we... don't always start with an MPlace. I tried this originally.
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.
Oh wait no there are more hacks here than I remember. Just saw this comment
// It is guaranteed that any non-slice scalar pair is actually ByRef here.
// When we come back from raw const eval, we are always by-ref. The only way our op here is
// by-val is if we are in destructure_mir_constant, i.e., if this is (a field of) something that we
// "tried to make immediate" before. We wouldn't do that for non-slice scalar pairs or
// structs containing such.
But, still, the ScalarPair arm should then be unreachable, right?
How far away are we from being able to remove destructure_mir_constant entirely, porting all its users to valtrees?
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 guess this shows that we have an impedence mismatch if Immediate
can contain ScalarPair
but we still need to be able to convert arbitrary OpTy
into ConstValue
. But it's still a plus if we can do the ScalarPair/Slice handling once centrally in op_to_const
rather than each codegen backend having to do this.
FWIW to fix #105536 it would probably be enough to change only try_as_immediate
... then maybe the former intern_const_alloc
arm here becomes unreachable?
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.
we... don't always start with an MPlace. I tried this originally.
Ah, I think ConstProp will also go through this and it can produce pairs. I hope the new ConstProp will use valtrees instead...
Something is odd with ByRef const printing: the ByRef points to an allocation that contains a wide reference, which does not get printed. That allocation however contains a pointer to the actual string data, and that gets printed. |
yea, this is because the |
@rust-timer build 45be547054cbb06ab494b34fe16bb68a559385b2 |
This comment has been minimized.
This comment has been minimized.
That's a bug though (and doesn't seem to be fixed by the last commit) -- from the current rendering it is impossible to tell which constant in the source refers to which of the allocations at the bottom. |
it's preexisting. I'm not fixing everything that's wrong about constants in this PR, just one "small" thing 😆 |
that's only relevant for when the source above actually mentions alloc ids. It's a bit too much info printed at the bottom now, I can filter that out if you want |
Hm, fair. Can you open an issue to track this? |
Yeah, if we don't show the allocID there's little point in printing the corresponding allocation. |
Finished benchmarking commit (45be547054cbb06ab494b34fe16bb68a559385b2): comparison URL. Overall result: ❌ regressions - ACTION NEEDEDBenchmarking 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 @bors rollup=never Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis 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.
CyclesResultsThis 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.
|
paired with #111768 the LLVM regressions go away entirely. There is still a major regression in the We could explore using some |
These are small allocations for string literals in the source, I assume? Can those generate a valtree instead of an |
yea, that's the plan, getting rid of |
Optimize scalar and scalar pair representations loaded from ByRef in llvm in rust-lang#105653 I noticed that we were generating suboptimal LLVM IR if we had a `ConstValue::ByRef` that could be represented by a `ScalarPair`. Before rust-lang#105653 this is probably rare, but after it, every slice will go down this suboptimal code path that requires LLVM to untangle a bunch of indirections and translate static allocations that are only used once to read a scalar pair from.
Optimize scalar and scalar pair representations loaded from ByRef in llvm in rust-lang/rust#105653 I noticed that we were generating suboptimal LLVM IR if we had a `ConstValue::ByRef` that could be represented by a `ScalarPair`. Before rust-lang/rust#105653 this is probably rare, but after it, every slice will go down this suboptimal code path that requires LLVM to untangle a bunch of indirections and translate static allocations that are only used once to read a scalar pair from.
Optimize scalar and scalar pair representations loaded from ByRef in llvm in rust-lang/rust#105653 I noticed that we were generating suboptimal LLVM IR if we had a `ConstValue::ByRef` that could be represented by a `ScalarPair`. Before rust-lang/rust#105653 this is probably rare, but after it, every slice will go down this suboptimal code path that requires LLVM to untangle a bunch of indirections and translate static allocations that are only used once to read a scalar pair from.
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit 246d190 with merge d870714f42cfdb6491316e5c358010b2268d6e93... |
☀️ Try build successful - checks-actions |
1 similar comment
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (d870714f42cfdb6491316e5c358010b2268d6e93): comparison URL. Overall result: ❌ regressions - ACTION NEEDEDBenchmarking 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 @bors rollup=never Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis 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.
CyclesResultsThis 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.
Binary sizeResultsThis 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.
Bootstrap: 658.605s -> 656.253s (-0.36%) |
The coercions regression is almost entirely due to the allocation and deallocation of allocations for slice constants:
Maybe removing this for mir constants isn't actually the right way forward. We could start mirroring LLVM and have a full on |
Hm, I'm trying to understand/remember what this is actually all about. What is So is this about slice literals that appear in the source, and having an efficient representation for those? That should be valtrees though? |
closing in favor of #115764 preserving the AllocId |
Optimize scalar and scalar pair representations loaded from ByRef in llvm in rust-lang/rust#105653 I noticed that we were generating suboptimal LLVM IR if we had a `ConstValue::ByRef` that could be represented by a `ScalarPair`. Before rust-lang/rust#105653 this is probably rare, but after it, every slice will go down this suboptimal code path that requires LLVM to untangle a bunch of indirections and translate static allocations that are only used once to read a scalar pair from.
Optimize scalar and scalar pair representations loaded from ByRef in llvm in rust-lang/rust#105653 I noticed that we were generating suboptimal LLVM IR if we had a `ConstValue::ByRef` that could be represented by a `ScalarPair`. Before rust-lang/rust#105653 this is probably rare, but after it, every slice will go down this suboptimal code path that requires LLVM to untangle a bunch of indirections and translate static allocations that are only used once to read a scalar pair from.
r? @RalfJung
fixes #105536
This only removes
Slice
, we can doZST
andScalar
individually to judge their performance effect