From ccd1bc2ad1be8516f16d80b8cb6dffd79f5c6c85 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sun, 22 Sep 2024 17:10:44 +0000 Subject: Return values larger than 2 registers using a return area pointer LLVM and Cranelift disagree about how to return values that don't fit in the registers designated for return values. LLVM will force the entire return value to be passed by return area pointer, while Cranelift will look at each IR level return value independently and decide to pass it in a register or not, which would result in the return value being passed partially in registers and partially through a return area pointer. While Cranelift may need to be fixed as the LLVM behavior is generally more correct with respect to the surface language, forcing this behavior in rustc itself makes it easier for other backends to conform to the Rust ABI and for the C ABI rustc already handles this behavior anyway. In addition LLVM's decision to pass the return value in registers or using a return area pointer depends on how exactly the return type is lowered to an LLVM IR type. For example `Option` can be lowered as `{ i128, i128 }` in which case the x86_64 backend would use a return area pointer, or it could be passed as `{ i32, i128 }` in which case the x86_64 backend would pass it in registers by taking advantage of an LLVM ABI extension that allows using 3 registers for the x86_64 sysv call conv rather than the officially specified 2 registers. This adjustment is only necessary for the Rust ABI as for other ABI's the calling convention implementations in rustc_target already ensure any return value which doesn't fit in the available amount of return registers is passed in the right way for the current target. --- tests/codegen/i128-x86-align.rs | 32 ++++++++++++++------------------ tests/codegen/tuple-layout-opt.rs | 8 ++++---- 2 files changed, 18 insertions(+), 22 deletions(-) (limited to 'tests/codegen') diff --git a/tests/codegen/i128-x86-align.rs b/tests/codegen/i128-x86-align.rs index 3e6ed2b8e16..6b1da445c40 100644 --- a/tests/codegen/i128-x86-align.rs +++ b/tests/codegen/i128-x86-align.rs @@ -19,13 +19,15 @@ pub struct ScalarPair { #[no_mangle] pub fn load(x: &ScalarPair) -> ScalarPair { // CHECK-LABEL: @load( + // CHECK-SAME: sret([32 x i8]) align 16 dereferenceable(32) %_0, // CHECK-SAME: align 16 dereferenceable(32) %x // CHECK: [[A:%.*]] = load i32, ptr %x, align 16 // CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds i8, ptr %x, i64 16 // CHECK-NEXT: [[B:%.*]] = load i128, ptr [[GEP]], align 16 - // CHECK-NEXT: [[IV1:%.*]] = insertvalue { i32, i128 } poison, i32 [[A]], 0 - // CHECK-NEXT: [[IV2:%.*]] = insertvalue { i32, i128 } [[IV1]], i128 [[B]], 1 - // CHECK-NEXT: ret { i32, i128 } [[IV2]] + // CHECK-NEXT: store i32 [[A]], ptr %_0, align 16 + // CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds i8, ptr %_0, i64 16 + // CHECK-NEXT: store i128 [[B]], ptr [[GEP]], align 16 + // CHECK-NEXT: ret void *x } @@ -53,29 +55,23 @@ pub fn alloca() { #[no_mangle] pub fn load_volatile(x: &ScalarPair) -> ScalarPair { // CHECK-LABEL: @load_volatile( + // CHECK-SAME: sret([32 x i8]) align 16 dereferenceable(32) %_0, // CHECK-SAME: align 16 dereferenceable(32) %x - // CHECK: [[TMP:%.*]] = alloca [32 x i8], align 16 // CHECK: [[LOAD:%.*]] = load volatile %ScalarPair, ptr %x, align 16 - // CHECK-NEXT: store %ScalarPair [[LOAD]], ptr [[TMP]], align 16 - // CHECK-NEXT: [[A:%.*]] = load i32, ptr [[TMP]], align 16 - // CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds i8, ptr [[TMP]], i64 16 - // CHECK-NEXT: [[B:%.*]] = load i128, ptr [[GEP]], align 16 + // CHECK-NEXT: store %ScalarPair [[LOAD]], ptr %_0, align 16 + // CHECK-NEXT: ret void unsafe { std::intrinsics::volatile_load(x) } } #[no_mangle] pub fn transmute(x: ScalarPair) -> (std::mem::MaybeUninit, i128) { - // CHECK-LABEL: define { i128, i128 } @transmute(i32 noundef %x.0, i128 noundef %x.1) - // CHECK: [[TMP:%.*]] = alloca [32 x i8], align 16 - // CHECK-NEXT: store i32 %x.0, ptr [[TMP]], align 16 - // CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds i8, ptr [[TMP]], i64 16 + // CHECK-LABEL: @transmute( + // CHECK-SAME: sret([32 x i8]) align 16 dereferenceable(32) %_0, + // CHECK-SAME: i32 noundef %x.0, i128 noundef %x.1 + // CHECK: store i32 %x.0, ptr %_0, align 16 + // CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds i8, ptr %_0, i64 16 // CHECK-NEXT: store i128 %x.1, ptr [[GEP]], align 16 - // CHECK-NEXT: [[LOAD1:%.*]] = load i128, ptr %_0, align 16 - // CHECK-NEXT: [[GEP2:%.*]] = getelementptr inbounds i8, ptr [[TMP]], i64 16 - // CHECK-NEXT: [[LOAD2:%.*]] = load i128, ptr [[GEP2]], align 16 - // CHECK-NEXT: [[IV1:%.*]] = insertvalue { i128, i128 } poison, i128 [[LOAD1]], 0 - // CHECK-NEXT: [[IV2:%.*]] = insertvalue { i128, i128 } [[IV1]], i128 [[LOAD2]], 1 - // CHECK-NEXT: ret { i128, i128 } [[IV2]] + // CHECK-NEXT: ret void unsafe { std::mem::transmute(x) } } diff --git a/tests/codegen/tuple-layout-opt.rs b/tests/codegen/tuple-layout-opt.rs index 601563bc061..3202e4749c5 100644 --- a/tests/codegen/tuple-layout-opt.rs +++ b/tests/codegen/tuple-layout-opt.rs @@ -19,28 +19,28 @@ pub fn test_ScalarZstFirst(_: ScalarZstFirst) -> ScalarZstFirst { } type ScalarPairZstLast = (u8, u128, ()); -// CHECK: define {{(dso_local )?}}{ i128, i8 } @test_ScalarPairZstLast(i128 %_1.0, i8 %_1.1) +// CHECK: define {{(dso_local )?}}void @test_ScalarPairZstLast(ptr sret([32 x i8]) align 16 %_0, i128 %_1.0, i8 %_1.1) #[no_mangle] pub fn test_ScalarPairZstLast(_: ScalarPairZstLast) -> ScalarPairZstLast { loop {} } type ScalarPairZstFirst = ((), u8, u128); -// CHECK: define {{(dso_local )?}}{ i8, i128 } @test_ScalarPairZstFirst(i8 %_1.0, i128 %_1.1) +// CHECK: define {{(dso_local )?}}void @test_ScalarPairZstFirst(ptr sret([32 x i8]) align 16 %_0, i8 %_1.0, i128 %_1.1) #[no_mangle] pub fn test_ScalarPairZstFirst(_: ScalarPairZstFirst) -> ScalarPairZstFirst { loop {} } type ScalarPairLotsOfZsts = ((), u8, (), u128, ()); -// CHECK: define {{(dso_local )?}}{ i128, i8 } @test_ScalarPairLotsOfZsts(i128 %_1.0, i8 %_1.1) +// CHECK: define {{(dso_local )?}}void @test_ScalarPairLotsOfZsts(ptr sret([32 x i8]) align 16 %_0, i128 %_1.0, i8 %_1.1) #[no_mangle] pub fn test_ScalarPairLotsOfZsts(_: ScalarPairLotsOfZsts) -> ScalarPairLotsOfZsts { loop {} } type ScalarPairLottaNesting = (((), ((), u8, (), u128, ())), ()); -// CHECK: define {{(dso_local )?}}{ i128, i8 } @test_ScalarPairLottaNesting(i128 %_1.0, i8 %_1.1) +// CHECK: define {{(dso_local )?}}void @test_ScalarPairLottaNesting(ptr sret([32 x i8]) align 16 %_0, i128 %_1.0, i8 %_1.1) #[no_mangle] pub fn test_ScalarPairLottaNesting(_: ScalarPairLottaNesting) -> ScalarPairLottaNesting { loop {} -- cgit 1.4.1-3-g733a5 From 5365b3f7be079008d7cac03b821f7c65563ee5ed Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Fri, 11 Oct 2024 14:41:02 -0700 Subject: Avoid superfluous UB checks in `IndexRange` `IndexRange::len` is justified as an overall invariant, and `take_prefix` and `take_suffix` are justified by local branch conditions. A few more UB-checked calls remain in cases that are only supported locally by `debug_assert!`, which won't do anything in distributed builds, so those UB checks may still be useful. We generally expect core's `#![rustc_preserve_ub_checks]` to optimize away in user's release builds, but the mere presence of that extra code can sometimes inhibit optimization, as seen in #131563. --- library/core/src/ops/index_range.rs | 11 +++++++---- tests/codegen/issues/issue-101082.rs | 5 +++++ 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'tests/codegen') diff --git a/library/core/src/ops/index_range.rs b/library/core/src/ops/index_range.rs index 64214eae377..dce3514a159 100644 --- a/library/core/src/ops/index_range.rs +++ b/library/core/src/ops/index_range.rs @@ -45,7 +45,8 @@ impl IndexRange { #[inline] pub const fn len(&self) -> usize { // SAFETY: By invariant, this cannot wrap - unsafe { self.end.unchecked_sub(self.start) } + // Using the intrinsic because a UB check here impedes LLVM optimization. (#131563) + unsafe { crate::intrinsics::unchecked_sub(self.end, self.start) } } /// # Safety @@ -82,7 +83,8 @@ impl IndexRange { let mid = if n <= self.len() { // SAFETY: We just checked that this will be between start and end, // and thus the addition cannot overflow. - unsafe { self.start.unchecked_add(n) } + // Using the intrinsic avoids a superfluous UB check. + unsafe { crate::intrinsics::unchecked_add(self.start, n) } } else { self.end }; @@ -100,8 +102,9 @@ impl IndexRange { pub fn take_suffix(&mut self, n: usize) -> Self { let mid = if n <= self.len() { // SAFETY: We just checked that this will be between start and end, - // and thus the addition cannot overflow. - unsafe { self.end.unchecked_sub(n) } + // and thus the subtraction cannot overflow. + // Using the intrinsic avoids a superfluous UB check. + unsafe { crate::intrinsics::unchecked_sub(self.end, n) } } else { self.start }; diff --git a/tests/codegen/issues/issue-101082.rs b/tests/codegen/issues/issue-101082.rs index 550d267a98f..4be1b6cb168 100644 --- a/tests/codegen/issues/issue-101082.rs +++ b/tests/codegen/issues/issue-101082.rs @@ -1,4 +1,9 @@ //@ compile-flags: -O +//@ revisions: host x86-64-v3 + +// This particular CPU regressed in #131563 +//@[x86-64-v3] only-x86_64 +//@[x86-64-v3] compile-flags: -Ctarget-cpu=x86-64-v3 #![crate_type = "lib"] -- cgit 1.4.1-3-g733a5 From 8ed77fd29e289a591df16390049a8e94f3c62b04 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sat, 12 Oct 2024 16:17:34 +0000 Subject: Update tests for 32bit targets --- tests/codegen/float/f128.rs | 106 +++++++++++++++++++++++-------- tests/codegen/float/f16.rs | 26 ++++++-- tests/codegen/mir-aggregate-no-alloca.rs | 30 ++++++--- tests/codegen/range-attribute.rs | 11 +++- tests/codegen/tuple-layout-opt.rs | 26 ++++++-- tests/codegen/union-abi.rs | 18 ++++-- 6 files changed, 162 insertions(+), 55 deletions(-) (limited to 'tests/codegen') diff --git a/tests/codegen/float/f128.rs b/tests/codegen/float/f128.rs index 80b572fbbc9..4af264101de 100644 --- a/tests/codegen/float/f128.rs +++ b/tests/codegen/float/f128.rs @@ -1,7 +1,11 @@ // 32-bit x86 returns `f32` and `f64` differently to avoid the x87 stack. -//@ revisions: x86 other +// 32-bit systems will return 128bit values using a return area pointer. +//@ revisions: x86 bit32 bit64 //@[x86] only-x86 -//@[other] ignore-x86 +//@[bit32] ignore-x86 +//@[bit32] only-32bit +//@[bit64] ignore-x86 +//@[bit64] only-64bit // Verify that our intrinsics generate the correct LLVM calls for f128 @@ -52,42 +56,54 @@ pub fn f128_le(a: f128, b: f128) -> bool { a <= b } -// CHECK-LABEL: fp128 @f128_neg( +// x86-LABEL: void @f128_neg({{.*}}sret([16 x i8]) +// bit32-LABEL: void @f128_neg({{.*}}sret([16 x i8]) +// bit64-LABEL: fp128 @f128_neg( #[no_mangle] pub fn f128_neg(a: f128) -> f128 { // CHECK: fneg fp128 -a } -// CHECK-LABEL: fp128 @f128_add( +// x86-LABEL: void @f128_add({{.*}}sret([16 x i8]) +// bit32-LABEL: void @f128_add({{.*}}sret([16 x i8]) +// bit64-LABEL: fp128 @f128_add( #[no_mangle] pub fn f128_add(a: f128, b: f128) -> f128 { // CHECK: fadd fp128 %{{.+}}, %{{.+}} a + b } -// CHECK-LABEL: fp128 @f128_sub( +// x86-LABEL: void @f128_sub({{.*}}sret([16 x i8]) +// bit32-LABEL: void @f128_sub({{.*}}sret([16 x i8]) +// bit64-LABEL: fp128 @f128_sub( #[no_mangle] pub fn f128_sub(a: f128, b: f128) -> f128 { // CHECK: fsub fp128 %{{.+}}, %{{.+}} a - b } -// CHECK-LABEL: fp128 @f128_mul( +// x86-LABEL: void @f128_mul({{.*}}sret([16 x i8]) +// bit32-LABEL: void @f128_mul({{.*}}sret([16 x i8]) +// bit64-LABEL: fp128 @f128_mul( #[no_mangle] pub fn f128_mul(a: f128, b: f128) -> f128 { // CHECK: fmul fp128 %{{.+}}, %{{.+}} a * b } -// CHECK-LABEL: fp128 @f128_div( +// x86-LABEL: void @f128_div({{.*}}sret([16 x i8]) +// bit32-LABEL: void @f128_div({{.*}}sret([16 x i8]) +// bit64-LABEL: fp128 @f128_div( #[no_mangle] pub fn f128_div(a: f128, b: f128) -> f128 { // CHECK: fdiv fp128 %{{.+}}, %{{.+}} a / b } -// CHECK-LABEL: fp128 @f128_rem( +// x86-LABEL: void @f128_rem({{.*}}sret([16 x i8]) +// bit32-LABEL: void @f128_rem({{.*}}sret([16 x i8]) +// bit64-LABEL: fp128 @f128_rem( #[no_mangle] pub fn f128_rem(a: f128, b: f128) -> f128 { // CHECK: frem fp128 %{{.+}}, %{{.+}} @@ -143,44 +159,56 @@ pub fn f128_as_f16(a: f128) -> f16 { a as f16 } -// other-LABEL: float @f128_as_f32( // x86-LABEL: i32 @f128_as_f32( +// bit32-LABEL: float @f128_as_f32( +// bit64-LABEL: float @f128_as_f32( #[no_mangle] pub fn f128_as_f32(a: f128) -> f32 { // CHECK: fptrunc fp128 %{{.+}} to float a as f32 } -// other-LABEL: double @f128_as_f64( // x86-LABEL: void @f128_as_f64( +// bit32-LABEL: double @f128_as_f64( +// bit64-LABEL: double @f128_as_f64( #[no_mangle] pub fn f128_as_f64(a: f128) -> f64 { // CHECK: fptrunc fp128 %{{.+}} to double a as f64 } -// CHECK-LABEL: fp128 @f128_as_self( +// x86-LABEL: void @f128_as_self({{.*}}sret([16 x i8]) +// bit32-LABEL: void @f128_as_self({{.*}}sret([16 x i8]) +// bit64-LABEL: fp128 @f128_as_self( #[no_mangle] pub fn f128_as_self(a: f128) -> f128 { - // CHECK: ret fp128 %{{.+}} + // x86: store fp128 %a, ptr %_0, align 16 + // bit32: store fp128 %a, ptr %_0, align 16 + // bit64: ret fp128 %{{.+}} a as f128 } -// CHECK-LABEL: fp128 @f16_as_f128( +// x86-LABEL: void @f16_as_f128({{.*}}sret([16 x i8]) +// bit32-LABEL: void @f16_as_f128({{.*}}sret([16 x i8]) +// bit64-LABEL: fp128 @f16_as_f128( #[no_mangle] pub fn f16_as_f128(a: f16) -> f128 { // CHECK: fpext half %{{.+}} to fp128 a as f128 } -// CHECK-LABEL: fp128 @f32_as_f128( +// x86-LABEL: void @f32_as_f128({{.*}}sret([16 x i8]) +// bit32-LABEL: void @f32_as_f128({{.*}}sret([16 x i8]) +// bit64-LABEL: fp128 @f32_as_f128( #[no_mangle] pub fn f32_as_f128(a: f32) -> f128 { // CHECK: fpext float %{{.+}} to fp128 a as f128 } -// CHECK-LABEL: fp128 @f64_as_f128( +// x86-LABEL: void @f64_as_f128({{.*}}sret([16 x i8]) +// bit32-LABEL: void @f64_as_f128({{.*}}sret([16 x i8]) +// bit64-LABEL: fp128 @f64_as_f128( #[no_mangle] pub fn f64_as_f128(a: f64) -> f128 { // CHECK: fpext double %{{.+}} to fp128 @@ -216,7 +244,9 @@ pub fn f128_as_u64(a: f128) -> u64 { a as u64 } -// CHECK-LABEL: i128 @f128_as_u128( +// x86-LABEL: void @f128_as_u128({{.*}}sret([16 x i8]) +// bit32-LABEL: void @f128_as_u128({{.*}}sret([16 x i8]) +// bit64-LABEL: i128 @f128_as_u128( #[no_mangle] pub fn f128_as_u128(a: f128) -> u128 { // CHECK: call i128 @llvm.fptoui.sat.i128.f128(fp128 %{{.+}}) @@ -250,7 +280,9 @@ pub fn f128_as_i64(a: f128) -> i64 { a as i64 } -// CHECK-LABEL: i128 @f128_as_i128( +// x86-LABEL: void @f128_as_i128({{.*}}sret([16 x i8]) +// bit32-LABEL: void @f128_as_i128({{.*}}sret([16 x i8]) +// bit64-LABEL: i128 @f128_as_i128( #[no_mangle] pub fn f128_as_i128(a: f128) -> i128 { // CHECK: call i128 @llvm.fptosi.sat.i128.f128(fp128 %{{.+}}) @@ -259,70 +291,90 @@ pub fn f128_as_i128(a: f128) -> i128 { /* int to float conversions */ -// CHECK-LABEL: fp128 @u8_as_f128( +// x86-LABEL: void @u8_as_f128({{.*}}sret([16 x i8]) +// bit32-LABEL: void @u8_as_f128({{.*}}sret([16 x i8]) +// bit64-LABEL: fp128 @u8_as_f128( #[no_mangle] pub fn u8_as_f128(a: u8) -> f128 { // CHECK: uitofp i8 %{{.+}} to fp128 a as f128 } -// CHECK-LABEL: fp128 @u16_as_f128( +// x86-LABEL: void @u16_as_f128({{.*}}sret([16 x i8]) +// bit32-LABEL: void @u16_as_f128({{.*}}sret([16 x i8]) +// bit64-LABEL: fp128 @u16_as_f128( #[no_mangle] pub fn u16_as_f128(a: u16) -> f128 { // CHECK: uitofp i16 %{{.+}} to fp128 a as f128 } -// CHECK-LABEL: fp128 @u32_as_f128( +// x86-LABEL: void @u32_as_f128({{.*}}sret([16 x i8]) +// bit32-LABEL: void @u32_as_f128({{.*}}sret([16 x i8]) +// bit64-LABEL: fp128 @u32_as_f128( #[no_mangle] pub fn u32_as_f128(a: u32) -> f128 { // CHECK: uitofp i32 %{{.+}} to fp128 a as f128 } -// CHECK-LABEL: fp128 @u64_as_f128( +// x86-LABEL: void @u64_as_f128({{.*}}sret([16 x i8]) +// bit32-LABEL: void @u64_as_f128({{.*}}sret([16 x i8]) +// bit64-LABEL: fp128 @u64_as_f128( #[no_mangle] pub fn u64_as_f128(a: u64) -> f128 { // CHECK: uitofp i64 %{{.+}} to fp128 a as f128 } -// CHECK-LABEL: fp128 @u128_as_f128( +// x86-LABEL: void @u128_as_f128({{.*}}sret([16 x i8]) +// bit32-LABEL: void @u128_as_f128({{.*}}sret([16 x i8]) +// bit64-LABEL: fp128 @u128_as_f128( #[no_mangle] pub fn u128_as_f128(a: u128) -> f128 { // CHECK: uitofp i128 %{{.+}} to fp128 a as f128 } -// CHECK-LABEL: fp128 @i8_as_f128( +// x86-LABEL: void @i8_as_f128({{.*}}sret([16 x i8]) +// bit32-LABEL: void @i8_as_f128({{.*}}sret([16 x i8]) +// bit64-LABEL: fp128 @i8_as_f128( #[no_mangle] pub fn i8_as_f128(a: i8) -> f128 { // CHECK: sitofp i8 %{{.+}} to fp128 a as f128 } -// CHECK-LABEL: fp128 @i16_as_f128( +// x86-LABEL: void @i16_as_f128({{.*}}sret([16 x i8]) +// bit32-LABEL: void @i16_as_f128({{.*}}sret([16 x i8]) +// bit64-LABEL: fp128 @i16_as_f128( #[no_mangle] pub fn i16_as_f128(a: i16) -> f128 { // CHECK: sitofp i16 %{{.+}} to fp128 a as f128 } -// CHECK-LABEL: fp128 @i32_as_f128( +// x86-LABEL: void @i32_as_f128({{.*}}sret([16 x i8]) +// bit32-LABEL: void @i32_as_f128({{.*}}sret([16 x i8]) +// bit64-LABEL: fp128 @i32_as_f128( #[no_mangle] pub fn i32_as_f128(a: i32) -> f128 { // CHECK: sitofp i32 %{{.+}} to fp128 a as f128 } -// CHECK-LABEL: fp128 @i64_as_f128( +// x86-LABEL: void @i64_as_f128({{.*}}sret([16 x i8]) +// bit32-LABEL: void @i64_as_f128({{.*}}sret([16 x i8]) +// bit64-LABEL: fp128 @i64_as_f128( #[no_mangle] pub fn i64_as_f128(a: i64) -> f128 { // CHECK: sitofp i64 %{{.+}} to fp128 a as f128 } -// CHECK-LABEL: fp128 @i128_as_f128( +// x86-LABEL: void @i128_as_f128({{.*}}sret([16 x i8]) +// bit32-LABEL: void @i128_as_f128({{.*}}sret([16 x i8]) +// bit64-LABEL: fp128 @i128_as_f128( #[no_mangle] pub fn i128_as_f128(a: i128) -> f128 { // CHECK: sitofp i128 %{{.+}} to fp128 diff --git a/tests/codegen/float/f16.rs b/tests/codegen/float/f16.rs index 2910d7d3e92..80931051f18 100644 --- a/tests/codegen/float/f16.rs +++ b/tests/codegen/float/f16.rs @@ -1,7 +1,11 @@ // 32-bit x86 returns `f32` and `f64` differently to avoid the x87 stack. -//@ revisions: x86 other +// 32-bit systems will return 128bit values using a return area pointer. +//@ revisions: x86 bit32 bit64 //@[x86] only-x86 -//@[other] ignore-x86 +//@[bit32] ignore-x86 +//@[bit32] only-32bit +//@[bit64] ignore-x86 +//@[bit64] only-64bit // Verify that our intrinsics generate the correct LLVM calls for f16 @@ -145,23 +149,27 @@ pub fn f16_as_self(a: f16) -> f16 { a as f16 } -// other-LABEL: float @f16_as_f32( // x86-LABEL: i32 @f16_as_f32( +// bit32-LABEL: float @f16_as_f32( +// bit64-LABEL: float @f16_as_f32( #[no_mangle] pub fn f16_as_f32(a: f16) -> f32 { // CHECK: fpext half %{{.+}} to float a as f32 } -// other-LABEL: double @f16_as_f64( // x86-LABEL: void @f16_as_f64( +// bit32-LABEL: double @f16_as_f64( +// bit64-LABEL: double @f16_as_f64( #[no_mangle] pub fn f16_as_f64(a: f16) -> f64 { // CHECK: fpext half %{{.+}} to double a as f64 } -// CHECK-LABEL: fp128 @f16_as_f128( +// x86-LABEL: void @f16_as_f128({{.*}}sret([16 x i8]) +// bit32-LABEL: void @f16_as_f128({{.*}}sret([16 x i8]) +// bit64-LABEL: fp128 @f16_as_f128( #[no_mangle] pub fn f16_as_f128(a: f16) -> f128 { // CHECK: fpext half %{{.+}} to fp128 @@ -218,7 +226,9 @@ pub fn f16_as_u64(a: f16) -> u64 { a as u64 } -// CHECK-LABEL: i128 @f16_as_u128( +// x86-LABEL: void @f16_as_u128({{.*}}sret([16 x i8]) +// bit32-LABEL: void @f16_as_u128({{.*}}sret([16 x i8]) +// bit64-LABEL: i128 @f16_as_u128( #[no_mangle] pub fn f16_as_u128(a: f16) -> u128 { // CHECK: call i128 @llvm.fptoui.sat.i128.f16(half %{{.+}}) @@ -252,7 +262,9 @@ pub fn f16_as_i64(a: f16) -> i64 { a as i64 } -// CHECK-LABEL: i128 @f16_as_i128( +// x86-LABEL: void @f16_as_i128({{.*}}sret([16 x i8]) +// bit32-LABEL: void @f16_as_i128({{.*}}sret([16 x i8]) +// bit64-LABEL: i128 @f16_as_i128( #[no_mangle] pub fn f16_as_i128(a: f16) -> i128 { // CHECK: call i128 @llvm.fptosi.sat.i128.f16(half %{{.+}}) diff --git a/tests/codegen/mir-aggregate-no-alloca.rs b/tests/codegen/mir-aggregate-no-alloca.rs index c0e7e1a05e3..84eb565c852 100644 --- a/tests/codegen/mir-aggregate-no-alloca.rs +++ b/tests/codegen/mir-aggregate-no-alloca.rs @@ -1,3 +1,7 @@ +// 32-bit systems will return 128bit values using a return area pointer. +//@ revisions: bit32 bit64 +//@[bit32] only-32bit +//@[bit64] only-64bit //@ compile-flags: -O -C no-prepopulate-passes -Z randomize-layout=no #![crate_type = "lib"] @@ -98,26 +102,36 @@ pub fn make_struct_1(a: i32) -> Struct1 { pub struct Struct2Asc(i16, i64); -// CHECK-LABEL: { i64, i16 } @make_struct_2_asc(i16 noundef %a, i64 noundef %b) +// bit32-LABEL: void @make_struct_2_asc({{.*}} sret([16 x i8]) {{.*}} %s, +// bit64-LABEL: { i64, i16 } @make_struct_2_asc( +// CHECK-SAME: i16 noundef %a, i64 noundef %b) #[no_mangle] pub fn make_struct_2_asc(a: i16, b: i64) -> Struct2Asc { // CHECK-NOT: alloca - // CHECK: %[[TEMP0:.+]] = insertvalue { i64, i16 } poison, i64 %b, 0 - // CHECK: %[[TEMP1:.+]] = insertvalue { i64, i16 } %[[TEMP0]], i16 %a, 1 - // CHECK: ret { i64, i16 } %[[TEMP1]] + // bit32: %[[GEP:.+]] = getelementptr inbounds i8, ptr %s, i32 8 + // bit32: store i16 %a, ptr %[[GEP]], align 8 + // bit32: store i64 %b, ptr %s, align 8 + // bit64: %[[TEMP0:.+]] = insertvalue { i64, i16 } poison, i64 %b, 0 + // bit64: %[[TEMP1:.+]] = insertvalue { i64, i16 } %[[TEMP0]], i16 %a, 1 + // bit64: ret { i64, i16 } %[[TEMP1]] let s = Struct2Asc(a, b); s } pub struct Struct2Desc(i64, i16); -// CHECK-LABEL: { i64, i16 } @make_struct_2_desc(i64 noundef %a, i16 noundef %b) +// bit32-LABEL: void @make_struct_2_desc({{.*}} sret([16 x i8]) {{.*}} %s, +// bit64-LABEL: { i64, i16 } @make_struct_2_desc( +// CHECK-SAME: i64 noundef %a, i16 noundef %b) #[no_mangle] pub fn make_struct_2_desc(a: i64, b: i16) -> Struct2Desc { // CHECK-NOT: alloca - // CHECK: %[[TEMP0:.+]] = insertvalue { i64, i16 } poison, i64 %a, 0 - // CHECK: %[[TEMP1:.+]] = insertvalue { i64, i16 } %[[TEMP0]], i16 %b, 1 - // CHECK: ret { i64, i16 } %[[TEMP1]] + // bit32: store i64 %a, ptr %s, align 8 + // bit32: %[[GEP:.+]] = getelementptr inbounds i8, ptr %s, i32 8 + // bit32: store i16 %b, ptr %[[GEP]], align 8 + // bit64: %[[TEMP0:.+]] = insertvalue { i64, i16 } poison, i64 %a, 0 + // bit64: %[[TEMP1:.+]] = insertvalue { i64, i16 } %[[TEMP0]], i16 %b, 1 + // bit64: ret { i64, i16 } %[[TEMP1]] let s = Struct2Desc(a, b); s } diff --git a/tests/codegen/range-attribute.rs b/tests/codegen/range-attribute.rs index bb19bec0fb9..456b28fc535 100644 --- a/tests/codegen/range-attribute.rs +++ b/tests/codegen/range-attribute.rs @@ -1,6 +1,10 @@ // Checks that range metadata gets emitted on functions result and arguments // with scalar value. +// 32-bit systems will return 128bit values using a return area pointer. +//@ revisions: bit32 bit64 +//@[bit32] only-32bit +//@[bit64] only-64bit //@ compile-flags: -O -C no-prepopulate-passes //@ min-llvm-version: 19 @@ -13,7 +17,8 @@ use std::num::NonZero; #[no_mangle] pub fn helper(_: usize) {} -// CHECK: noundef range(i128 1, 0) i128 @nonzero_int(i128 noundef range(i128 1, 0) %x) +// bit32: void @nonzero_int({{.*}} sret([16 x i8]) {{.*}}, i128 noundef range(i128 1, 0) %x) +// bit64: noundef range(i128 1, 0) i128 @nonzero_int(i128 noundef range(i128 1, 0) %x) #[no_mangle] pub fn nonzero_int(x: NonZero) -> NonZero { x @@ -43,7 +48,9 @@ pub enum Enum1 { C(u64), } -// CHECK: { [[ENUM1_TYP:i[0-9]+]], i64 } @enum1_value([[ENUM1_TYP]] noundef range([[ENUM1_TYP]] 0, 3) %x.0, i64 noundef %x.1) +// bit32: void @enum1_value({{.*}} sret([16 x i8]) {{[^,]*}}, [[ENUM1_TYP:i[0-9]+]] +// bit64: { [[ENUM1_TYP:i[0-9]+]], i64 } @enum1_value([[ENUM1_TYP]] +// CHECK-SAME: noundef range([[ENUM1_TYP]] 0, 3) %x.0, i64 noundef %x.1) #[no_mangle] pub fn enum1_value(x: Enum1) -> Enum1 { x diff --git a/tests/codegen/tuple-layout-opt.rs b/tests/codegen/tuple-layout-opt.rs index 3202e4749c5..ce64b7b46a9 100644 --- a/tests/codegen/tuple-layout-opt.rs +++ b/tests/codegen/tuple-layout-opt.rs @@ -1,3 +1,7 @@ +// 32-bit systems will return 128bit values using a return area pointer. +//@ revisions: bit32 bit64 +//@[bit32] only-32bit +//@[bit64] only-64bit //@ compile-flags: -C no-prepopulate-passes -Copt-level=0 // Test that tuples get optimized layout, in particular with a ZST in the last field (#63244) @@ -5,42 +9,52 @@ #![crate_type = "lib"] type ScalarZstLast = (u128, ()); -// CHECK: define {{(dso_local )?}}i128 @test_ScalarZstLast(i128 %_1) +// bit32: define {{(dso_local )?}}void @test_ScalarZstLast({{.*}} sret([16 x i8]) {{.*}}, i128 %_1) +// bit64: define {{(dso_local )?}}i128 @test_ScalarZstLast(i128 %_1) #[no_mangle] pub fn test_ScalarZstLast(_: ScalarZstLast) -> ScalarZstLast { loop {} } type ScalarZstFirst = ((), u128); -// CHECK: define {{(dso_local )?}}i128 @test_ScalarZstFirst(i128 %_1) +// bit32: define {{(dso_local )?}}void @test_ScalarZstFirst({{.*}} sret([16 x i8]) {{.*}}, i128 %_1) +// bit64: define {{(dso_local )?}}i128 @test_ScalarZstFirst(i128 %_1) #[no_mangle] pub fn test_ScalarZstFirst(_: ScalarZstFirst) -> ScalarZstFirst { loop {} } type ScalarPairZstLast = (u8, u128, ()); -// CHECK: define {{(dso_local )?}}void @test_ScalarPairZstLast(ptr sret([32 x i8]) align 16 %_0, i128 %_1.0, i8 %_1.1) +// bit32: define {{(dso_local )?}}void @test_ScalarPairZstLast(ptr sret([24 x i8]) align 8 +// bit64: define {{(dso_local )?}}void @test_ScalarPairZstLast(ptr sret([32 x i8]) align 16 +// CHECK-SAME: %_0, i128 %_1.0, i8 %_1.1) #[no_mangle] pub fn test_ScalarPairZstLast(_: ScalarPairZstLast) -> ScalarPairZstLast { loop {} } type ScalarPairZstFirst = ((), u8, u128); -// CHECK: define {{(dso_local )?}}void @test_ScalarPairZstFirst(ptr sret([32 x i8]) align 16 %_0, i8 %_1.0, i128 %_1.1) +// bit32: define {{(dso_local )?}}void @test_ScalarPairZstFirst(ptr sret([24 x i8]) align 8 +// bit64: define {{(dso_local )?}}void @test_ScalarPairZstFirst(ptr sret([32 x i8]) align 16 +// CHECK-SAME: %_0, i8 %_1.0, i128 %_1.1) #[no_mangle] pub fn test_ScalarPairZstFirst(_: ScalarPairZstFirst) -> ScalarPairZstFirst { loop {} } type ScalarPairLotsOfZsts = ((), u8, (), u128, ()); -// CHECK: define {{(dso_local )?}}void @test_ScalarPairLotsOfZsts(ptr sret([32 x i8]) align 16 %_0, i128 %_1.0, i8 %_1.1) +// bit32: define {{(dso_local )?}}void @test_ScalarPairLotsOfZsts(ptr sret([24 x i8]) align 8 +// bit64: define {{(dso_local )?}}void @test_ScalarPairLotsOfZsts(ptr sret([32 x i8]) align 16 +// CHECK-SAME: %_0, i128 %_1.0, i8 %_1.1) #[no_mangle] pub fn test_ScalarPairLotsOfZsts(_: ScalarPairLotsOfZsts) -> ScalarPairLotsOfZsts { loop {} } type ScalarPairLottaNesting = (((), ((), u8, (), u128, ())), ()); -// CHECK: define {{(dso_local )?}}void @test_ScalarPairLottaNesting(ptr sret([32 x i8]) align 16 %_0, i128 %_1.0, i8 %_1.1) +// bit32: define {{(dso_local )?}}void @test_ScalarPairLottaNesting(ptr sret([24 x i8]) align 8 +// bit64: define {{(dso_local )?}}void @test_ScalarPairLottaNesting(ptr sret([32 x i8]) align 16 +// CHECK-SAME: %_0, i128 %_1.0, i8 %_1.1) #[no_mangle] pub fn test_ScalarPairLottaNesting(_: ScalarPairLottaNesting) -> ScalarPairLottaNesting { loop {} diff --git a/tests/codegen/union-abi.rs b/tests/codegen/union-abi.rs index a1c081d7d61..b3c67a59730 100644 --- a/tests/codegen/union-abi.rs +++ b/tests/codegen/union-abi.rs @@ -1,9 +1,13 @@ //@ ignore-emscripten vectors passed directly //@ compile-flags: -O -C no-prepopulate-passes // 32-bit x86 returns `f32` differently to avoid the x87 stack. -//@ revisions: x86 other +// 32-bit systems will return 128bit values using a return area pointer. +//@ revisions: x86 bit32 bit64 //@[x86] only-x86 -//@[other] ignore-x86 +//@[bit32] ignore-x86 +//@[bit32] only-32bit +//@[bit64] ignore-x86 +//@[bit64] only-64bit // This test that using union forward the abi of the inner type, as // discussed in #54668 @@ -71,8 +75,9 @@ pub union UnionF32 { a: f32, } -// other: define {{(dso_local )?}}float @test_UnionF32(float %_1) // x86: define {{(dso_local )?}}i32 @test_UnionF32(float %_1) +// bit32: define {{(dso_local )?}}float @test_UnionF32(float %_1) +// bit64: define {{(dso_local )?}}float @test_UnionF32(float %_1) #[no_mangle] pub fn test_UnionF32(_: UnionF32) -> UnionF32 { loop {} @@ -83,8 +88,9 @@ pub union UnionF32F32 { b: f32, } -// other: define {{(dso_local )?}}float @test_UnionF32F32(float %_1) // x86: define {{(dso_local )?}}i32 @test_UnionF32F32(float %_1) +// bit32: define {{(dso_local )?}}float @test_UnionF32F32(float %_1) +// bit64: define {{(dso_local )?}}float @test_UnionF32F32(float %_1) #[no_mangle] pub fn test_UnionF32F32(_: UnionF32F32) -> UnionF32F32 { loop {} @@ -104,7 +110,9 @@ pub fn test_UnionF32U32(_: UnionF32U32) -> UnionF32U32 { pub union UnionU128 { a: u128, } -// CHECK: define {{(dso_local )?}}i128 @test_UnionU128(i128 %_1) +// x86: define {{(dso_local )?}}void @test_UnionU128({{.*}}sret([16 x i8]){{.*}}, i128 %_1) +// bit32: define {{(dso_local )?}}void @test_UnionU128({{.*}}sret([16 x i8]){{.*}}, i128 %_1) +// bit64: define {{(dso_local )?}}i128 @test_UnionU128(i128 %_1) #[no_mangle] pub fn test_UnionU128(_: UnionU128) -> UnionU128 { loop {} -- cgit 1.4.1-3-g733a5 From 0e7309516950b04acc3732ece92ad2edfbd1868e Mon Sep 17 00:00:00 2001 From: Matthew Maurer Date: Wed, 16 Oct 2024 18:38:26 +0000 Subject: llvm: Tolerate propagated range metadata llvm/llvm-project#91101 propagates range information across inlining, resulting in more metadata in this test. Tolerate the range metadata if it appears. --- tests/codegen/iter-repeat-n-trivial-drop.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/codegen') diff --git a/tests/codegen/iter-repeat-n-trivial-drop.rs b/tests/codegen/iter-repeat-n-trivial-drop.rs index 7de224b92d8..4dab499a8a5 100644 --- a/tests/codegen/iter-repeat-n-trivial-drop.rs +++ b/tests/codegen/iter-repeat-n-trivial-drop.rs @@ -47,7 +47,7 @@ pub fn iter_repeat_n_next(it: &mut std::iter::RepeatN) -> Option Vec { - // CHECK: %[[ADDR:.+]] = tail call {{(noalias )?}}noundef dereferenceable_or_null(1234) ptr @__rust_alloc(i64 noundef 1234, i64 noundef 1) + // CHECK: %[[ADDR:.+]] = tail call {{(noalias )?}}noundef dereferenceable_or_null(1234) ptr @__rust_alloc(i64 noundef {{(range\(i64 1, 0\) )?}}1234, i64 noundef {{(range\(i64 1, -9223372036854775807\) )?}}1) // CHECK: tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(1234) %[[ADDR]], i8 42, i64 1234, let n = 1234_usize; -- cgit 1.4.1-3-g733a5 From aa299a9bdfc64b02404d05fe1984fd1571aa224d Mon Sep 17 00:00:00 2001 From: clubby789 Date: Sat, 19 Oct 2024 10:05:07 +0000 Subject: Add codegen test for branchy bool match --- .../issues/issue-108395-branchy-bool-match.rs | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tests/codegen/issues/issue-108395-branchy-bool-match.rs (limited to 'tests/codegen') diff --git a/tests/codegen/issues/issue-108395-branchy-bool-match.rs b/tests/codegen/issues/issue-108395-branchy-bool-match.rs new file mode 100644 index 00000000000..24f5c0f6635 --- /dev/null +++ b/tests/codegen/issues/issue-108395-branchy-bool-match.rs @@ -0,0 +1,27 @@ +//@ compile-flags: -O -Zmerge-functions=disabled +//! Test for . Check that +//! matching on two bools with wildcards does not produce branches. +#![crate_type = "lib"] + +// CHECK-LABEL: @wildcard( +#[no_mangle] +pub fn wildcard(a: u16, b: u16, v: u16) -> u16 { + // CHECK-NOT: br + match (a == v, b == v) { + (true, false) => 0, + (false, true) => u16::MAX, + _ => 1 << 15, // half + } +} + +// CHECK-LABEL: @exhaustive( +#[no_mangle] +pub fn exhaustive(a: u16, b: u16, v: u16) -> u16 { + // CHECK-NOT: br + match (a == v, b == v) { + (true, false) => 0, + (false, true) => u16::MAX, + (true, true) => 1 << 15, + (false, false) => 1 << 15, + } +} -- cgit 1.4.1-3-g733a5 From cc7044b080d167745b7425ed3cb8c9866401c375 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 17 Oct 2024 09:43:21 +0000 Subject: Fix test expectations for 32bit x86 --- tests/assembly/x86-return-float.rs | 2 +- tests/codegen/mir-aggregate-no-alloca.rs | 12 ++++++------ tests/codegen/range-attribute.rs | 2 +- tests/codegen/tuple-layout-opt.rs | 12 ++++-------- 4 files changed, 12 insertions(+), 16 deletions(-) (limited to 'tests/codegen') diff --git a/tests/assembly/x86-return-float.rs b/tests/assembly/x86-return-float.rs index f9ebf53dddc..30c5e869633 100644 --- a/tests/assembly/x86-return-float.rs +++ b/tests/assembly/x86-return-float.rs @@ -315,10 +315,10 @@ pub fn return_f16(x: f16) -> f16 { #[no_mangle] pub fn return_f128(x: f128) -> f128 { // CHECK: movl [[#%d,OFFSET:]](%ebp), %[[PTR:.*]] - // CHECK-NEXT: movl [[#%d,OFFSET+16]](%ebp), %[[VAL4:.*]] // CHECK-NEXT: movl [[#%d,OFFSET+4]](%ebp), %[[VAL1:.*]] // CHECK-NEXT: movl [[#%d,OFFSET+8]](%ebp), %[[VAL2:.*]] // CHECK-NEXT: movl [[#%d,OFFSET+12]](%ebp), %[[VAL3:.*]] + // CHECK-NEXT: movl [[#%d,OFFSET+16]](%ebp), %[[VAL4:.*]] // CHECK-NEXT: movl %[[VAL4:.*]] 12(%[[PTR]]) // CHECK-NEXT: movl %[[VAL3:.*]] 8(%[[PTR]]) // CHECK-NEXT: movl %[[VAL2:.*]] 4(%[[PTR]]) diff --git a/tests/codegen/mir-aggregate-no-alloca.rs b/tests/codegen/mir-aggregate-no-alloca.rs index 84eb565c852..04ffb075538 100644 --- a/tests/codegen/mir-aggregate-no-alloca.rs +++ b/tests/codegen/mir-aggregate-no-alloca.rs @@ -102,15 +102,15 @@ pub fn make_struct_1(a: i32) -> Struct1 { pub struct Struct2Asc(i16, i64); -// bit32-LABEL: void @make_struct_2_asc({{.*}} sret([16 x i8]) {{.*}} %s, +// bit32-LABEL: void @make_struct_2_asc({{.*}} sret({{[^,]*}}) {{.*}} %s, // bit64-LABEL: { i64, i16 } @make_struct_2_asc( // CHECK-SAME: i16 noundef %a, i64 noundef %b) #[no_mangle] pub fn make_struct_2_asc(a: i16, b: i64) -> Struct2Asc { // CHECK-NOT: alloca // bit32: %[[GEP:.+]] = getelementptr inbounds i8, ptr %s, i32 8 - // bit32: store i16 %a, ptr %[[GEP]], align 8 - // bit32: store i64 %b, ptr %s, align 8 + // bit32: store i16 %a, ptr %[[GEP]] + // bit32: store i64 %b, ptr %s // bit64: %[[TEMP0:.+]] = insertvalue { i64, i16 } poison, i64 %b, 0 // bit64: %[[TEMP1:.+]] = insertvalue { i64, i16 } %[[TEMP0]], i16 %a, 1 // bit64: ret { i64, i16 } %[[TEMP1]] @@ -120,15 +120,15 @@ pub fn make_struct_2_asc(a: i16, b: i64) -> Struct2Asc { pub struct Struct2Desc(i64, i16); -// bit32-LABEL: void @make_struct_2_desc({{.*}} sret([16 x i8]) {{.*}} %s, +// bit32-LABEL: void @make_struct_2_desc({{.*}} sret({{[^,]*}}) {{.*}} %s, // bit64-LABEL: { i64, i16 } @make_struct_2_desc( // CHECK-SAME: i64 noundef %a, i16 noundef %b) #[no_mangle] pub fn make_struct_2_desc(a: i64, b: i16) -> Struct2Desc { // CHECK-NOT: alloca - // bit32: store i64 %a, ptr %s, align 8 + // bit32: store i64 %a, ptr %s // bit32: %[[GEP:.+]] = getelementptr inbounds i8, ptr %s, i32 8 - // bit32: store i16 %b, ptr %[[GEP]], align 8 + // bit32: store i16 %b, ptr %[[GEP]] // bit64: %[[TEMP0:.+]] = insertvalue { i64, i16 } poison, i64 %a, 0 // bit64: %[[TEMP1:.+]] = insertvalue { i64, i16 } %[[TEMP0]], i16 %b, 1 // bit64: ret { i64, i16 } %[[TEMP1]] diff --git a/tests/codegen/range-attribute.rs b/tests/codegen/range-attribute.rs index 456b28fc535..8972fc76ca2 100644 --- a/tests/codegen/range-attribute.rs +++ b/tests/codegen/range-attribute.rs @@ -48,7 +48,7 @@ pub enum Enum1 { C(u64), } -// bit32: void @enum1_value({{.*}} sret([16 x i8]) {{[^,]*}}, [[ENUM1_TYP:i[0-9]+]] +// bit32: void @enum1_value({{.*}} sret({{[^,]*}}) {{[^,]*}}, [[ENUM1_TYP:i[0-9]+]] // bit64: { [[ENUM1_TYP:i[0-9]+]], i64 } @enum1_value([[ENUM1_TYP]] // CHECK-SAME: noundef range([[ENUM1_TYP]] 0, 3) %x.0, i64 noundef %x.1) #[no_mangle] diff --git a/tests/codegen/tuple-layout-opt.rs b/tests/codegen/tuple-layout-opt.rs index ce64b7b46a9..5b2f65e7aa7 100644 --- a/tests/codegen/tuple-layout-opt.rs +++ b/tests/codegen/tuple-layout-opt.rs @@ -25,8 +25,7 @@ pub fn test_ScalarZstFirst(_: ScalarZstFirst) -> ScalarZstFirst { } type ScalarPairZstLast = (u8, u128, ()); -// bit32: define {{(dso_local )?}}void @test_ScalarPairZstLast(ptr sret([24 x i8]) align 8 -// bit64: define {{(dso_local )?}}void @test_ScalarPairZstLast(ptr sret([32 x i8]) align 16 +// CHECK: define {{(dso_local )?}}void @test_ScalarPairZstLast(ptr sret({{[^,]*}}) // CHECK-SAME: %_0, i128 %_1.0, i8 %_1.1) #[no_mangle] pub fn test_ScalarPairZstLast(_: ScalarPairZstLast) -> ScalarPairZstLast { @@ -34,8 +33,7 @@ pub fn test_ScalarPairZstLast(_: ScalarPairZstLast) -> ScalarPairZstLast { } type ScalarPairZstFirst = ((), u8, u128); -// bit32: define {{(dso_local )?}}void @test_ScalarPairZstFirst(ptr sret([24 x i8]) align 8 -// bit64: define {{(dso_local )?}}void @test_ScalarPairZstFirst(ptr sret([32 x i8]) align 16 +// CHECK: define {{(dso_local )?}}void @test_ScalarPairZstFirst(ptr sret({{[^,]*}}) // CHECK-SAME: %_0, i8 %_1.0, i128 %_1.1) #[no_mangle] pub fn test_ScalarPairZstFirst(_: ScalarPairZstFirst) -> ScalarPairZstFirst { @@ -43,8 +41,7 @@ pub fn test_ScalarPairZstFirst(_: ScalarPairZstFirst) -> ScalarPairZstFirst { } type ScalarPairLotsOfZsts = ((), u8, (), u128, ()); -// bit32: define {{(dso_local )?}}void @test_ScalarPairLotsOfZsts(ptr sret([24 x i8]) align 8 -// bit64: define {{(dso_local )?}}void @test_ScalarPairLotsOfZsts(ptr sret([32 x i8]) align 16 +// CHECK: define {{(dso_local )?}}void @test_ScalarPairLotsOfZsts(ptr sret({{[^,]*}}) // CHECK-SAME: %_0, i128 %_1.0, i8 %_1.1) #[no_mangle] pub fn test_ScalarPairLotsOfZsts(_: ScalarPairLotsOfZsts) -> ScalarPairLotsOfZsts { @@ -52,8 +49,7 @@ pub fn test_ScalarPairLotsOfZsts(_: ScalarPairLotsOfZsts) -> ScalarPairLotsOfZst } type ScalarPairLottaNesting = (((), ((), u8, (), u128, ())), ()); -// bit32: define {{(dso_local )?}}void @test_ScalarPairLottaNesting(ptr sret([24 x i8]) align 8 -// bit64: define {{(dso_local )?}}void @test_ScalarPairLottaNesting(ptr sret([32 x i8]) align 16 +// CHECK: define {{(dso_local )?}}void @test_ScalarPairLottaNesting(ptr sret({{[^,]*}}) // CHECK-SAME: %_0, i128 %_1.0, i8 %_1.1) #[no_mangle] pub fn test_ScalarPairLottaNesting(_: ScalarPairLottaNesting) -> ScalarPairLottaNesting { -- cgit 1.4.1-3-g733a5 From 56ee492a6e7a917b2b3f888e33dd52a13d3ecb64 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 14 Sep 2024 13:44:02 +0200 Subject: move strict provenance lints to new feature gate, remove old feature gates --- compiler/rustc_arena/src/lib.rs | 1 - compiler/rustc_codegen_ssa/src/lib.rs | 1 - compiler/rustc_const_eval/src/lib.rs | 1 - compiler/rustc_data_structures/src/lib.rs | 1 - compiler/rustc_feature/src/unstable.rs | 2 +- compiler/rustc_lint_defs/src/builtin.rs | 6 ++---- compiler/rustc_middle/src/lib.rs | 1 - compiler/rustc_span/src/symbol.rs | 2 +- library/alloc/benches/lib.rs | 3 ++- library/alloc/src/lib.rs | 3 ++- library/alloc/tests/lib.rs | 3 ++- library/core/src/intrinsics.rs | 1 - library/core/src/lib.rs | 3 ++- library/core/src/ptr/const_ptr.rs | 2 +- library/core/src/ptr/mod.rs | 2 -- library/core/src/ptr/mut_ptr.rs | 2 +- library/core/src/ptr/non_null.rs | 1 - library/core/src/sync/atomic.rs | 12 +++++------ library/core/tests/lib.rs | 3 ++- library/panic_unwind/src/lib.rs | 2 -- library/portable-simd/crates/core_simd/src/lib.rs | 1 - .../crates/core_simd/tests/pointers.rs | 2 +- library/proc_macro/src/lib.rs | 1 - library/std/src/lib.rs | 4 ++-- library/unwind/src/lib.rs | 1 - .../language-features/strict-provenance-lints.md | 21 ++++++++++++++++++ .../src/language-features/strict-provenance.md | 22 ------------------- src/tools/miri/src/lib.rs | 2 -- .../dangling_pointer_to_raw_pointer.rs | 1 - .../fail/dangling_pointers/deref_dangling_box.rs | 1 - .../fail/dangling_pointers/deref_dangling_ref.rs | 1 - .../intrinsics/ptr_offset_from_different_ints.rs | 1 - .../fail/provenance/int_copy_looses_provenance3.rs | 1 - .../tests/fail/provenance/provenance_transmute.rs | 1 - .../tests/fail/provenance/ptr_int_unexposed.rs | 1 - .../miri/tests/fail/provenance/ptr_invalid.rs | 1 - .../tests/fail/provenance/ptr_invalid_offset.rs | 1 - .../fail/provenance/strict_provenance_cast.rs | 1 - .../tests/fail/stacked_borrows/exposed_only_ro.rs | 1 - .../fail/unaligned_pointers/promise_alignment.rs | 1 - .../uninit_alloc_diagnostic_with_provenance.rs | 1 - .../miri/tests/pass-dep/libc/libc-affinity.rs | 1 - .../tests/pass-dep/libc/libc-epoll-no-blocking.rs | 1 - src/tools/miri/tests/pass-dep/libc/libc-mem.rs | 2 +- src/tools/miri/tests/pass-dep/libc/libc-misc.rs | 1 - src/tools/miri/tests/pass-dep/libc/mmap.rs | 1 - src/tools/miri/tests/pass/align_offset_symbolic.rs | 1 - src/tools/miri/tests/pass/atomic.rs | 2 +- .../miri/tests/pass/box-custom-alloc-aliasing.rs | 1 - .../concurrency/address_reuse_happens_before.rs | 1 - src/tools/miri/tests/pass/const-addrs.rs | 1 - .../miri/tests/pass/drop_type_without_drop_glue.rs | 2 +- src/tools/miri/tests/pass/extern_types.rs | 2 +- src/tools/miri/tests/pass/provenance.rs | 1 - src/tools/miri/tests/pass/ptr_int_from_exposed.rs | 1 - src/tools/miri/tests/pass/ptr_raw.rs | 1 - src/tools/miri/tests/pass/shims/ptr_mask.rs | 1 - src/tools/miri/tests/pass/slices.rs | 1 - .../miri/tests/pass/stacked-borrows/int-to-ptr.rs | 1 - .../tests/pass/stacked-borrows/stack-printing.rs | 1 - .../pass/stacked-borrows/unknown-bottom-gc.rs | 1 - src/tools/miri/tests/pass/transmute_ptr.rs | 1 - src/tools/miri/tests/pass/underscore_pattern.rs | 1 - .../tests/pass/zero-sized-accesses-and-offsets.rs | 1 - tests/codegen/atomicptr.rs | 1 - .../issues/issue-103285-ptr-addr-overflow-check.rs | 1 - tests/mir-opt/gvn_ptr_eq_with_constant.rs | 2 -- .../exposed-provenance/basic.rs | 2 -- .../exposed-provenance/function.rs | 2 -- .../exposed-provenance/inline1.rs | 2 -- .../exposed-provenance/inline2.rs | 2 -- .../exposed-provenance/print.rs | 2 -- .../exposed-provenance/print3.rs | 2 -- .../exposed-provenance/segfault.rs | 2 -- .../exposed-provenance/zero.rs | 2 -- .../strict-provenance/basic.rs | 2 -- .../strict-provenance/function.rs | 2 -- .../strict-provenance/inline1.rs | 2 -- .../strict-provenance/inline2.rs | 2 -- .../strict-provenance/print.rs | 2 -- .../strict-provenance/print3.rs | 2 -- .../strict-provenance/segfault.rs | 2 -- .../strict-provenance/zero.rs | 2 -- .../feature-gate-strict_provenance.rs | 15 ------------- .../feature-gate-strict_provenance.stderr | 25 ---------------------- .../feature-gate-strict_provenance_lints.rs | 15 +++++++++++++ .../feature-gate-strict_provenance_lints.stderr | 25 ++++++++++++++++++++++ .../ui/lint/lint-strict-provenance-fuzzy-casts.rs | 2 +- .../ui/lint/lint-strict-provenance-lossy-casts.rs | 2 +- tests/ui/mir/alignment/i686-pc-windows-msvc.rs | 2 -- tests/ui/mir/alignment/packed.rs | 2 -- tests/ui/structs-enums/type-sizes.rs | 1 - 92 files changed, 92 insertions(+), 179 deletions(-) create mode 100644 src/doc/unstable-book/src/language-features/strict-provenance-lints.md delete mode 100644 src/doc/unstable-book/src/language-features/strict-provenance.md delete mode 100644 tests/ui/feature-gates/feature-gate-strict_provenance.rs delete mode 100644 tests/ui/feature-gates/feature-gate-strict_provenance.stderr create mode 100644 tests/ui/feature-gates/feature-gate-strict_provenance_lints.rs create mode 100644 tests/ui/feature-gates/feature-gate-strict_provenance_lints.stderr (limited to 'tests/codegen') diff --git a/compiler/rustc_arena/src/lib.rs b/compiler/rustc_arena/src/lib.rs index cecf223b961..4d8525989cc 100644 --- a/compiler/rustc_arena/src/lib.rs +++ b/compiler/rustc_arena/src/lib.rs @@ -23,7 +23,6 @@ #![feature(maybe_uninit_slice)] #![feature(rustc_attrs)] #![feature(rustdoc_internals)] -#![feature(strict_provenance)] #![warn(unreachable_pub)] // tidy-alphabetical-end diff --git a/compiler/rustc_codegen_ssa/src/lib.rs b/compiler/rustc_codegen_ssa/src/lib.rs index cbd95146294..73bfa9dbd10 100644 --- a/compiler/rustc_codegen_ssa/src/lib.rs +++ b/compiler/rustc_codegen_ssa/src/lib.rs @@ -11,7 +11,6 @@ #![feature(let_chains)] #![feature(negative_impls)] #![feature(rustdoc_internals)] -#![feature(strict_provenance)] #![feature(trait_alias)] #![feature(try_blocks)] #![warn(unreachable_pub)] diff --git a/compiler/rustc_const_eval/src/lib.rs b/compiler/rustc_const_eval/src/lib.rs index 39e2d3b4ebb..0490195caf4 100644 --- a/compiler/rustc_const_eval/src/lib.rs +++ b/compiler/rustc_const_eval/src/lib.rs @@ -10,7 +10,6 @@ #![feature(never_type)] #![feature(rustdoc_internals)] #![feature(slice_ptr_get)] -#![feature(strict_provenance)] #![feature(trait_alias)] #![feature(try_blocks)] #![feature(unqualified_local_imports)] diff --git a/compiler/rustc_data_structures/src/lib.rs b/compiler/rustc_data_structures/src/lib.rs index fba2707922b..afac08ae6f8 100644 --- a/compiler/rustc_data_structures/src/lib.rs +++ b/compiler/rustc_data_structures/src/lib.rs @@ -33,7 +33,6 @@ #![feature(ptr_alignment_type)] #![feature(rustc_attrs)] #![feature(rustdoc_internals)] -#![feature(strict_provenance)] #![feature(test)] #![feature(thread_id_value)] #![feature(type_alias_impl_trait)] diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 1067156958d..cecb9a2fe56 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -598,7 +598,7 @@ declare_features! ( /// Allows attributes on expressions and non-item statements. (unstable, stmt_expr_attributes, "1.6.0", Some(15701)), /// Allows lints part of the strict provenance effort. - (unstable, strict_provenance, "1.61.0", Some(95228)), + (unstable, strict_provenance_lints, "1.61.0", Some(130351)), /// Allows string patterns to dereference values to match them. (unstable, string_deref_patterns, "1.67.0", Some(87121)), /// Allows the use of `#[target_feature]` on safe functions. diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 45a5ce0ca20..10f0f6f6a06 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -2667,7 +2667,6 @@ declare_lint! { /// ### Example /// /// ```rust - /// #![feature(strict_provenance)] /// #![warn(fuzzy_provenance_casts)] /// /// fn main() { @@ -2701,7 +2700,7 @@ declare_lint! { pub FUZZY_PROVENANCE_CASTS, Allow, "a fuzzy integer to pointer cast is used", - @feature_gate = strict_provenance; + @feature_gate = strict_provenance_lints; } declare_lint! { @@ -2711,7 +2710,6 @@ declare_lint! { /// ### Example /// /// ```rust - /// #![feature(strict_provenance)] /// #![warn(lossy_provenance_casts)] /// /// fn main() { @@ -2747,7 +2745,7 @@ declare_lint! { pub LOSSY_PROVENANCE_CASTS, Allow, "a lossy pointer to integer cast is used", - @feature_gate = strict_provenance; + @feature_gate = strict_provenance_lints; } declare_lint! { diff --git a/compiler/rustc_middle/src/lib.rs b/compiler/rustc_middle/src/lib.rs index e9b73d25ba2..04a06ba7464 100644 --- a/compiler/rustc_middle/src/lib.rs +++ b/compiler/rustc_middle/src/lib.rs @@ -56,7 +56,6 @@ #![feature(ptr_alignment_type)] #![feature(rustc_attrs)] #![feature(rustdoc_internals)] -#![feature(strict_provenance)] #![feature(trait_upcasting)] #![feature(trusted_len)] #![feature(try_blocks)] diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 6f62b4f82d7..3ab482072b8 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -1913,7 +1913,7 @@ symbols! { str_trim, str_trim_end, str_trim_start, - strict_provenance, + strict_provenance_lints, string_as_mut_str, string_as_str, string_deref_patterns, diff --git a/library/alloc/benches/lib.rs b/library/alloc/benches/lib.rs index ae9608ec7bd..c1907361f93 100644 --- a/library/alloc/benches/lib.rs +++ b/library/alloc/benches/lib.rs @@ -4,7 +4,8 @@ #![feature(iter_next_chunk)] #![feature(repr_simd)] #![feature(slice_partition_dedup)] -#![feature(strict_provenance)] +#![cfg_attr(bootstrap, feature(strict_provenance))] +#![cfg_attr(not(bootstrap), feature(strict_provenance_lints))] #![feature(test)] #![deny(fuzzy_provenance_casts)] diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index ae9b3739858..50a5f3c5b1e 100644 --- a/library/alloc/src/lib.rs +++ b/library/alloc/src/lib.rs @@ -147,7 +147,6 @@ #![feature(slice_range)] #![feature(std_internals)] #![feature(str_internals)] -#![feature(strict_provenance)] #![feature(trusted_fused)] #![feature(trusted_len)] #![feature(trusted_random_access)] @@ -162,6 +161,8 @@ // // Language features: // tidy-alphabetical-start +#![cfg_attr(bootstrap, feature(strict_provenance))] +#![cfg_attr(not(bootstrap), feature(strict_provenance_lints))] #![cfg_attr(not(test), feature(coroutine_trait))] #![cfg_attr(test, feature(panic_update_hook))] #![cfg_attr(test, feature(test))] diff --git a/library/alloc/tests/lib.rs b/library/alloc/tests/lib.rs index 301126b5d4d..699a8e6776e 100644 --- a/library/alloc/tests/lib.rs +++ b/library/alloc/tests/lib.rs @@ -32,7 +32,8 @@ #![feature(panic_update_hook)] #![feature(pointer_is_aligned_to)] #![feature(thin_box)] -#![feature(strict_provenance)] +#![cfg_attr(bootstrap, feature(strict_provenance))] +#![cfg_attr(not(bootstrap), feature(strict_provenance_lints))] #![feature(drain_keep_rest)] #![feature(local_waker)] #![feature(vec_pop_if)] diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index 38e858626b9..97e727633c5 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -2794,7 +2794,6 @@ where /// #![feature(is_val_statically_known)] /// #![feature(core_intrinsics)] /// # #![allow(internal_features)] -/// #![feature(strict_provenance)] /// use std::intrinsics::is_val_statically_known; /// /// fn foo(x: &i32) -> bool { diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index ad034d3e576..16877566765 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -163,7 +163,6 @@ #![feature(str_internals)] #![feature(str_split_inclusive_remainder)] #![feature(str_split_remainder)] -#![feature(strict_provenance)] #![feature(ub_checks)] #![feature(unchecked_neg)] #![feature(unchecked_shifts)] @@ -174,6 +173,8 @@ // // Language features: // tidy-alphabetical-start +#![cfg_attr(bootstrap, feature(strict_provenance))] +#![cfg_attr(not(bootstrap), feature(strict_provenance_lints))] #![feature(abi_unadjusted)] #![feature(adt_const_params)] #![feature(allow_internal_unsafe)] diff --git a/library/core/src/ptr/const_ptr.rs b/library/core/src/ptr/const_ptr.rs index f530954516b..9ee0fb5948e 100644 --- a/library/core/src/ptr/const_ptr.rs +++ b/library/core/src/ptr/const_ptr.rs @@ -552,7 +552,7 @@ impl *const T { /// ## Examples /// /// ``` - /// #![feature(ptr_mask, strict_provenance)] + /// #![feature(ptr_mask)] /// let v = 17_u32; /// let ptr: *const u32 = &v; /// diff --git a/library/core/src/ptr/mod.rs b/library/core/src/ptr/mod.rs index 72a77ea6b18..f769b515877 100644 --- a/library/core/src/ptr/mod.rs +++ b/library/core/src/ptr/mod.rs @@ -290,8 +290,6 @@ //! represent the tagged pointer as an actual pointer and not a `usize`*. For instance: //! //! ``` -//! #![feature(strict_provenance)] -//! //! unsafe { //! // A flag we want to pack into our pointer //! static HAS_DATA: usize = 0x1; diff --git a/library/core/src/ptr/mut_ptr.rs b/library/core/src/ptr/mut_ptr.rs index aac42f517ef..782934fc311 100644 --- a/library/core/src/ptr/mut_ptr.rs +++ b/library/core/src/ptr/mut_ptr.rs @@ -549,7 +549,7 @@ impl *mut T { /// ## Examples /// /// ``` - /// #![feature(ptr_mask, strict_provenance)] + /// #![feature(ptr_mask)] /// let mut v = 17_u32; /// let ptr: *mut u32 = &mut v; /// diff --git a/library/core/src/ptr/non_null.rs b/library/core/src/ptr/non_null.rs index 0477147d87f..d91bbe1a5a1 100644 --- a/library/core/src/ptr/non_null.rs +++ b/library/core/src/ptr/non_null.rs @@ -748,7 +748,6 @@ impl NonNull { /// *Incorrect* usage: /// /// ```rust,no_run - /// #![feature(strict_provenance)] /// use std::ptr::NonNull; /// /// let ptr1 = NonNull::new(Box::into_raw(Box::new(0u8))).unwrap(); diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs index 42b68e28273..17ba18c2a66 100644 --- a/library/core/src/sync/atomic.rs +++ b/library/core/src/sync/atomic.rs @@ -1758,7 +1758,7 @@ impl AtomicPtr { /// # Examples /// /// ``` - /// #![feature(strict_provenance_atomic_ptr, strict_provenance)] + /// #![feature(strict_provenance_atomic_ptr)] /// use core::sync::atomic::{AtomicPtr, Ordering}; /// /// let atom = AtomicPtr::::new(core::ptr::null_mut()); @@ -1838,7 +1838,7 @@ impl AtomicPtr { /// # Examples /// /// ``` - /// #![feature(strict_provenance_atomic_ptr, strict_provenance)] + /// #![feature(strict_provenance_atomic_ptr)] /// use core::sync::atomic::{AtomicPtr, Ordering}; /// /// let atom = AtomicPtr::::new(core::ptr::null_mut()); @@ -1874,7 +1874,7 @@ impl AtomicPtr { /// # Examples /// /// ``` - /// #![feature(strict_provenance_atomic_ptr, strict_provenance)] + /// #![feature(strict_provenance_atomic_ptr)] /// use core::sync::atomic::{AtomicPtr, Ordering}; /// /// let atom = AtomicPtr::::new(core::ptr::without_provenance_mut(1)); @@ -1919,7 +1919,7 @@ impl AtomicPtr { /// # Examples /// /// ``` - /// #![feature(strict_provenance_atomic_ptr, strict_provenance)] + /// #![feature(strict_provenance_atomic_ptr)] /// use core::sync::atomic::{AtomicPtr, Ordering}; /// /// let pointer = &mut 3i64 as *mut i64; @@ -1970,7 +1970,7 @@ impl AtomicPtr { /// # Examples /// /// ``` - /// #![feature(strict_provenance_atomic_ptr, strict_provenance)] + /// #![feature(strict_provenance_atomic_ptr)] /// use core::sync::atomic::{AtomicPtr, Ordering}; /// /// let pointer = &mut 3i64 as *mut i64; @@ -2020,7 +2020,7 @@ impl AtomicPtr { /// # Examples /// /// ``` - /// #![feature(strict_provenance_atomic_ptr, strict_provenance)] + /// #![feature(strict_provenance_atomic_ptr)] /// use core::sync::atomic::{AtomicPtr, Ordering}; /// /// let pointer = &mut 3i64 as *mut i64; diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs index 443090097c0..5d6921845d0 100644 --- a/library/core/tests/lib.rs +++ b/library/core/tests/lib.rs @@ -1,4 +1,6 @@ // tidy-alphabetical-start +#![cfg_attr(bootstrap, feature(strict_provenance))] +#![cfg_attr(not(bootstrap), feature(strict_provenance_lints))] #![cfg_attr(target_has_atomic = "128", feature(integer_atomics))] #![cfg_attr(test, feature(cfg_match))] #![feature(alloc_layout_extra)] @@ -85,7 +87,6 @@ #![feature(std_internals)] #![feature(step_trait)] #![feature(str_internals)] -#![feature(strict_provenance)] #![feature(strict_provenance_atomic_ptr)] #![feature(test)] #![feature(trait_upcasting)] diff --git a/library/panic_unwind/src/lib.rs b/library/panic_unwind/src/lib.rs index 6cd4dffb8aa..1981675f409 100644 --- a/library/panic_unwind/src/lib.rs +++ b/library/panic_unwind/src/lib.rs @@ -19,8 +19,6 @@ #![feature(panic_unwind)] #![feature(staged_api)] #![feature(std_internals)] -#![feature(strict_provenance)] -#![feature(exposed_provenance)] #![feature(rustc_attrs)] #![panic_runtime] #![feature(panic_runtime)] diff --git a/library/portable-simd/crates/core_simd/src/lib.rs b/library/portable-simd/crates/core_simd/src/lib.rs index cc6246b4a0d..992a7705e3c 100644 --- a/library/portable-simd/crates/core_simd/src/lib.rs +++ b/library/portable-simd/crates/core_simd/src/lib.rs @@ -9,7 +9,6 @@ repr_simd, simd_ffi, staged_api, - strict_provenance, prelude_import, ptr_metadata )] diff --git a/library/portable-simd/crates/core_simd/tests/pointers.rs b/library/portable-simd/crates/core_simd/tests/pointers.rs index 90bfc5d5fd6..d7db4e82b3c 100644 --- a/library/portable-simd/crates/core_simd/tests/pointers.rs +++ b/library/portable-simd/crates/core_simd/tests/pointers.rs @@ -1,4 +1,4 @@ -#![feature(portable_simd, strict_provenance, exposed_provenance)] +#![feature(portable_simd)] use core_simd::simd::{ ptr::{SimdConstPtr, SimdMutPtr}, diff --git a/library/proc_macro/src/lib.rs b/library/proc_macro/src/lib.rs index 72b597a8083..ae47bb7adf4 100644 --- a/library/proc_macro/src/lib.rs +++ b/library/proc_macro/src/lib.rs @@ -32,7 +32,6 @@ #![feature(restricted_std)] #![feature(rustc_attrs)] #![feature(min_specialization)] -#![feature(strict_provenance)] #![recursion_limit = "256"] #![allow(internal_features)] #![deny(ffi_unwind_calls)] diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 3ab65238368..8c1a3c76829 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -279,6 +279,8 @@ // // Language features: // tidy-alphabetical-start +#![cfg_attr(bootstrap, feature(strict_provenance))] +#![cfg_attr(not(bootstrap), feature(strict_provenance_lints))] #![feature(alloc_error_handler)] #![feature(allocator_internals)] #![feature(allow_internal_unsafe)] @@ -336,7 +338,6 @@ #![feature(error_iter)] #![feature(exact_size_is_empty)] #![feature(exclusive_wrapper)] -#![feature(exposed_provenance)] #![feature(extend_one)] #![feature(float_gamma)] #![feature(float_minimum_maximum)] @@ -362,7 +363,6 @@ #![feature(slice_range)] #![feature(std_internals)] #![feature(str_internals)] -#![feature(strict_provenance)] #![feature(strict_provenance_atomic_ptr)] #![feature(ub_checks)] // tidy-alphabetical-end diff --git a/library/unwind/src/lib.rs b/library/unwind/src/lib.rs index 5a476d5843b..79baa5b0b83 100644 --- a/library/unwind/src/lib.rs +++ b/library/unwind/src/lib.rs @@ -2,7 +2,6 @@ #![unstable(feature = "panic_unwind", issue = "32837")] #![feature(link_cfg)] #![feature(staged_api)] -#![feature(strict_provenance)] #![cfg_attr(not(target_env = "msvc"), feature(libc))] #![cfg_attr( all(target_family = "wasm", not(target_os = "emscripten")), diff --git a/src/doc/unstable-book/src/language-features/strict-provenance-lints.md b/src/doc/unstable-book/src/language-features/strict-provenance-lints.md new file mode 100644 index 00000000000..81bdf07a86a --- /dev/null +++ b/src/doc/unstable-book/src/language-features/strict-provenance-lints.md @@ -0,0 +1,21 @@ +# `strict_provenance_lints` + +The tracking issue for this feature is: [#95228] + +[#95228]: https://github.com/rust-lang/rust/issues/95228 +----- + +The `strict_provenance_lints` feature allows to enable the `fuzzy_provenance_casts` and `lossy_provenance_casts` lints. +These lint on casts between integers and pointers, that are recommended against or invalid in the strict provenance model. + +## Example + +```rust +#![feature(strict_provenance_lints)] +#![warn(fuzzy_provenance_casts)] + +fn main() { + let _dangling = 16_usize as *const u8; + //~^ WARNING: strict provenance disallows casting integer `usize` to pointer `*const u8` +} +``` diff --git a/src/doc/unstable-book/src/language-features/strict-provenance.md b/src/doc/unstable-book/src/language-features/strict-provenance.md deleted file mode 100644 index dc60f3f375d..00000000000 --- a/src/doc/unstable-book/src/language-features/strict-provenance.md +++ /dev/null @@ -1,22 +0,0 @@ -# `strict_provenance` - -The tracking issue for this feature is: [#95228] - -[#95228]: https://github.com/rust-lang/rust/issues/95228 ------ - -The `strict_provenance` feature allows to enable the `fuzzy_provenance_casts` and `lossy_provenance_casts` lints. -These lint on casts between integers and pointers, that are recommended against or invalid in the strict provenance model. -The same feature gate is also used for the experimental strict provenance API in `std` (actually `core`). - -## Example - -```rust -#![feature(strict_provenance)] -#![warn(fuzzy_provenance_casts)] - -fn main() { - let _dangling = 16_usize as *const u8; - //~^ WARNING: strict provenance disallows casting integer `usize` to pointer `*const u8` -} -``` diff --git a/src/tools/miri/src/lib.rs b/src/tools/miri/src/lib.rs index 9814858beaa..660f2e493bc 100644 --- a/src/tools/miri/src/lib.rs +++ b/src/tools/miri/src/lib.rs @@ -11,8 +11,6 @@ #![feature(let_chains)] #![feature(trait_upcasting)] #![feature(strict_overflow_ops)] -#![feature(strict_provenance)] -#![feature(exposed_provenance)] #![feature(pointer_is_aligned_to)] #![feature(unqualified_local_imports)] // Configure clippy and other lints diff --git a/src/tools/miri/tests/fail/dangling_pointers/dangling_pointer_to_raw_pointer.rs b/src/tools/miri/tests/fail/dangling_pointers/dangling_pointer_to_raw_pointer.rs index 3e20b8da622..c63e926376d 100644 --- a/src/tools/miri/tests/fail/dangling_pointers/dangling_pointer_to_raw_pointer.rs +++ b/src/tools/miri/tests/fail/dangling_pointers/dangling_pointer_to_raw_pointer.rs @@ -1,4 +1,3 @@ -#![feature(strict_provenance)] use std::ptr; fn direct_raw(x: *const (i32, i32)) -> *const i32 { diff --git a/src/tools/miri/tests/fail/dangling_pointers/deref_dangling_box.rs b/src/tools/miri/tests/fail/dangling_pointers/deref_dangling_box.rs index fa40f942b8f..b22c1b4c5e8 100644 --- a/src/tools/miri/tests/fail/dangling_pointers/deref_dangling_box.rs +++ b/src/tools/miri/tests/fail/dangling_pointers/deref_dangling_box.rs @@ -1,6 +1,5 @@ // Should be caught even without retagging //@compile-flags: -Zmiri-disable-stacked-borrows -#![feature(strict_provenance)] use std::ptr::{self, addr_of_mut}; // Deref'ing a dangling raw pointer is fine, but for a dangling box it is not. diff --git a/src/tools/miri/tests/fail/dangling_pointers/deref_dangling_ref.rs b/src/tools/miri/tests/fail/dangling_pointers/deref_dangling_ref.rs index 036ef2580a8..eeab7c333e5 100644 --- a/src/tools/miri/tests/fail/dangling_pointers/deref_dangling_ref.rs +++ b/src/tools/miri/tests/fail/dangling_pointers/deref_dangling_ref.rs @@ -1,6 +1,5 @@ // Should be caught even without retagging //@compile-flags: -Zmiri-disable-stacked-borrows -#![feature(strict_provenance)] use std::ptr::{self, addr_of_mut}; // Deref'ing a dangling raw pointer is fine, but for a dangling reference it is not. diff --git a/src/tools/miri/tests/fail/intrinsics/ptr_offset_from_different_ints.rs b/src/tools/miri/tests/fail/intrinsics/ptr_offset_from_different_ints.rs index c307dfddb6c..0acda559d3a 100644 --- a/src/tools/miri/tests/fail/intrinsics/ptr_offset_from_different_ints.rs +++ b/src/tools/miri/tests/fail/intrinsics/ptr_offset_from_different_ints.rs @@ -1,4 +1,3 @@ -#![feature(strict_provenance)] use core::ptr; fn main() { diff --git a/src/tools/miri/tests/fail/provenance/int_copy_looses_provenance3.rs b/src/tools/miri/tests/fail/provenance/int_copy_looses_provenance3.rs index d6bbfd7d94c..da381596284 100644 --- a/src/tools/miri/tests/fail/provenance/int_copy_looses_provenance3.rs +++ b/src/tools/miri/tests/fail/provenance/int_copy_looses_provenance3.rs @@ -1,4 +1,3 @@ -#![feature(strict_provenance)] use std::mem; #[repr(C, usize)] diff --git a/src/tools/miri/tests/fail/provenance/provenance_transmute.rs b/src/tools/miri/tests/fail/provenance/provenance_transmute.rs index bc5dd53dcf5..d72f10530d7 100644 --- a/src/tools/miri/tests/fail/provenance/provenance_transmute.rs +++ b/src/tools/miri/tests/fail/provenance/provenance_transmute.rs @@ -1,5 +1,4 @@ //@compile-flags: -Zmiri-permissive-provenance -#![feature(strict_provenance)] use std::mem; diff --git a/src/tools/miri/tests/fail/provenance/ptr_int_unexposed.rs b/src/tools/miri/tests/fail/provenance/ptr_int_unexposed.rs index f89378fcb3c..a43ba13e13d 100644 --- a/src/tools/miri/tests/fail/provenance/ptr_int_unexposed.rs +++ b/src/tools/miri/tests/fail/provenance/ptr_int_unexposed.rs @@ -1,5 +1,4 @@ //@compile-flags: -Zmiri-permissive-provenance -#![feature(strict_provenance, exposed_provenance)] fn main() { let x: i32 = 3; diff --git a/src/tools/miri/tests/fail/provenance/ptr_invalid.rs b/src/tools/miri/tests/fail/provenance/ptr_invalid.rs index 512473cd894..d4479f32e56 100644 --- a/src/tools/miri/tests/fail/provenance/ptr_invalid.rs +++ b/src/tools/miri/tests/fail/provenance/ptr_invalid.rs @@ -1,4 +1,3 @@ -#![feature(strict_provenance, exposed_provenance)] // Ensure that a `ptr::without_provenance` ptr is truly invalid. fn main() { diff --git a/src/tools/miri/tests/fail/provenance/ptr_invalid_offset.rs b/src/tools/miri/tests/fail/provenance/ptr_invalid_offset.rs index c8be521ef82..53a16ce5d1b 100644 --- a/src/tools/miri/tests/fail/provenance/ptr_invalid_offset.rs +++ b/src/tools/miri/tests/fail/provenance/ptr_invalid_offset.rs @@ -1,5 +1,4 @@ //@compile-flags: -Zmiri-strict-provenance -#![feature(strict_provenance)] fn main() { let x = 22; diff --git a/src/tools/miri/tests/fail/provenance/strict_provenance_cast.rs b/src/tools/miri/tests/fail/provenance/strict_provenance_cast.rs index d7b54f640f6..4674ba841b4 100644 --- a/src/tools/miri/tests/fail/provenance/strict_provenance_cast.rs +++ b/src/tools/miri/tests/fail/provenance/strict_provenance_cast.rs @@ -1,5 +1,4 @@ //@compile-flags: -Zmiri-strict-provenance -#![feature(exposed_provenance)] fn main() { let addr = &0 as *const i32 as usize; diff --git a/src/tools/miri/tests/fail/stacked_borrows/exposed_only_ro.rs b/src/tools/miri/tests/fail/stacked_borrows/exposed_only_ro.rs index 608ab718919..dfd7d4bb0be 100644 --- a/src/tools/miri/tests/fail/stacked_borrows/exposed_only_ro.rs +++ b/src/tools/miri/tests/fail/stacked_borrows/exposed_only_ro.rs @@ -1,5 +1,4 @@ //@compile-flags: -Zmiri-permissive-provenance -#![feature(exposed_provenance)] // If we have only exposed read-only pointers, doing a write through a wildcard ptr should fail. diff --git a/src/tools/miri/tests/fail/unaligned_pointers/promise_alignment.rs b/src/tools/miri/tests/fail/unaligned_pointers/promise_alignment.rs index e075db66039..009ce1eb882 100644 --- a/src/tools/miri/tests/fail/unaligned_pointers/promise_alignment.rs +++ b/src/tools/miri/tests/fail/unaligned_pointers/promise_alignment.rs @@ -1,6 +1,5 @@ //@compile-flags: -Zmiri-symbolic-alignment-check //@revisions: call_unaligned_ptr read_unaligned_ptr -#![feature(strict_provenance)] #[path = "../../utils/mod.rs"] mod utils; diff --git a/src/tools/miri/tests/fail/uninit/uninit_alloc_diagnostic_with_provenance.rs b/src/tools/miri/tests/fail/uninit/uninit_alloc_diagnostic_with_provenance.rs index 954571f4a22..1cf70d9d9a3 100644 --- a/src/tools/miri/tests/fail/uninit/uninit_alloc_diagnostic_with_provenance.rs +++ b/src/tools/miri/tests/fail/uninit/uninit_alloc_diagnostic_with_provenance.rs @@ -1,7 +1,6 @@ //@compile-flags: -Zmiri-disable-validation //@error-in-other-file: memory is uninitialized at [0x4..0x8] //@normalize-stderr-test: "a[0-9]+" -> "ALLOC" -#![feature(strict_provenance)] #![allow(dropping_copy_types)] // Test printing allocations that contain single-byte provenance. diff --git a/src/tools/miri/tests/pass-dep/libc/libc-affinity.rs b/src/tools/miri/tests/pass-dep/libc/libc-affinity.rs index 8aa8c7dcb8e..3c4311efc4c 100644 --- a/src/tools/miri/tests/pass-dep/libc/libc-affinity.rs +++ b/src/tools/miri/tests/pass-dep/libc/libc-affinity.rs @@ -3,7 +3,6 @@ //@compile-flags: -Zmiri-disable-isolation -Zmiri-num-cpus=4 #![feature(io_error_more)] #![feature(pointer_is_aligned_to)] -#![feature(strict_provenance)] use std::mem::{size_of, size_of_val}; diff --git a/src/tools/miri/tests/pass-dep/libc/libc-epoll-no-blocking.rs b/src/tools/miri/tests/pass-dep/libc/libc-epoll-no-blocking.rs index 3ea34513376..288c1d41f30 100644 --- a/src/tools/miri/tests/pass-dep/libc/libc-epoll-no-blocking.rs +++ b/src/tools/miri/tests/pass-dep/libc/libc-epoll-no-blocking.rs @@ -1,6 +1,5 @@ //@only-target: linux -#![feature(strict_provenance)] use std::convert::TryInto; fn main() { diff --git a/src/tools/miri/tests/pass-dep/libc/libc-mem.rs b/src/tools/miri/tests/pass-dep/libc/libc-mem.rs index c399616b9ae..10be78798a6 100644 --- a/src/tools/miri/tests/pass-dep/libc/libc-mem.rs +++ b/src/tools/miri/tests/pass-dep/libc/libc-mem.rs @@ -1,4 +1,4 @@ -#![feature(strict_provenance, pointer_is_aligned_to)] +#![feature(pointer_is_aligned_to)] use std::{mem, ptr, slice}; fn test_memcpy() { diff --git a/src/tools/miri/tests/pass-dep/libc/libc-misc.rs b/src/tools/miri/tests/pass-dep/libc/libc-misc.rs index f3261eaa43c..f07007fa705 100644 --- a/src/tools/miri/tests/pass-dep/libc/libc-misc.rs +++ b/src/tools/miri/tests/pass-dep/libc/libc-misc.rs @@ -2,7 +2,6 @@ //@compile-flags: -Zmiri-disable-isolation #![feature(io_error_more)] #![feature(pointer_is_aligned_to)] -#![feature(strict_provenance)] use std::mem::transmute; diff --git a/src/tools/miri/tests/pass-dep/libc/mmap.rs b/src/tools/miri/tests/pass-dep/libc/mmap.rs index db305acbf4a..bfd840d2fb8 100644 --- a/src/tools/miri/tests/pass-dep/libc/mmap.rs +++ b/src/tools/miri/tests/pass-dep/libc/mmap.rs @@ -1,6 +1,5 @@ //@ignore-target: windows # No mmap on Windows //@compile-flags: -Zmiri-disable-isolation -Zmiri-permissive-provenance -#![feature(strict_provenance)] use std::io::Error; use std::{ptr, slice}; diff --git a/src/tools/miri/tests/pass/align_offset_symbolic.rs b/src/tools/miri/tests/pass/align_offset_symbolic.rs index 9647277821f..c836a3b07cb 100644 --- a/src/tools/miri/tests/pass/align_offset_symbolic.rs +++ b/src/tools/miri/tests/pass/align_offset_symbolic.rs @@ -1,5 +1,4 @@ //@compile-flags: -Zmiri-symbolic-alignment-check -#![feature(strict_provenance)] use std::mem; diff --git a/src/tools/miri/tests/pass/atomic.rs b/src/tools/miri/tests/pass/atomic.rs index f84fe825d01..2b2e89e6d70 100644 --- a/src/tools/miri/tests/pass/atomic.rs +++ b/src/tools/miri/tests/pass/atomic.rs @@ -2,7 +2,7 @@ //@[tree]compile-flags: -Zmiri-tree-borrows //@compile-flags: -Zmiri-strict-provenance -#![feature(strict_provenance, strict_provenance_atomic_ptr)] +#![feature(strict_provenance_atomic_ptr)] // FIXME(static_mut_refs): Do not allow `static_mut_refs` lint #![allow(static_mut_refs)] diff --git a/src/tools/miri/tests/pass/box-custom-alloc-aliasing.rs b/src/tools/miri/tests/pass/box-custom-alloc-aliasing.rs index 0a61db960c1..63329118283 100644 --- a/src/tools/miri/tests/pass/box-custom-alloc-aliasing.rs +++ b/src/tools/miri/tests/pass/box-custom-alloc-aliasing.rs @@ -5,7 +5,6 @@ //@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows #![feature(allocator_api)] -#![feature(strict_provenance)] use std::alloc::{AllocError, Allocator, Layout}; use std::cell::{Cell, UnsafeCell}; diff --git a/src/tools/miri/tests/pass/concurrency/address_reuse_happens_before.rs b/src/tools/miri/tests/pass/concurrency/address_reuse_happens_before.rs index 255f4061abc..a293dd0bef1 100644 --- a/src/tools/miri/tests/pass/concurrency/address_reuse_happens_before.rs +++ b/src/tools/miri/tests/pass/concurrency/address_reuse_happens_before.rs @@ -1,7 +1,6 @@ //! Regression test for : //! When the address gets reused, there should be a happens-before relation. //@compile-flags: -Zmiri-address-reuse-cross-thread-rate=1.0 -#![feature(strict_provenance)] #![feature(sync_unsafe_cell)] use std::cell::SyncUnsafeCell; diff --git a/src/tools/miri/tests/pass/const-addrs.rs b/src/tools/miri/tests/pass/const-addrs.rs index 727c67ebfb5..af68b28b2b8 100644 --- a/src/tools/miri/tests/pass/const-addrs.rs +++ b/src/tools/miri/tests/pass/const-addrs.rs @@ -7,7 +7,6 @@ // MIR inlining will put every evaluation of the const we're repeatedly evaluating into the same // stack frame, breaking this test. //@compile-flags: -Zinline-mir=no -#![feature(strict_provenance)] const EVALS: usize = 256; diff --git a/src/tools/miri/tests/pass/drop_type_without_drop_glue.rs b/src/tools/miri/tests/pass/drop_type_without_drop_glue.rs index 43ddc8a4d8b..2f8665e8d62 100644 --- a/src/tools/miri/tests/pass/drop_type_without_drop_glue.rs +++ b/src/tools/miri/tests/pass/drop_type_without_drop_glue.rs @@ -1,4 +1,4 @@ -#![feature(custom_mir, core_intrinsics, strict_provenance)] +#![feature(custom_mir, core_intrinsics)] use std::intrinsics::mir::*; // The `Drop` terminator on a type with no drop glue should be a NOP. diff --git a/src/tools/miri/tests/pass/extern_types.rs b/src/tools/miri/tests/pass/extern_types.rs index eade5c6ac08..08e9caf4f1c 100644 --- a/src/tools/miri/tests/pass/extern_types.rs +++ b/src/tools/miri/tests/pass/extern_types.rs @@ -1,6 +1,6 @@ //@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows -#![feature(extern_types, strict_provenance)] +#![feature(extern_types)] use std::ptr; diff --git a/src/tools/miri/tests/pass/provenance.rs b/src/tools/miri/tests/pass/provenance.rs index 2e4d240cc48..8c52b703190 100644 --- a/src/tools/miri/tests/pass/provenance.rs +++ b/src/tools/miri/tests/pass/provenance.rs @@ -1,6 +1,5 @@ //@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows -#![feature(strict_provenance)] use std::{mem, ptr}; const PTR_SIZE: usize = mem::size_of::<&i32>(); diff --git a/src/tools/miri/tests/pass/ptr_int_from_exposed.rs b/src/tools/miri/tests/pass/ptr_int_from_exposed.rs index ade5f537785..9a76c8dd349 100644 --- a/src/tools/miri/tests/pass/ptr_int_from_exposed.rs +++ b/src/tools/miri/tests/pass/ptr_int_from_exposed.rs @@ -2,7 +2,6 @@ // Tree Borrows doesn't support int2ptr casts, but let's make sure we don't immediately crash either. //@[tree]compile-flags: -Zmiri-tree-borrows //@[stack]compile-flags: -Zmiri-permissive-provenance -#![feature(strict_provenance, exposed_provenance)] use std::ptr; diff --git a/src/tools/miri/tests/pass/ptr_raw.rs b/src/tools/miri/tests/pass/ptr_raw.rs index dcf13d97ce3..c958dfddf69 100644 --- a/src/tools/miri/tests/pass/ptr_raw.rs +++ b/src/tools/miri/tests/pass/ptr_raw.rs @@ -1,4 +1,3 @@ -#![feature(strict_provenance)] use std::mem; use std::ptr::{self, addr_of}; diff --git a/src/tools/miri/tests/pass/shims/ptr_mask.rs b/src/tools/miri/tests/pass/shims/ptr_mask.rs index fb8bb6b13db..6872ba577d2 100644 --- a/src/tools/miri/tests/pass/shims/ptr_mask.rs +++ b/src/tools/miri/tests/pass/shims/ptr_mask.rs @@ -1,5 +1,4 @@ #![feature(ptr_mask)] -#![feature(strict_provenance)] fn main() { let v: u32 = 0xABCDABCD; diff --git a/src/tools/miri/tests/pass/slices.rs b/src/tools/miri/tests/pass/slices.rs index 39e1d1cb97f..dd18a061cdd 100644 --- a/src/tools/miri/tests/pass/slices.rs +++ b/src/tools/miri/tests/pass/slices.rs @@ -4,7 +4,6 @@ #![feature(slice_as_chunks)] #![feature(slice_partition_dedup)] #![feature(layout_for_ptr)] -#![feature(strict_provenance)] use std::{ptr, slice}; diff --git a/src/tools/miri/tests/pass/stacked-borrows/int-to-ptr.rs b/src/tools/miri/tests/pass/stacked-borrows/int-to-ptr.rs index c89d79b42e3..8a05fca3f31 100644 --- a/src/tools/miri/tests/pass/stacked-borrows/int-to-ptr.rs +++ b/src/tools/miri/tests/pass/stacked-borrows/int-to-ptr.rs @@ -1,5 +1,4 @@ //@compile-flags: -Zmiri-permissive-provenance -#![feature(exposed_provenance)] use std::ptr; // Just to make sure that casting a ref to raw, to int and back to raw diff --git a/src/tools/miri/tests/pass/stacked-borrows/stack-printing.rs b/src/tools/miri/tests/pass/stacked-borrows/stack-printing.rs index 1478b21d6c1..e507f49b955 100644 --- a/src/tools/miri/tests/pass/stacked-borrows/stack-printing.rs +++ b/src/tools/miri/tests/pass/stacked-borrows/stack-printing.rs @@ -2,7 +2,6 @@ // printing, not how it interacts with the GC. //@compile-flags: -Zmiri-permissive-provenance -Zmiri-provenance-gc=0 -#![feature(strict_provenance)] use std::alloc::{self, Layout}; use std::mem::ManuallyDrop; diff --git a/src/tools/miri/tests/pass/stacked-borrows/unknown-bottom-gc.rs b/src/tools/miri/tests/pass/stacked-borrows/unknown-bottom-gc.rs index 55356814a1a..b0f53283cda 100644 --- a/src/tools/miri/tests/pass/stacked-borrows/unknown-bottom-gc.rs +++ b/src/tools/miri/tests/pass/stacked-borrows/unknown-bottom-gc.rs @@ -1,5 +1,4 @@ //@compile-flags: -Zmiri-permissive-provenance -#![feature(exposed_provenance)] use std::ptr; diff --git a/src/tools/miri/tests/pass/transmute_ptr.rs b/src/tools/miri/tests/pass/transmute_ptr.rs index ce6d86b7068..0944781c6de 100644 --- a/src/tools/miri/tests/pass/transmute_ptr.rs +++ b/src/tools/miri/tests/pass/transmute_ptr.rs @@ -1,6 +1,5 @@ //@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows -#![feature(strict_provenance)] use std::{mem, ptr}; fn t1() { diff --git a/src/tools/miri/tests/pass/underscore_pattern.rs b/src/tools/miri/tests/pass/underscore_pattern.rs index f59bb9f5c82..2f203bdc01e 100644 --- a/src/tools/miri/tests/pass/underscore_pattern.rs +++ b/src/tools/miri/tests/pass/underscore_pattern.rs @@ -1,5 +1,4 @@ // Various tests ensuring that underscore patterns really just construct the place, but don't check its contents. -#![feature(strict_provenance)] #![feature(never_type)] use std::ptr; diff --git a/src/tools/miri/tests/pass/zero-sized-accesses-and-offsets.rs b/src/tools/miri/tests/pass/zero-sized-accesses-and-offsets.rs index a3356b682a6..6c0d9bc253a 100644 --- a/src/tools/miri/tests/pass/zero-sized-accesses-and-offsets.rs +++ b/src/tools/miri/tests/pass/zero-sized-accesses-and-offsets.rs @@ -1,5 +1,4 @@ //! Tests specific for : zero-sized operations. -#![feature(strict_provenance)] use std::ptr; diff --git a/tests/codegen/atomicptr.rs b/tests/codegen/atomicptr.rs index ea8b382c8fc..e8c5e6a6749 100644 --- a/tests/codegen/atomicptr.rs +++ b/tests/codegen/atomicptr.rs @@ -6,7 +6,6 @@ //@ compile-flags: -O -Cno-prepopulate-passes #![crate_type = "lib"] -#![feature(strict_provenance)] #![feature(strict_provenance_atomic_ptr)] use std::ptr::without_provenance_mut; diff --git a/tests/codegen/issues/issue-103285-ptr-addr-overflow-check.rs b/tests/codegen/issues/issue-103285-ptr-addr-overflow-check.rs index d4a74b3d782..122f02fbbc5 100644 --- a/tests/codegen/issues/issue-103285-ptr-addr-overflow-check.rs +++ b/tests/codegen/issues/issue-103285-ptr-addr-overflow-check.rs @@ -1,7 +1,6 @@ //@ compile-flags: -O -C debug-assertions=yes #![crate_type = "lib"] -#![feature(strict_provenance)] #[no_mangle] pub fn test(src: *const u8, dst: *const u8) -> usize { diff --git a/tests/mir-opt/gvn_ptr_eq_with_constant.rs b/tests/mir-opt/gvn_ptr_eq_with_constant.rs index d8025072ee3..05445208e07 100644 --- a/tests/mir-opt/gvn_ptr_eq_with_constant.rs +++ b/tests/mir-opt/gvn_ptr_eq_with_constant.rs @@ -5,8 +5,6 @@ // Regression for -#![feature(strict_provenance)] - struct Foo(std::marker::PhantomData); impl Foo { diff --git a/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/basic.rs b/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/basic.rs index 0c9df7ecd78..b2b4934aa5f 100644 --- a/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/basic.rs +++ b/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/basic.rs @@ -2,8 +2,6 @@ //@ compile-flags: -Copt-level=2 //@ run-pass -#![feature(exposed_provenance)] - use std::ptr; fn main() { diff --git a/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/function.rs b/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/function.rs index b188b794d1f..bf130c9f759 100644 --- a/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/function.rs +++ b/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/function.rs @@ -4,8 +4,6 @@ // Based on https://github.com/rust-lang/rust/issues/107975#issuecomment-1434203908 -#![feature(exposed_provenance)] - use std::ptr; fn f() -> usize { diff --git a/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/inline1.rs b/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/inline1.rs index 7f64e23b9c1..cdf07eade87 100644 --- a/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/inline1.rs +++ b/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/inline1.rs @@ -4,8 +4,6 @@ // Based on https://github.com/rust-lang/rust/issues/107975#issuecomment-1432161340 -#![feature(exposed_provenance)] - use std::ptr; #[inline(never)] diff --git a/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/inline2.rs b/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/inline2.rs index 3417296ce12..f128e1bb084 100644 --- a/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/inline2.rs +++ b/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/inline2.rs @@ -4,8 +4,6 @@ // Based on https://github.com/rust-lang/rust/issues/107975#issuecomment-1432161340 -#![feature(exposed_provenance)] - use std::ptr; #[inline(never)] diff --git a/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/print.rs b/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/print.rs index e1e9e3f46b8..0baf8886395 100644 --- a/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/print.rs +++ b/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/print.rs @@ -4,8 +4,6 @@ // https://github.com/rust-lang/rust/issues/107975#issuecomment-1430704499 -#![feature(exposed_provenance)] - use std::ptr; fn main() { diff --git a/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/print3.rs b/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/print3.rs index 8d581e8c9e9..c7f46318aae 100644 --- a/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/print3.rs +++ b/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/print3.rs @@ -4,8 +4,6 @@ // https://github.com/rust-lang/rust/issues/107975#issuecomment-1430704499 -#![feature(exposed_provenance)] - use std::ptr; fn main() { diff --git a/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/segfault.rs b/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/segfault.rs index 506f114cd2a..b163c282d93 100644 --- a/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/segfault.rs +++ b/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/segfault.rs @@ -4,8 +4,6 @@ // https://github.com/rust-lang/rust/issues/107975#issuecomment-1431758601 -#![feature(exposed_provenance)] - use std::{ cell::{Ref, RefCell}, ptr, diff --git a/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/zero.rs b/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/zero.rs index 603db5e08f4..7ccff8d0848 100644 --- a/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/zero.rs +++ b/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/zero.rs @@ -4,8 +4,6 @@ // Derived from https://github.com/rust-lang/rust/issues/107975#issuecomment-1431758601 -#![feature(exposed_provenance)] - use std::ptr; fn main() { diff --git a/tests/ui/codegen/equal-pointers-unequal/strict-provenance/basic.rs b/tests/ui/codegen/equal-pointers-unequal/strict-provenance/basic.rs index 0243c2bfe95..4602ec654d1 100644 --- a/tests/ui/codegen/equal-pointers-unequal/strict-provenance/basic.rs +++ b/tests/ui/codegen/equal-pointers-unequal/strict-provenance/basic.rs @@ -2,8 +2,6 @@ //@ compile-flags: -Copt-level=2 //@ run-pass -#![feature(strict_provenance)] - use std::ptr; fn main() { diff --git a/tests/ui/codegen/equal-pointers-unequal/strict-provenance/function.rs b/tests/ui/codegen/equal-pointers-unequal/strict-provenance/function.rs index 29758036a21..789a78c15b4 100644 --- a/tests/ui/codegen/equal-pointers-unequal/strict-provenance/function.rs +++ b/tests/ui/codegen/equal-pointers-unequal/strict-provenance/function.rs @@ -4,8 +4,6 @@ // Based on https://github.com/rust-lang/rust/issues/107975#issuecomment-1434203908 -#![feature(strict_provenance)] - use std::ptr; fn f() -> usize { diff --git a/tests/ui/codegen/equal-pointers-unequal/strict-provenance/inline1.rs b/tests/ui/codegen/equal-pointers-unequal/strict-provenance/inline1.rs index 11925261a65..5f4ee731f7d 100644 --- a/tests/ui/codegen/equal-pointers-unequal/strict-provenance/inline1.rs +++ b/tests/ui/codegen/equal-pointers-unequal/strict-provenance/inline1.rs @@ -4,8 +4,6 @@ // Based on https://github.com/rust-lang/rust/issues/107975#issuecomment-1432161340 -#![feature(strict_provenance)] - use std::ptr; #[inline(never)] diff --git a/tests/ui/codegen/equal-pointers-unequal/strict-provenance/inline2.rs b/tests/ui/codegen/equal-pointers-unequal/strict-provenance/inline2.rs index e628bb90faa..0414879804a 100644 --- a/tests/ui/codegen/equal-pointers-unequal/strict-provenance/inline2.rs +++ b/tests/ui/codegen/equal-pointers-unequal/strict-provenance/inline2.rs @@ -4,8 +4,6 @@ // Based on https://github.com/rust-lang/rust/issues/107975#issuecomment-1432161340 -#![feature(strict_provenance)] - use std::ptr; #[inline(never)] diff --git a/tests/ui/codegen/equal-pointers-unequal/strict-provenance/print.rs b/tests/ui/codegen/equal-pointers-unequal/strict-provenance/print.rs index 075e3475a32..b7165ce1e5c 100644 --- a/tests/ui/codegen/equal-pointers-unequal/strict-provenance/print.rs +++ b/tests/ui/codegen/equal-pointers-unequal/strict-provenance/print.rs @@ -4,8 +4,6 @@ // https://github.com/rust-lang/rust/issues/107975#issuecomment-1430704499 -#![feature(strict_provenance)] - use std::ptr; fn main() { diff --git a/tests/ui/codegen/equal-pointers-unequal/strict-provenance/print3.rs b/tests/ui/codegen/equal-pointers-unequal/strict-provenance/print3.rs index 6d7b6fa33e0..a02ff30918d 100644 --- a/tests/ui/codegen/equal-pointers-unequal/strict-provenance/print3.rs +++ b/tests/ui/codegen/equal-pointers-unequal/strict-provenance/print3.rs @@ -4,8 +4,6 @@ // https://github.com/rust-lang/rust/issues/107975#issuecomment-1430704499 -#![feature(strict_provenance)] - use std::ptr; fn main() { diff --git a/tests/ui/codegen/equal-pointers-unequal/strict-provenance/segfault.rs b/tests/ui/codegen/equal-pointers-unequal/strict-provenance/segfault.rs index 67660d285a4..fea41e03612 100644 --- a/tests/ui/codegen/equal-pointers-unequal/strict-provenance/segfault.rs +++ b/tests/ui/codegen/equal-pointers-unequal/strict-provenance/segfault.rs @@ -4,8 +4,6 @@ // https://github.com/rust-lang/rust/issues/107975#issuecomment-1431758601 -#![feature(strict_provenance)] - use std::{ cell::{Ref, RefCell}, ptr, diff --git a/tests/ui/codegen/equal-pointers-unequal/strict-provenance/zero.rs b/tests/ui/codegen/equal-pointers-unequal/strict-provenance/zero.rs index a89310f9930..d963e45e4cd 100644 --- a/tests/ui/codegen/equal-pointers-unequal/strict-provenance/zero.rs +++ b/tests/ui/codegen/equal-pointers-unequal/strict-provenance/zero.rs @@ -4,8 +4,6 @@ // Derived from https://github.com/rust-lang/rust/issues/107975#issuecomment-1431758601 -#![feature(strict_provenance)] - use std::ptr; fn main() { diff --git a/tests/ui/feature-gates/feature-gate-strict_provenance.rs b/tests/ui/feature-gates/feature-gate-strict_provenance.rs deleted file mode 100644 index 738c8daa168..00000000000 --- a/tests/ui/feature-gates/feature-gate-strict_provenance.rs +++ /dev/null @@ -1,15 +0,0 @@ -//@ check-pass - -#![deny(fuzzy_provenance_casts)] -//~^ WARNING unknown lint: `fuzzy_provenance_casts` -#![deny(lossy_provenance_casts)] -//~^ WARNING unknown lint: `lossy_provenance_casts` - -fn main() { - // no warnings emitted since the lints are not activated - - let _dangling = 16_usize as *const u8; - - let x: u8 = 37; - let _addr: usize = &x as *const u8 as usize; -} diff --git a/tests/ui/feature-gates/feature-gate-strict_provenance.stderr b/tests/ui/feature-gates/feature-gate-strict_provenance.stderr deleted file mode 100644 index 82078d576ad..00000000000 --- a/tests/ui/feature-gates/feature-gate-strict_provenance.stderr +++ /dev/null @@ -1,25 +0,0 @@ -warning: unknown lint: `fuzzy_provenance_casts` - --> $DIR/feature-gate-strict_provenance.rs:3:1 - | -LL | #![deny(fuzzy_provenance_casts)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the `fuzzy_provenance_casts` lint is unstable - = note: see issue #95228 for more information - = help: add `#![feature(strict_provenance)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - = note: `#[warn(unknown_lints)]` on by default - -warning: unknown lint: `lossy_provenance_casts` - --> $DIR/feature-gate-strict_provenance.rs:5:1 - | -LL | #![deny(lossy_provenance_casts)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the `lossy_provenance_casts` lint is unstable - = note: see issue #95228 for more information - = help: add `#![feature(strict_provenance)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -warning: 2 warnings emitted - diff --git a/tests/ui/feature-gates/feature-gate-strict_provenance_lints.rs b/tests/ui/feature-gates/feature-gate-strict_provenance_lints.rs new file mode 100644 index 00000000000..738c8daa168 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-strict_provenance_lints.rs @@ -0,0 +1,15 @@ +//@ check-pass + +#![deny(fuzzy_provenance_casts)] +//~^ WARNING unknown lint: `fuzzy_provenance_casts` +#![deny(lossy_provenance_casts)] +//~^ WARNING unknown lint: `lossy_provenance_casts` + +fn main() { + // no warnings emitted since the lints are not activated + + let _dangling = 16_usize as *const u8; + + let x: u8 = 37; + let _addr: usize = &x as *const u8 as usize; +} diff --git a/tests/ui/feature-gates/feature-gate-strict_provenance_lints.stderr b/tests/ui/feature-gates/feature-gate-strict_provenance_lints.stderr new file mode 100644 index 00000000000..15428cbd4be --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-strict_provenance_lints.stderr @@ -0,0 +1,25 @@ +warning: unknown lint: `fuzzy_provenance_casts` + --> $DIR/feature-gate-strict_provenance_lints.rs:3:1 + | +LL | #![deny(fuzzy_provenance_casts)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `fuzzy_provenance_casts` lint is unstable + = note: see issue #130351 for more information + = help: add `#![feature(strict_provenance_lints)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + = note: `#[warn(unknown_lints)]` on by default + +warning: unknown lint: `lossy_provenance_casts` + --> $DIR/feature-gate-strict_provenance_lints.rs:5:1 + | +LL | #![deny(lossy_provenance_casts)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `lossy_provenance_casts` lint is unstable + = note: see issue #130351 for more information + = help: add `#![feature(strict_provenance_lints)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +warning: 2 warnings emitted + diff --git a/tests/ui/lint/lint-strict-provenance-fuzzy-casts.rs b/tests/ui/lint/lint-strict-provenance-fuzzy-casts.rs index d2d72a68f13..187209d4e20 100644 --- a/tests/ui/lint/lint-strict-provenance-fuzzy-casts.rs +++ b/tests/ui/lint/lint-strict-provenance-fuzzy-casts.rs @@ -1,4 +1,4 @@ -#![feature(strict_provenance)] +#![feature(strict_provenance_lints)] #![deny(fuzzy_provenance_casts)] fn main() { diff --git a/tests/ui/lint/lint-strict-provenance-lossy-casts.rs b/tests/ui/lint/lint-strict-provenance-lossy-casts.rs index 9799a053756..395dc75f825 100644 --- a/tests/ui/lint/lint-strict-provenance-lossy-casts.rs +++ b/tests/ui/lint/lint-strict-provenance-lossy-casts.rs @@ -1,4 +1,4 @@ -#![feature(strict_provenance)] +#![feature(strict_provenance_lints)] #![deny(lossy_provenance_casts)] fn main() { diff --git a/tests/ui/mir/alignment/i686-pc-windows-msvc.rs b/tests/ui/mir/alignment/i686-pc-windows-msvc.rs index 379f61ae818..c6b47a6d679 100644 --- a/tests/ui/mir/alignment/i686-pc-windows-msvc.rs +++ b/tests/ui/mir/alignment/i686-pc-windows-msvc.rs @@ -7,8 +7,6 @@ // 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 = x.as_mut_ptr(); diff --git a/tests/ui/mir/alignment/packed.rs b/tests/ui/mir/alignment/packed.rs index 1a12425f11a..cf908365e1a 100644 --- a/tests/ui/mir/alignment/packed.rs +++ b/tests/ui/mir/alignment/packed.rs @@ -1,8 +1,6 @@ //@ run-pass //@ compile-flags: -C debug-assertions -#![feature(strict_provenance)] - #[repr(packed)] struct Misaligner { _head: u8, diff --git a/tests/ui/structs-enums/type-sizes.rs b/tests/ui/structs-enums/type-sizes.rs index f49ce33841a..1961f10bd0a 100644 --- a/tests/ui/structs-enums/type-sizes.rs +++ b/tests/ui/structs-enums/type-sizes.rs @@ -5,7 +5,6 @@ #![allow(dead_code)] #![feature(never_type)] #![feature(pointer_is_aligned_to)] -#![feature(strict_provenance)] use std::mem::size_of; use std::num::NonZero; -- cgit 1.4.1-3-g733a5