-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
x64: Ensure that constants are always 16 bytes for XmmMem #4790
x64: Ensure that constants are always 16 bytes for XmmMem #4790
Conversation
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.
Thanks!
@@ -0,0 +1,17 @@ | |||
test run | |||
set enable_llvm_abi_extensions | |||
target x86_64 |
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 just run this on all architectures as well as the interpreter? The bug was x64-specific but the test should work everywhere and it would be nice to know if it didn't.
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.
As a further suggestion, we can also remove the set enable_llvm_abi_extensions
since we no longer have i128
's in this new minimized test case.
Subscribe to Label Action
This issue or pull request has been labeled: "cranelift", "cranelift:area:machinst", "cranelift:area:x64", "isle"
Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
@@ -806,7 +806,7 @@ macro_rules! isle_prelude_methods { | |||
|
|||
#[inline] | |||
fn emit_u128_le_const(&mut self, value: u128) -> VCodeConstant { | |||
let data = VCodeConstantData::Generated(value.to_le_bytes().iter().cloned().collect()); | |||
let data = VCodeConstantData::Generated(value.to_le_bytes().iter().copied().collect()); |
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, after Chris' suggestion, now you can simplify this to value.to_le_bytes().into()
, I think.
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 ConstantData
doesn't have a From
implementation for arrays, but .as_slice().into()
ought to work at least.
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 like we're stuck with my verbose monstrosity:
809 | let data = VCodeConstantData::Generated(value.to_le_bytes().iter().into());
| ^^^^ the trait `From<core::slice::Iter<'_, u8>>` is not implemented for `ConstantData`
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.
The problem there is the .iter()
.
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.
Yeah, I get a similar error without it. I had been experimenting :)
809 | let data = VCodeConstantData::Generated(value.to_le_bytes().into());
| ^^^^ the trait `From<[u8; 16]>` is not implemented for `ConstantData`
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'd figured out that just .into()
wouldn't work after I posted my first comment. Did you try my second suggestion, of .as_slice().into()
?
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.
Ah! Totally missed your second comment, that works 👍
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.
Hooray! It'd probably be nice if ConstantData
actually had a From<[T; n]>
implementation too, but I didn't want to suggest doing that in this PR. 😅
Ensure that constants generated for the memory case of XmmMem values are always 16 bytes, ensuring that we don't accidantally perform an unaligned load.
Fixes #4761