From 058ff728dc2a16b44c8abad2581287743c828270 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 27 Feb 2020 10:00:40 +0100 Subject: [PATCH 1/4] debug-assert ptr sanity in ptr::write --- src/libcore/ptr/mod.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/libcore/ptr/mod.rs b/src/libcore/ptr/mod.rs index 72c46f58fcc..4913cd73a2a 100644 --- a/src/libcore/ptr/mod.rs +++ b/src/libcore/ptr/mod.rs @@ -810,9 +810,7 @@ pub unsafe fn read_unaligned(src: *const T) -> T { #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub unsafe fn write(dst: *mut T, src: T) { - // FIXME: the debug assertion here causes codegen test failures on some architectures. - // See . - // debug_assert!(is_aligned_and_not_null(dst), "attempt to write to unaligned or null pointer"); + debug_assert!(is_aligned_and_not_null(dst), "attempt to write to unaligned or null pointer"); intrinsics::move_val_init(&mut *dst, src) } From 59350e4ae25ce9b82ca8b088a63b58c32e22449c Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 17 Feb 2020 21:43:51 +0100 Subject: [PATCH 2/4] increase slack for stack size test --- src/test/ui/issues/issue-40883.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/ui/issues/issue-40883.rs b/src/test/ui/issues/issue-40883.rs index 37e61b1b0e6..5a51acc73e8 100644 --- a/src/test/ui/issues/issue-40883.rs +++ b/src/test/ui/issues/issue-40883.rs @@ -78,8 +78,8 @@ fn verify_stack_usage(before_ptr: *mut Vec) { let stack_usage = isize::abs( (&mut stack_var as *mut _ as isize) - (before_ptr as isize)) as usize; - // give space for 2 copies of `Big` + 128 "misc" bytes. - if stack_usage > mem::size_of::() * 2 + 128 { + // give space for 2 copies of `Big` + 256 "misc" bytes. + if stack_usage > mem::size_of::() * 2 + 256 { panic!("used {} bytes of stack, but `struct Big` is only {} bytes", stack_usage, mem::size_of::()); } From 139a8c34bc40d3d30c31ffb4c0908b3511237ee7 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 12 Mar 2020 19:44:52 +0100 Subject: [PATCH 3/4] fix a codegen test --- src/test/codegen/repeat-trusted-len.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/test/codegen/repeat-trusted-len.rs b/src/test/codegen/repeat-trusted-len.rs index 8fbe712065b..8e08b78ad1e 100644 --- a/src/test/codegen/repeat-trusted-len.rs +++ b/src/test/codegen/repeat-trusted-len.rs @@ -5,14 +5,9 @@ use std::iter; -// CHECK: @helper([[USIZE:i[0-9]+]] %_1) -#[no_mangle] -pub fn helper(_: usize) { -} - // CHECK-LABEL: @repeat_take_collect #[no_mangle] pub fn repeat_take_collect() -> Vec { -// CHECK: call void @llvm.memset.p0i8.[[USIZE]](i8* {{(nonnull )?}}align 1{{.*}} %{{[0-9]+}}, i8 42, [[USIZE]] 100000, i1 false) +// CHECK: call void @llvm.memset.p0i8.i{{[0-9]+}}(i8* {{(nonnull )?}}align 1{{.*}} %{{[0-9]+}}, i8 42, i{{[0-9]+}} 100000, i1 false) iter::repeat(42).take(100000).collect() } From c95f08affac33aa86c9c39110e7d717d2a5e3d33 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 18 Mar 2020 13:35:46 +0100 Subject: [PATCH 4/4] increase stack slack for x86_64-pc-windows-gnu --- src/test/ui/issues/issue-40883.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/test/ui/issues/issue-40883.rs b/src/test/ui/issues/issue-40883.rs index 5a51acc73e8..8a4aef46dd5 100644 --- a/src/test/ui/issues/issue-40883.rs +++ b/src/test/ui/issues/issue-40883.rs @@ -71,15 +71,16 @@ pub fn supersize_me(out: &mut Vec) { #[inline(never)] fn verify_stack_usage(before_ptr: *mut Vec) { - // to check stack usage, create locals before and after + // To check stack usage, create locals before and after // and check the difference in addresses between them. let mut stack_var: Vec = vec![]; test::black_box(&mut stack_var); let stack_usage = isize::abs( (&mut stack_var as *mut _ as isize) - (before_ptr as isize)) as usize; - // give space for 2 copies of `Big` + 256 "misc" bytes. - if stack_usage > mem::size_of::() * 2 + 256 { + // Give space for 2 copies of `Big` + 272 "misc" bytes + // (value observed on x86_64-pc-windows-gnu). + if stack_usage > mem::size_of::() * 2 + 272 { panic!("used {} bytes of stack, but `struct Big` is only {} bytes", stack_usage, mem::size_of::()); }