-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Change Thir to lazily create constants #94876
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
Conversation
This comment has been minimized.
This comment has been minimized.
73a22ab
to
9e73a91
Compare
@@ -70,7 +70,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { | |||
local_decl.local_info = | |||
Some(Box::new(LocalInfo::StaticRef { def_id, is_thread_local: true })); | |||
} | |||
ExprKind::Literal { const_id: Some(def_id), .. } => { | |||
ExprKind::NamedConst { def_id, .. } => { |
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 might be problematic. I'm not completely sure whether we need any other variants here. Also don't know what adding constants to local_info here does later in codegen.
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 previously also did this for ExprKind::ConstParam
, would have to figure out what it's used for myself 😆 think you can just keep the current behavior and add a FIXME for now
ExprKind::NamedConst { def_id, .. } => { | |
ExprKind::NamedConst { def_id, .. } | ExprKind::ConstParam { def_id, .. } => { |
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 also want this for ExprKind::ConstParam
: please add this as a test:
#![feature(adt_const_params)]
#![allow(incomplete_features)]
#[derive(PartialEq, Eq)]
struct Yikes;
impl Yikes {
fn mut_self(&mut self) {}
}
fn foo<const YIKES: Yikes>() {
YIKES.mut_self()
}
fn main() {
foo::<{ Yikes }>()
}
This comment has been minimized.
This comment has been minimized.
a2ef0d4
to
f7ff7aa
Compare
f7ff7aa
to
1f24795
Compare
This is ready for review now. Shouldn't be reviewed commit by commit probably. |
I guess squash the commits in that case? |
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.
a few nits
@@ -70,7 +70,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { | |||
local_decl.local_info = | |||
Some(Box::new(LocalInfo::StaticRef { def_id, is_thread_local: true })); | |||
} | |||
ExprKind::Literal { const_id: Some(def_id), .. } => { | |||
ExprKind::NamedConst { def_id, .. } => { |
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 previously also did this for ExprKind::ConstParam
, would have to figure out what it's used for myself 😆 think you can just keep the current behavior and add a FIXME for now
ExprKind::NamedConst { def_id, .. } => { | |
ExprKind::NamedConst { def_id, .. } | ExprKind::ConstParam { def_id, .. } => { |
e13f6b6
to
07f5641
Compare
Decided to keep the |
This comment has been minimized.
This comment has been minimized.
e2e84c3
to
c962c81
Compare
This comment has been minimized.
This comment has been minimized.
c962c81
to
8e21280
Compare
This comment has been minimized.
This comment has been minimized.
c98ec1a
to
b3d71d3
Compare
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.
Alright, am pretty happy with this PR now.
I do dislike ScalarLiteral
, it feels like a pretty bad name 🤔 can't think of a better name myself, so please take 1-2 min to think of one and if not we can merge it as is 😆
@@ -70,7 +70,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { | |||
local_decl.local_info = | |||
Some(Box::new(LocalInfo::StaticRef { def_id, is_thread_local: true })); | |||
} | |||
ExprKind::Literal { const_id: Some(def_id), .. } => { | |||
ExprKind::NamedConst { def_id, .. } => { |
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 also want this for ExprKind::ConstParam
: please add this as a test:
#![feature(adt_const_params)]
#![allow(incomplete_features)]
#[derive(PartialEq, Eq)]
struct Yikes;
impl Yikes {
fn mut_self(&mut self) {}
}
fn foo<const YIKES: Yikes>() {
YIKES.mut_self()
}
fn main() {
foo::<{ Yikes }>()
}
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
interesting 🤔 I would be surprised if these changes mattered, even if keeping them would probably have been preferable. let's try it again, maybe it was spurious in some way? @bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit 96050421395ae1c3a75dc0a883e0d9317f918195 with merge 7827037e4b0cf03a1f99c331fa9ef74dd062fbea... |
☀️ Try build successful - checks-actions |
Queued 7827037e4b0cf03a1f99c331fa9ef74dd062fbea with parent cd2da4d, future comparison URL. |
Finished benchmarking commit (7827037e4b0cf03a1f99c331fa9ef74dd062fbea): comparison url. Summary: This benchmark run shows 11 relevant improvements 🎉 but 5 relevant regressions 😿 to instruction counts.
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. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never |
hm this is very weird. How can it be that the number of calls of a query differ in perf runs? Is this a bug in rustc_perf? (cc @Mark-Simulacrum) |
9605042
to
ccfbe52
Compare
This comment has been minimized.
This comment has been minimized.
ccfbe52
to
19041d9
Compare
@bors r+ rollup=never |
📌 Commit 19041d9 has been approved by |
☀️ Test successful - checks-actions |
☀️ Test successful - checks-actions |
Finished benchmarking commit (8d8135f): comparison url. Summary: This benchmark run shows 32 relevant improvements 🎉 but 13 relevant regressions 😿 to instruction counts.
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression |
Visiting for weekly performance triage. The changes to the primary benchmarks are almost universally green here. The secondary benchmarks are more of a mixed bag, but I think we can accept a 3.5% regression on tuple-stress given the overall benefits. @rustbot label: +perf-regression-triaged |
To allow
AbstractConst
s to work with the previous thir changes we made and those we want to make, i.e. to avoid problems due toValTree
andConstValue
conversions, we instead switch to a thir representation for constants that allows us to lazily create constants.r? @oli-obk