-
Notifications
You must be signed in to change notification settings - Fork 13.3k
ScalarPairs are offset==0 field + other non-zst field #51307
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
src/librustc_mir/interpret/place.rs
Outdated
@@ -137,7 +137,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { | |||
Value::Scalar(_) if offset.bytes() == 0 && field.size == base_layout.size => Ok(Some((base, field.ty))), | |||
// split fat pointers, 2 element tuples, ... | |||
Value::ScalarPair(a, b) if base_layout.fields.count() == 2 => { | |||
let val = [a, b][field_index]; | |||
let val = [a, b][base_layout.fields.memory_index(field_index)]; |
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 still not a good idea (if you want to see what happens, try adding a bunch of ZSTs) - what you want is to check whether offset.bytes() == 0
or not. I could've sworn I already wrote the code in this module to do it correctly, are there several similar pieces of code in here?
if let Value::ScalarPair(_, value) = other { | ||
write_next(value)?; | ||
if let Value::ScalarPair(a, b) = other { | ||
write_next([a, b][layout.fields.memory_index(1)])?; |
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.
Same here.
@@ -221,7 +221,7 @@ impl<'b, 'a, 'tcx:'b> ConstPropagator<'b, 'a, 'tcx> { | |||
trace!("layout computed"); | |||
use rustc_data_structures::indexed_vec::Idx; | |||
let field_index = field.index(); | |||
let val = [a, b][field_index]; | |||
let val = [a, b][base_layout.fields.memory_index(field_index)]; |
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.
Same here.
Value::Scalar(_) => bug!("Scalar does not cover entire type"), | ||
}; | ||
let dest = | ||
self.eval_place(&mir::Place::Local(arg_local))?; |
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 not do something like this for the source, too?
_ => None, | ||
} | ||
let (value, field_ty) = self.use_ecx(span, |this| { | ||
this.ecx.read_field(base, None, field, 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.
Like this, maybe?
src/librustc_mir/interpret/place.rs
Outdated
@@ -136,8 +136,8 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { | |||
Value::ScalarPair(..) | | |||
Value::Scalar(_) if offset.bytes() == 0 && field.size == base_layout.size => Ok(Some((base, field.ty))), | |||
// split fat pointers, 2 element tuples, ... |
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 comment is too specific.
@bors r+ |
📌 Commit f7eedfa has been approved by |
⌛ Testing commit f7eedfa with merge 4baf141bf291b89ec611558c28ea995733055246... |
💔 Test failed - status-travis |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
1 similar comment
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
all builders took less than 2h except for the dist builder, which timed out after 3h 😕 |
@bors retry |
☀️ Test successful - status-appveyor, status-travis |
r? @eddyb
fixes #51300