-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Disable alignment checks on i686-pc-windows-msvc #112684
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,10 @@ pub struct CheckAlignment; | |
|
||
impl<'tcx> MirPass<'tcx> for CheckAlignment { | ||
fn is_enabled(&self, sess: &Session) -> bool { | ||
// FIXME(#112480) MSVC and rustc disagree on minimum stack alignment on x86 Windows | ||
if sess.target.llvm_target == "i686-pc-windows-msvc" { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this potentially going to make some of the MIR tests for this fail on i686-msvc? Are there any tests that should get something like a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think just the test for the alignment check itself. The mir-opt tests have debug assertions disabled and I think I was otherwise pretty careful to modify the other tests so that they are not perturbed by them, but that was some time ago. I'd prefer to be able to run the msvc test suite locally but I don't think that's supported on a Linux host?
wesleywiser marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return false; | ||
} | ||
sess.opts.debug_assertions | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// run-pass | ||
// only-i686-pc-windows-msvc | ||
// compile-flags: -Copt-level=0 -Cdebug-assertions=yes | ||
|
||
// MSVC isn't sure if on 32-bit Windows its u64 type is 8-byte-aligned or 4-byte-aligned. | ||
// So this test ensures that on i686-pc-windows-msvc, we do not insert a runtime check | ||
// that will fail on dereferencing of a pointer to u64 which is not 8-byte-aligned but is | ||
// 4-byte-aligned. | ||
|
||
#![feature(strict_provenance)] | ||
|
||
fn main() { | ||
let mut x = [0u64; 2]; | ||
let ptr: *mut u8 = x.as_mut_ptr().cast::<u8>(); | ||
unsafe { | ||
let misaligned = ptr.add(4).cast::<u64>(); | ||
assert!(misaligned.addr() % 8 != 0); | ||
assert!(misaligned.addr() % 4 == 0); | ||
*misaligned = 42; | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.