From 645c0fddd2e0446cc0e6eecd8a78de4b5ab5a967 Mon Sep 17 00:00:00 2001 From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> Date: Fri, 30 Dec 2022 15:55:05 +0100 Subject: [PATCH 1/3] Put `noundef` on all scalars that don't allow uninit Previously, it was only put on scalars with range validity invariants like bool, was uninit was obviously invalid for those. Since then, we have normatively declared all uninit primitives to be undefined behavior and can therefore put `noundef` on them. The remaining concern was the `mem::uninitialized` function, which cause quite a lot of UB in the older parts of the ecosystem. This function now doesn't return uninit values anymore, making users of it safe from this change. The only real sources of UB where people could encounter uninit primitives are `MaybeUninit::uninit().assume_init()`, which has always be clear in the docs about being UB and from heap allocations (like reading from the spare capacity of a vec. This is hopefully rare enough to not break anything. --- compiler/rustc_codegen_llvm/src/builder.rs | 2 +- compiler/rustc_ty_utils/src/abi.rs | 2 +- tests/codegen/abi-sysv64.rs | 2 +- tests/codegen/abi-x86-interrupt.rs | 2 +- tests/codegen/adjustments.rs | 2 +- tests/codegen/box-maybe-uninit-llvm14.rs | 2 +- tests/codegen/box-maybe-uninit.rs | 2 +- tests/codegen/c-variadic.rs | 4 +- tests/codegen/call-llvm-intrinsics.rs | 2 +- tests/codegen/comparison-operators-newtype.rs | 8 +- tests/codegen/enum-match.rs | 6 +- tests/codegen/fastcall-inreg.rs | 12 +- tests/codegen/fewer-names.rs | 4 +- tests/codegen/frame-pointer.rs | 2 +- tests/codegen/function-arguments.rs | 30 ++-- tests/codegen/intrinsics/const_eval_select.rs | 2 +- tests/codegen/intrinsics/mask.rs | 2 +- tests/codegen/issue-32031.rs | 4 +- tests/codegen/issue-58881.rs | 2 +- tests/codegen/loads.rs | 6 +- tests/codegen/naked-functions.rs | 2 +- tests/codegen/pic-relocation-model.rs | 4 +- tests/codegen/pie-relocation-model.rs | 4 +- tests/codegen/refs.rs | 2 +- tests/codegen/repr-transparent.rs | 28 ++-- .../riscv-abi/riscv64-lp64-lp64f-lp64d-abi.rs | 18 +-- .../codegen/sanitizer-cfi-emit-type-checks.rs | 2 +- ...mit-kcfi-operand-bundle-itanium-cxx-abi.rs | 6 +- tests/codegen/sanitizer-recover.rs | 10 +- tests/codegen/scalar-pair-bool.rs | 4 +- .../some-abis-do-extend-params-to-32-bits.rs | 148 +++++++++--------- tests/codegen/transmute-scalar.rs | 10 +- tests/codegen/tuple-layout-opt.rs | 12 +- tests/codegen/var-names.rs | 2 +- tests/codegen/zst-offset.rs | 2 +- 35 files changed, 176 insertions(+), 176 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/builder.rs b/compiler/rustc_codegen_llvm/src/builder.rs index 5bf45a81e434..5e98deae48aa 100644 --- a/compiler/rustc_codegen_llvm/src/builder.rs +++ b/compiler/rustc_codegen_llvm/src/builder.rs @@ -501,7 +501,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { layout: TyAndLayout<'tcx>, offset: Size, ) { - if !scalar.is_always_valid(bx) { + if !scalar.is_uninit_valid() { bx.noundef_metadata(load); } diff --git a/compiler/rustc_ty_utils/src/abi.rs b/compiler/rustc_ty_utils/src/abi.rs index dc1dd1bfaf8e..ce50b6fb43f5 100644 --- a/compiler/rustc_ty_utils/src/abi.rs +++ b/compiler/rustc_ty_utils/src/abi.rs @@ -220,7 +220,7 @@ fn adjust_for_rust_scalar<'tcx>( } // Scalars which have invalid values cannot be undef. - if !scalar.is_always_valid(&cx) { + if !scalar.is_uninit_valid() { attrs.set(ArgAttribute::NoUndef); } diff --git a/tests/codegen/abi-sysv64.rs b/tests/codegen/abi-sysv64.rs index dfc312279083..e84c86b9ad04 100644 --- a/tests/codegen/abi-sysv64.rs +++ b/tests/codegen/abi-sysv64.rs @@ -15,7 +15,7 @@ trait Sized {} trait Copy {} impl Copy for i64 {} -// CHECK: define x86_64_sysvcc i64 @has_sysv64_abi +// CHECK: define x86_64_sysvcc noundef i64 @has_sysv64_abi #[no_mangle] pub extern "sysv64" fn has_sysv64_abi(a: i64) -> i64 { a diff --git a/tests/codegen/abi-x86-interrupt.rs b/tests/codegen/abi-x86-interrupt.rs index d612f603e4fe..94df1cb9f78b 100644 --- a/tests/codegen/abi-x86-interrupt.rs +++ b/tests/codegen/abi-x86-interrupt.rs @@ -15,7 +15,7 @@ trait Sized {} trait Copy {} impl Copy for i64 {} -// CHECK: define x86_intrcc i64 @has_x86_interrupt_abi +// CHECK: define x86_intrcc noundef i64 @has_x86_interrupt_abi #[no_mangle] pub extern "x86-interrupt" fn has_x86_interrupt_abi(a: i64) -> i64 { a diff --git a/tests/codegen/adjustments.rs b/tests/codegen/adjustments.rs index 39880c9341f4..d09bdfa09d29 100644 --- a/tests/codegen/adjustments.rs +++ b/tests/codegen/adjustments.rs @@ -3,7 +3,7 @@ #![crate_type = "lib"] // Hack to get the correct size for the length part in slices -// CHECK: @helper([[USIZE:i[0-9]+]] %_1) +// CHECK: @helper([[USIZE:i[0-9]+]] noundef %_1) #[no_mangle] pub fn helper(_: usize) { } diff --git a/tests/codegen/box-maybe-uninit-llvm14.rs b/tests/codegen/box-maybe-uninit-llvm14.rs index 7b5ae894311e..b0c88f76c436 100644 --- a/tests/codegen/box-maybe-uninit-llvm14.rs +++ b/tests/codegen/box-maybe-uninit-llvm14.rs @@ -31,4 +31,4 @@ pub fn box_uninitialized2() -> Box> { // Hide the LLVM 15+ `allocalign` attribute in the declaration of __rust_alloc // from the CHECK-NOT above. We don't check the attributes here because we can't rely // on all of them being set until LLVM 15. -// CHECK: declare noalias{{.*}} @__rust_alloc(i{{[0-9]+}}, i{{[0-9]+.*}}) +// CHECK: declare noalias{{.*}} @__rust_alloc(i{{[0-9]+}} noundef, i{{[0-9]+.*}} noundef) diff --git a/tests/codegen/box-maybe-uninit.rs b/tests/codegen/box-maybe-uninit.rs index c82b56a71f5c..2f88966996ab 100644 --- a/tests/codegen/box-maybe-uninit.rs +++ b/tests/codegen/box-maybe-uninit.rs @@ -28,6 +28,6 @@ pub fn box_uninitialized2() -> Box> { // Hide the `allocalign` attribute in the declaration of __rust_alloc // from the CHECK-NOT above, and also verify the attributes got set reasonably. -// CHECK: declare noalias ptr @__rust_alloc(i{{[0-9]+}}, i{{[0-9]+}} allocalign) unnamed_addr [[RUST_ALLOC_ATTRS:#[0-9]+]] +// CHECK: declare noalias noundef ptr @__rust_alloc(i{{[0-9]+}} noundef, i{{[0-9]+}} allocalign noundef) unnamed_addr [[RUST_ALLOC_ATTRS:#[0-9]+]] // CHECK-DAG: attributes [[RUST_ALLOC_ATTRS]] = { {{.*}} allockind("alloc,uninitialized,aligned") allocsize(0) uwtable "alloc-family"="__rust_alloc" {{.*}} } diff --git a/tests/codegen/c-variadic.rs b/tests/codegen/c-variadic.rs index a5be56c47be8..1f16550d3b60 100644 --- a/tests/codegen/c-variadic.rs +++ b/tests/codegen/c-variadic.rs @@ -15,7 +15,7 @@ extern "C" { pub unsafe extern "C" fn use_foreign_c_variadic_0() { // Ensure that we correctly call foreign C-variadic functions. - // CHECK: call void (i32, ...) @foreign_c_variadic_0([[PARAM:i32( signext)?]] 0) + // CHECK: call void (i32, ...) @foreign_c_variadic_0([[PARAM:i32 noundef( signext)?]] 0) foreign_c_variadic_0(0); // CHECK: call void (i32, ...) @foreign_c_variadic_0([[PARAM]] 0, [[PARAM]] 42) foreign_c_variadic_0(0, 42i32); @@ -61,7 +61,7 @@ pub unsafe extern "C" fn c_variadic(n: i32, mut ap: ...) -> i32 { // Ensure that we generate the correct `call` signature when calling a Rust // defined C-variadic. pub unsafe fn test_c_variadic_call() { - // CHECK: call [[RET:(signext )?i32]] (i32, ...) @c_variadic([[PARAM]] 0) + // CHECK: call [[RET:noundef( signext)? i32]] (i32, ...) @c_variadic([[PARAM]] 0) c_variadic(0); // CHECK: call [[RET]] (i32, ...) @c_variadic([[PARAM]] 0, [[PARAM]] 42) c_variadic(0, 42i32); diff --git a/tests/codegen/call-llvm-intrinsics.rs b/tests/codegen/call-llvm-intrinsics.rs index 998099c23909..8e0327f84b4a 100644 --- a/tests/codegen/call-llvm-intrinsics.rs +++ b/tests/codegen/call-llvm-intrinsics.rs @@ -23,7 +23,7 @@ pub fn do_call() { unsafe { // Ensure that we `call` LLVM intrinsics instead of trying to `invoke` them - // CHECK: call float @llvm.sqrt.f32(float 4.000000e+00 + // CHECK: call noundef float @llvm.sqrt.f32(float noundef 4.000000e+00 sqrt(4.0); } } diff --git a/tests/codegen/comparison-operators-newtype.rs b/tests/codegen/comparison-operators-newtype.rs index 5cf6c3ac0a23..683a2bd4fbb5 100644 --- a/tests/codegen/comparison-operators-newtype.rs +++ b/tests/codegen/comparison-operators-newtype.rs @@ -13,7 +13,7 @@ use std::cmp::Ordering; pub struct Foo(u16); // CHECK-LABEL: @check_lt -// CHECK-SAME: (i16 %[[A:.+]], i16 %[[B:.+]]) +// CHECK-SAME: (i16 noundef %[[A:.+]], i16 noundef %[[B:.+]]) #[no_mangle] pub fn check_lt(a: Foo, b: Foo) -> bool { // CHECK: %[[R:.+]] = icmp ult i16 %[[A]], %[[B]] @@ -22,7 +22,7 @@ pub fn check_lt(a: Foo, b: Foo) -> bool { } // CHECK-LABEL: @check_le -// CHECK-SAME: (i16 %[[A:.+]], i16 %[[B:.+]]) +// CHECK-SAME: (i16 noundef %[[A:.+]], i16 noundef %[[B:.+]]) #[no_mangle] pub fn check_le(a: Foo, b: Foo) -> bool { // CHECK: %[[R:.+]] = icmp ule i16 %[[A]], %[[B]] @@ -31,7 +31,7 @@ pub fn check_le(a: Foo, b: Foo) -> bool { } // CHECK-LABEL: @check_gt -// CHECK-SAME: (i16 %[[A:.+]], i16 %[[B:.+]]) +// CHECK-SAME: (i16 noundef %[[A:.+]], i16 noundef %[[B:.+]]) #[no_mangle] pub fn check_gt(a: Foo, b: Foo) -> bool { // CHECK: %[[R:.+]] = icmp ugt i16 %[[A]], %[[B]] @@ -40,7 +40,7 @@ pub fn check_gt(a: Foo, b: Foo) -> bool { } // CHECK-LABEL: @check_ge -// CHECK-SAME: (i16 %[[A:.+]], i16 %[[B:.+]]) +// CHECK-SAME: (i16 noundef %[[A:.+]], i16 noundef %[[B:.+]]) #[no_mangle] pub fn check_ge(a: Foo, b: Foo) -> bool { // CHECK: %[[R:.+]] = icmp uge i16 %[[A]], %[[B]] diff --git a/tests/codegen/enum-match.rs b/tests/codegen/enum-match.rs index 827eb20154af..5f8063a27f7a 100644 --- a/tests/codegen/enum-match.rs +++ b/tests/codegen/enum-match.rs @@ -11,7 +11,7 @@ pub enum Enum0 { B, } -// CHECK: define i8 @match0{{.*}} +// CHECK: define noundef i8 @match0{{.*}} // CHECK-NEXT: start: // CHECK-NEXT: %1 = icmp eq i8 %0, 2 // CHECK-NEXT: %2 = and i8 %0, 1 @@ -32,7 +32,7 @@ pub enum Enum1 { C, } -// CHECK: define i8 @match1{{.*}} +// CHECK: define noundef i8 @match1{{.*}} // CHECK-NEXT: start: // CHECK-NEXT: [[DISCR:%.*]] = {{.*}}call i8 @llvm.usub.sat.i8(i8 %0, i8 1) // CHECK-NEXT: switch i8 [[DISCR]], label {{.*}} [ @@ -88,7 +88,7 @@ pub enum Enum2 { E, } -// CHECK: define i8 @match2{{.*}} +// CHECK: define noundef i8 @match2{{.*}} // CHECK-NEXT: start: // CHECK-NEXT: %1 = add i8 %0, 2 // CHECK-NEXT: %2 = zext i8 %1 to i64 diff --git a/tests/codegen/fastcall-inreg.rs b/tests/codegen/fastcall-inreg.rs index d426ade28dd1..02f5d545910e 100644 --- a/tests/codegen/fastcall-inreg.rs +++ b/tests/codegen/fastcall-inreg.rs @@ -15,27 +15,27 @@ trait Sized {} trait Copy {} pub mod tests { - // CHECK: @f1(i32 inreg %_1, i32 inreg %_2, i32 %_3) + // CHECK: @f1(i32 inreg noundef %_1, i32 inreg noundef %_2, i32 noundef %_3) #[no_mangle] pub extern "fastcall" fn f1(_: i32, _: i32, _: i32) {} - // CHECK: @f2({{i32\*|ptr}} inreg %_1, {{i32\*|ptr}} inreg %_2, {{i32\*|ptr}} %_3) + // CHECK: @f2({{i32\*|ptr}} inreg noundef %_1, {{i32\*|ptr}} inreg noundef %_2, {{i32\*|ptr}} noundef %_3) #[no_mangle] pub extern "fastcall" fn f2(_: *const i32, _: *const i32, _: *const i32) {} - // CHECK: @f3(float %_1, i32 inreg %_2, i32 inreg %_3, i32 %_4) + // CHECK: @f3(float noundef %_1, i32 inreg noundef %_2, i32 inreg noundef %_3, i32 noundef %_4) #[no_mangle] pub extern "fastcall" fn f3(_: f32, _: i32, _: i32, _: i32) {} - // CHECK: @f4(i32 inreg %_1, float %_2, i32 inreg %_3, i32 %_4) + // CHECK: @f4(i32 inreg noundef %_1, float noundef %_2, i32 inreg noundef %_3, i32 noundef %_4) #[no_mangle] pub extern "fastcall" fn f4(_: i32, _: f32, _: i32, _: i32) {} - // CHECK: @f5(i64 %_1, i32 %_2) + // CHECK: @f5(i64 noundef %_1, i32 noundef %_2) #[no_mangle] pub extern "fastcall" fn f5(_: i64, _: i32) {} - // CHECK: @f6(i1 inreg noundef zeroext %_1, i32 inreg %_2, i32 %_3) + // CHECK: @f6(i1 inreg noundef zeroext %_1, i32 inreg noundef %_2, i32 noundef %_3) #[no_mangle] pub extern "fastcall" fn f6(_: bool, _: i32, _: i32) {} } diff --git a/tests/codegen/fewer-names.rs b/tests/codegen/fewer-names.rs index 7307e0379dfa..ac8cba06b48f 100644 --- a/tests/codegen/fewer-names.rs +++ b/tests/codegen/fewer-names.rs @@ -7,11 +7,11 @@ #[no_mangle] pub fn sum(x: u32, y: u32) -> u32 { -// YES-LABEL: define{{.*}}i32 @sum(i32 %0, i32 %1) +// YES-LABEL: define{{.*}}i32 @sum(i32 noundef %0, i32 noundef %1) // YES-NEXT: %3 = add i32 %1, %0 // YES-NEXT: ret i32 %3 -// NO-LABEL: define{{.*}}i32 @sum(i32 %x, i32 %y) +// NO-LABEL: define{{.*}}i32 @sum(i32 noundef %x, i32 noundef %y) // NO-NEXT: start: // NO-NEXT: %z = add i32 %y, %x // NO-NEXT: ret i32 %z diff --git a/tests/codegen/frame-pointer.rs b/tests/codegen/frame-pointer.rs index f7c02d47939f..da7f2ec80460 100644 --- a/tests/codegen/frame-pointer.rs +++ b/tests/codegen/frame-pointer.rs @@ -20,7 +20,7 @@ trait Copy { } impl Copy for u32 {} -// CHECK: define i32 @peach{{.*}}[[PEACH_ATTRS:\#[0-9]+]] { +// CHECK: define noundef i32 @peach{{.*}}[[PEACH_ATTRS:\#[0-9]+]] { #[no_mangle] pub fn peach(x: u32) -> u32 { x diff --git a/tests/codegen/function-arguments.rs b/tests/codegen/function-arguments.rs index 0f9e90f6ba77..20519978a0d1 100644 --- a/tests/codegen/function-arguments.rs +++ b/tests/codegen/function-arguments.rs @@ -61,7 +61,7 @@ pub fn maybeuninit_char(x: MaybeUninit) -> MaybeUninit { x } -// CHECK: i64 @int(i64 %x) +// CHECK: noundef i64 @int(i64 noundef %x) #[no_mangle] pub fn int(x: u64) -> u64 { x @@ -73,7 +73,7 @@ pub fn nonzero_int(x: NonZeroU64) -> NonZeroU64 { x } -// CHECK: i64 @option_nonzero_int(i64 %x) +// CHECK: noundef i64 @option_nonzero_int(i64 noundef %x) #[no_mangle] pub fn option_nonzero_int(x: Option) -> Option { x @@ -138,7 +138,7 @@ pub fn indirect_struct(_: S) { pub fn borrowed_struct(_: &S) { } -// CHECK: @raw_struct({{%S\*|ptr}} %_1) +// CHECK: @raw_struct({{%S\*|ptr}} noundef %_1) #[no_mangle] pub fn raw_struct(_: *const S) { } @@ -160,35 +160,35 @@ pub fn struct_return() -> S { } // Hack to get the correct size for the length part in slices -// CHECK: @helper([[USIZE:i[0-9]+]] %_1) +// CHECK: @helper([[USIZE:i[0-9]+]] noundef %_1) #[no_mangle] pub fn helper(_: usize) { } -// CHECK: @slice({{\[0 x i8\]\*|ptr}} noalias noundef nonnull readonly align 1 %_1.0, [[USIZE]] %_1.1) +// CHECK: @slice({{\[0 x i8\]\*|ptr}} noalias noundef nonnull readonly align 1 %_1.0, [[USIZE]] noundef %_1.1) // FIXME #25759 This should also have `nocapture` #[no_mangle] pub fn slice(_: &[u8]) { } -// CHECK: @mutable_slice({{\[0 x i8\]\*|ptr}} noalias noundef nonnull align 1 %_1.0, [[USIZE]] %_1.1) +// CHECK: @mutable_slice({{\[0 x i8\]\*|ptr}} noalias noundef nonnull align 1 %_1.0, [[USIZE]] noundef %_1.1) // FIXME #25759 This should also have `nocapture` #[no_mangle] pub fn mutable_slice(_: &mut [u8]) { } -// CHECK: @unsafe_slice({{\[0 x i16\]\*|ptr}} noundef nonnull align 2 %_1.0, [[USIZE]] %_1.1) +// CHECK: @unsafe_slice({{\[0 x i16\]\*|ptr}} noundef nonnull align 2 %_1.0, [[USIZE]] noundef %_1.1) // unsafe interior means this isn't actually readonly and there may be aliases ... #[no_mangle] pub fn unsafe_slice(_: &[UnsafeInner]) { } -// CHECK: @raw_slice({{\[0 x i8\]\*|ptr}} %_1.0, [[USIZE]] %_1.1) +// CHECK: @raw_slice({{\[0 x i8\]\*|ptr}} noundef %_1.0, [[USIZE]] noundef %_1.1) #[no_mangle] pub fn raw_slice(_: *const [u8]) { } -// CHECK: @str({{\[0 x i8\]\*|ptr}} noalias noundef nonnull readonly align 1 %_1.0, [[USIZE]] %_1.1) +// CHECK: @str({{\[0 x i8\]\*|ptr}} noalias noundef nonnull readonly align 1 %_1.0, [[USIZE]] noundef %_1.1) // FIXME #25759 This should also have `nocapture` #[no_mangle] pub fn str(_: &[u8]) { @@ -197,26 +197,26 @@ pub fn str(_: &[u8]) { // CHECK: @trait_borrow({{\{\}\*|ptr}} noundef nonnull align 1 %_1.0, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}) %_1.1) // FIXME #25759 This should also have `nocapture` #[no_mangle] -pub fn trait_borrow(_: &Drop) { +pub fn trait_borrow(_: &dyn Drop) { } -// CHECK: @trait_raw({{\{\}\*|ptr}} %_1.0, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}) %_1.1) +// CHECK: @trait_raw({{\{\}\*|ptr}} noundef %_1.0, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}) %_1.1) #[no_mangle] -pub fn trait_raw(_: *const Drop) { +pub fn trait_raw(_: *const dyn Drop) { } // CHECK: @trait_box({{\{\}\*|ptr}} noalias noundef nonnull align 1{{( %0)?}}, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}){{( %1)?}}) #[no_mangle] -pub fn trait_box(_: Box) { +pub fn trait_box(_: Box) { } // CHECK: { {{i8\*|ptr}}, {{i8\*|ptr}} } @trait_option({{i8\*|ptr}} noalias noundef align 1 %x.0, {{i8\*|ptr}} %x.1) #[no_mangle] -pub fn trait_option(x: Option>) -> Option> { +pub fn trait_option(x: Option>) -> Option> { x } -// CHECK: { {{\[0 x i16\]\*|ptr}}, [[USIZE]] } @return_slice({{\[0 x i16\]\*|ptr}} noalias noundef nonnull readonly align 2 %x.0, [[USIZE]] %x.1) +// CHECK: { {{\[0 x i16\]\*|ptr}}, [[USIZE]] } @return_slice({{\[0 x i16\]\*|ptr}} noalias noundef nonnull readonly align 2 %x.0, [[USIZE]] noundef %x.1) #[no_mangle] pub fn return_slice(x: &[u16]) -> &[u16] { x diff --git a/tests/codegen/intrinsics/const_eval_select.rs b/tests/codegen/intrinsics/const_eval_select.rs index db8a04763d35..424157158f6c 100644 --- a/tests/codegen/intrinsics/const_eval_select.rs +++ b/tests/codegen/intrinsics/const_eval_select.rs @@ -13,6 +13,6 @@ pub fn hi(n: i32) -> i32 { n } #[no_mangle] pub unsafe fn hey() { - // CHECK: call i32 @hi(i32 + // CHECK: call noundef i32 @hi(i32 const_eval_select((42,), foo, hi); } diff --git a/tests/codegen/intrinsics/mask.rs b/tests/codegen/intrinsics/mask.rs index 2e984db1be52..c7a2e4ba06dd 100644 --- a/tests/codegen/intrinsics/mask.rs +++ b/tests/codegen/intrinsics/mask.rs @@ -2,7 +2,7 @@ #![feature(core_intrinsics)] // CHECK-LABEL: @mask_ptr -// CHECK-SAME: [[WORD:i[0-9]+]] %mask +// CHECK-SAME: [[WORD:i[0-9]+]] noundef %mask #[no_mangle] pub fn mask_ptr(ptr: *const u16, mask: usize) -> *const u16 { // CHECK: call diff --git a/tests/codegen/issue-32031.rs b/tests/codegen/issue-32031.rs index 82ba325572ab..b181079785cf 100644 --- a/tests/codegen/issue-32031.rs +++ b/tests/codegen/issue-32031.rs @@ -5,7 +5,7 @@ #[no_mangle] pub struct F32(f32); -// CHECK: define{{.*}}float @add_newtype_f32(float %a, float %b) +// CHECK: define{{.*}}float @add_newtype_f32(float noundef %a, float noundef %b) #[inline(never)] #[no_mangle] pub fn add_newtype_f32(a: F32, b: F32) -> F32 { @@ -15,7 +15,7 @@ pub fn add_newtype_f32(a: F32, b: F32) -> F32 { #[no_mangle] pub struct F64(f64); -// CHECK: define{{.*}}double @add_newtype_f64(double %a, double %b) +// CHECK: define{{.*}}double @add_newtype_f64(double noundef %a, double noundef %b) #[inline(never)] #[no_mangle] pub fn add_newtype_f64(a: F64, b: F64) -> F64 { diff --git a/tests/codegen/issue-58881.rs b/tests/codegen/issue-58881.rs index 0900a33377bc..9349b78f9620 100644 --- a/tests/codegen/issue-58881.rs +++ b/tests/codegen/issue-58881.rs @@ -16,6 +16,6 @@ struct Bar(u64, u64, u64); // Ensure that emit arguments of the correct type. pub unsafe fn test_call_variadic() { - // CHECK: call void (i32, ...) @variadic_fn(i32 0, i8 {{.*}}, {{%Bar\*|ptr}} {{.*}}) + // CHECK: call void (i32, ...) @variadic_fn(i32 noundef 0, i8 {{.*}}, {{%Bar\*|ptr}} {{.*}}) variadic_fn(0, Foo(0), Bar(0, 0, 0)) } diff --git a/tests/codegen/loads.rs b/tests/codegen/loads.rs index f448306ba1b0..c97281970925 100644 --- a/tests/codegen/loads.rs +++ b/tests/codegen/loads.rs @@ -51,7 +51,7 @@ pub fn load_scalar_pair<'a>(x: &(&'a i32, &'a Align16)) -> (&'a i32, &'a Align16 #[no_mangle] pub fn load_raw_pointer<'a>(x: &*const i32) -> *const i32 { // loaded raw pointer should not have !nonnull, !align, or !noundef metadata - // CHECK: load {{i32\*|ptr}}, {{i32\*\*|ptr}} %x, align [[PTR_ALIGNMENT]]{{$}} + // CHECK: load {{i32\*|ptr}}, {{i32\*\*|ptr}} %x, align [[PTR_ALIGNMENT]], !noundef !2{{$}} *x } @@ -93,7 +93,7 @@ pub fn load_maybeuninit_enum_bool(x: &MaybeUninit) -> MaybeUninit u16 { - // CHECK: load i16, {{i16\*|ptr}} %x, align 2{{$}} + // CHECK: load i16, {{i16\*|ptr}} %x, align 2, !noundef !2{{$}} *x } @@ -107,7 +107,7 @@ pub fn load_nonzero_int(x: &NonZeroU16) -> NonZeroU16 { // CHECK-LABEL: @load_option_nonzero_int #[no_mangle] pub fn load_option_nonzero_int(x: &Option) -> Option { - // CHECK: load i16, {{i16\*|ptr}} %x, align 2{{$}} + // CHECK: load i16, {{i16\*|ptr}} %x, align 2, !noundef !2{{$}} *x } diff --git a/tests/codegen/naked-functions.rs b/tests/codegen/naked-functions.rs index 51c7a0c615d0..725c0a67a006 100644 --- a/tests/codegen/naked-functions.rs +++ b/tests/codegen/naked-functions.rs @@ -19,7 +19,7 @@ pub unsafe extern "C" fn naked_empty() { } // CHECK: Function Attrs: naked -// CHECK-NEXT: define{{.*}}i{{[0-9]+}} @naked_with_args_and_return(i64 %a, i64 %b) +// CHECK-NEXT: define{{.*}}i{{[0-9]+}} @naked_with_args_and_return(i64 noundef %a, i64 noundef %b) #[no_mangle] #[naked] pub unsafe extern "C" fn naked_with_args_and_return(a: isize, b: isize) -> isize { diff --git a/tests/codegen/pic-relocation-model.rs b/tests/codegen/pic-relocation-model.rs index 602a08067bae..7b4f0d9bae5d 100644 --- a/tests/codegen/pic-relocation-model.rs +++ b/tests/codegen/pic-relocation-model.rs @@ -2,7 +2,7 @@ #![crate_type = "rlib"] -// CHECK: define i8 @call_foreign_fn() +// CHECK: define noundef i8 @call_foreign_fn() #[no_mangle] pub fn call_foreign_fn() -> u8 { unsafe { @@ -13,7 +13,7 @@ pub fn call_foreign_fn() -> u8 { // (Allow but do not require `zeroext` here, because it is not worth effort to // spell out which targets have it and which ones do not; see rust#97800.) -// CHECK: declare{{( zeroext)?}} i8 @foreign_fn() +// CHECK: declare noundef{{( zeroext)?}} i8 @foreign_fn() extern "C" {fn foreign_fn() -> u8;} // CHECK: !{i32 {{[78]}}, !"PIC Level", i32 2} diff --git a/tests/codegen/pie-relocation-model.rs b/tests/codegen/pie-relocation-model.rs index ec44edc06677..a59216c3eee5 100644 --- a/tests/codegen/pie-relocation-model.rs +++ b/tests/codegen/pie-relocation-model.rs @@ -5,7 +5,7 @@ // With PIE we know local functions cannot be interpositioned, we can mark them // as dso_local. -// CHECK: define dso_local i8 @call_foreign_fn() +// CHECK: define dso_local noundef i8 @call_foreign_fn() #[no_mangle] pub fn call_foreign_fn() -> u8 { unsafe { @@ -15,7 +15,7 @@ pub fn call_foreign_fn() -> u8 { // External functions are still marked as non-dso_local, since we don't know if the symbol // is defined in the binary or in the shared library. -// CHECK: declare zeroext i8 @foreign_fn() +// CHECK: declare noundef zeroext i8 @foreign_fn() extern "C" {fn foreign_fn() -> u8;} // CHECK: !{i32 {{[78]}}, !"PIC Level", i32 2} diff --git a/tests/codegen/refs.rs b/tests/codegen/refs.rs index 0b796754d1d8..579fd901ee66 100644 --- a/tests/codegen/refs.rs +++ b/tests/codegen/refs.rs @@ -3,7 +3,7 @@ #![crate_type = "lib"] // Hack to get the correct size for the length part in slices -// CHECK: @helper([[USIZE:i[0-9]+]] %_1) +// CHECK: @helper([[USIZE:i[0-9]+]] noundef %_1) #[no_mangle] pub fn helper(_: usize) { } diff --git a/tests/codegen/repr-transparent.rs b/tests/codegen/repr-transparent.rs index 4f2313ce47a9..311cbfbaa093 100644 --- a/tests/codegen/repr-transparent.rs +++ b/tests/codegen/repr-transparent.rs @@ -18,21 +18,21 @@ pub struct Zst2(()); #[repr(transparent)] pub struct F32(f32); -// CHECK: define{{.*}}float @test_F32(float %_1) +// CHECK: define{{.*}}float @test_F32(float noundef %_1) #[no_mangle] pub extern "C" fn test_F32(_: F32) -> F32 { loop {} } #[repr(transparent)] pub struct Ptr(*mut u8); -// CHECK: define{{.*}}{{i8\*|ptr}} @test_Ptr({{i8\*|ptr}} %_1) +// CHECK: define{{.*}}{{i8\*|ptr}} @test_Ptr({{i8\*|ptr}} noundef %_1) #[no_mangle] pub extern "C" fn test_Ptr(_: Ptr) -> Ptr { loop {} } #[repr(transparent)] pub struct WithZst(u64, Zst1); -// CHECK: define{{.*}}i64 @test_WithZst(i64 %_1) +// CHECK: define{{.*}}i64 @test_WithZst(i64 noundef %_1) #[no_mangle] pub extern "C" fn test_WithZst(_: WithZst) -> WithZst { loop {} } @@ -40,14 +40,14 @@ pub extern "C" fn test_WithZst(_: WithZst) -> WithZst { loop {} } pub struct WithZeroSizedArray(*const f32, [i8; 0]); // Apparently we use i32* when newtype-unwrapping f32 pointers. Whatever. -// CHECK: define{{.*}}{{i32\*|ptr}} @test_WithZeroSizedArray({{i32\*|ptr}} %_1) +// CHECK: define{{.*}}{{i32\*|ptr}} @test_WithZeroSizedArray({{i32\*|ptr}} noundef %_1) #[no_mangle] pub extern "C" fn test_WithZeroSizedArray(_: WithZeroSizedArray) -> WithZeroSizedArray { loop {} } #[repr(transparent)] pub struct Generic(T); -// CHECK: define{{.*}}double @test_Generic(double %_1) +// CHECK: define{{.*}}double @test_Generic(double noundef %_1) #[no_mangle] pub extern "C" fn test_Generic(_: Generic) -> Generic { loop {} } @@ -64,7 +64,7 @@ pub extern "C" fn test_Gpz(_: GenericPlusZst) -> GenericPlusZst { lo #[repr(transparent)] pub struct LifetimePhantom<'a, T: 'a>(*const T, PhantomData<&'a T>); -// CHECK: define{{.*}}{{i16\*|ptr}} @test_LifetimePhantom({{i16\*|ptr}} %_1) +// CHECK: define{{.*}}{{i16\*|ptr}} @test_LifetimePhantom({{i16\*|ptr}} noundef %_1) #[no_mangle] pub extern "C" fn test_LifetimePhantom(_: LifetimePhantom) -> LifetimePhantom { loop {} } @@ -74,28 +74,28 @@ pub struct UnitPhantom { val: T, unit: PhantomData } pub struct Px; -// CHECK: define{{.*}}float @test_UnitPhantom(float %_1) +// CHECK: define{{.*}}float @test_UnitPhantom(float noundef %_1) #[no_mangle] pub extern "C" fn test_UnitPhantom(_: UnitPhantom) -> UnitPhantom { loop {} } #[repr(transparent)] pub struct TwoZsts(Zst1, i8, Zst2); -// CHECK: define{{( dso_local)?}}{{( signext)?}} i8 @test_TwoZsts(i8{{( signext)?}} %_1) +// CHECK: define{{( dso_local)?}} noundef{{( signext)?}} i8 @test_TwoZsts(i8 noundef{{( signext)?}} %_1) #[no_mangle] pub extern "C" fn test_TwoZsts(_: TwoZsts) -> TwoZsts { loop {} } #[repr(transparent)] pub struct Nested1(Zst2, Generic); -// CHECK: define{{.*}}double @test_Nested1(double %_1) +// CHECK: define{{.*}}double @test_Nested1(double noundef %_1) #[no_mangle] pub extern "C" fn test_Nested1(_: Nested1) -> Nested1 { loop {} } #[repr(transparent)] pub struct Nested2(Nested1, Zst1); -// CHECK: define{{.*}}double @test_Nested2(double %_1) +// CHECK: define{{.*}}double @test_Nested2(double noundef %_1) #[no_mangle] pub extern "C" fn test_Nested2(_: Nested2) -> Nested2 { loop {} } @@ -115,7 +115,7 @@ impl Mirror for T { type It = Self; } #[repr(transparent)] pub struct StructWithProjection(::It); -// CHECK: define{{.*}}float @test_Projection(float %_1) +// CHECK: define{{.*}}float @test_Projection(float noundef %_1) #[no_mangle] pub extern "C" fn test_Projection(_: StructWithProjection) -> StructWithProjection { loop {} } @@ -124,7 +124,7 @@ pub enum EnumF32 { Variant(F32) } -// CHECK: define{{.*}}float @test_EnumF32(float %_1) +// CHECK: define{{.*}}float @test_EnumF32(float noundef %_1) #[no_mangle] pub extern "C" fn test_EnumF32(_: EnumF32) -> EnumF32 { loop {} } @@ -133,7 +133,7 @@ pub enum EnumF32WithZsts { Variant(Zst1, F32, Zst2) } -// CHECK: define{{.*}}float @test_EnumF32WithZsts(float %_1) +// CHECK: define{{.*}}float @test_EnumF32WithZsts(float noundef %_1) #[no_mangle] pub extern "C" fn test_EnumF32WithZsts(_: EnumF32WithZsts) -> EnumF32WithZsts { loop {} } @@ -142,7 +142,7 @@ pub union UnionF32 { field: F32, } -// CHECK: define{{.*}}float @test_UnionF32(float %_1) +// CHECK: define{{.*}} float @test_UnionF32(float %_1) #[no_mangle] pub extern "C" fn test_UnionF32(_: UnionF32) -> UnionF32 { loop {} } diff --git a/tests/codegen/riscv-abi/riscv64-lp64-lp64f-lp64d-abi.rs b/tests/codegen/riscv-abi/riscv64-lp64-lp64f-lp64d-abi.rs index 61c4b7b51af7..045f01985a57 100644 --- a/tests/codegen/riscv-abi/riscv64-lp64-lp64f-lp64d-abi.rs +++ b/tests/codegen/riscv-abi/riscv64-lp64-lp64f-lp64d-abi.rs @@ -29,25 +29,25 @@ pub extern "C" fn f_scalar_0(a: bool) -> bool { a } -// CHECK: define signext i8 @f_scalar_1(i8 signext %x) +// CHECK: define noundef signext i8 @f_scalar_1(i8 noundef signext %x) #[no_mangle] pub extern "C" fn f_scalar_1(x: i8) -> i8 { x } -// CHECK: define zeroext i8 @f_scalar_2(i8 zeroext %x) +// CHECK: define noundef zeroext i8 @f_scalar_2(i8 noundef zeroext %x) #[no_mangle] pub extern "C" fn f_scalar_2(x: u8) -> u8 { x } -// CHECK: define signext i32 @f_scalar_3(i32 signext %x) +// CHECK: define noundef signext i32 @f_scalar_3(i32 noundef signext %x) #[no_mangle] pub extern "C" fn f_scalar_3(x: i32) -> u32 { x as u32 } -// CHECK: define i64 @f_scalar_4(i64 %x) +// CHECK: define noundef i64 @f_scalar_4(i64 noundef %x) #[no_mangle] pub extern "C" fn f_scalar_4(x: i64) -> i64 { x @@ -132,13 +132,13 @@ pub struct Large { pub extern "C" fn f_agg_large(mut x: Large) { } -// CHECK: define void @f_agg_large_ret({{%Large\*|ptr}} {{.*}}sret{{.*}}, i32 signext %i, i8 signext %j) +// CHECK: define void @f_agg_large_ret({{%Large\*|ptr}} {{.*}}sret{{.*}}, i32 noundef signext %i, i8 noundef signext %j) #[no_mangle] pub extern "C" fn f_agg_large_ret(i: i32, j: i8) -> Large { Large { a: 1, b: 2, c: 3, d: 4 } } -// CHECK: define void @f_scalar_stack_1(i64 %0, [2 x i64] %1, i128 %2, {{%Large\*|ptr}} {{.*}}%d, i8 zeroext %e, i8 signext %f, i8 %g, i8 %h) +// CHECK: define void @f_scalar_stack_1(i64 %0, [2 x i64] %1, i128 %2, {{%Large\*|ptr}} {{.*}}%d, i8 noundef zeroext %e, i8 noundef signext %f, i8 noundef %g, i8 noundef %h) #[no_mangle] pub extern "C" fn f_scalar_stack_1( a: Tiny, @@ -152,7 +152,7 @@ pub extern "C" fn f_scalar_stack_1( ) { } -// CHECK: define void @f_scalar_stack_2({{%Large\*|ptr}} {{.*}}sret{{.*}} %0, i64 %a, i128 %1, i128 %2, i64 %d, i8 zeroext %e, i8 %f, i8 %g) +// CHECK: define void @f_scalar_stack_2({{%Large\*|ptr}} {{.*}}sret{{.*}} %0, i64 noundef %a, i128 %1, i128 %2, i64 noundef %d, i8 noundef zeroext %e, i8 noundef %f, i8 noundef %g) #[no_mangle] pub extern "C" fn f_scalar_stack_2( a: u64, @@ -172,7 +172,7 @@ extern "C" { #[no_mangle] pub unsafe extern "C" fn f_va_caller() { - // CHECK: call signext i32 (i32, ...) @f_va_callee(i32 signext 1, i32 signext 2, i64 3, double {{.*}}, double {{.*}}, i64 {{.*}}, [2 x i64] {{.*}}, i128 {{.*}}, {{%Large\*|ptr}} {{.*}}) + // CHECK: call noundef signext i32 (i32, ...) @f_va_callee(i32 noundef signext 1, i32 noundef signext 2, i64 noundef 3, double {{.*}}, double {{.*}}, i64 {{.*}}, [2 x i64] {{.*}}, i128 {{.*}}, {{%Large\*|ptr}} {{.*}}) f_va_callee( 1, 2i32, @@ -184,6 +184,6 @@ pub unsafe extern "C" fn f_va_caller() { SmallAligned { a: 11 }, Large { a: 12, b: 13, c: 14, d: 15 }, ); - // CHECK: call signext i32 (i32, ...) @f_va_callee(i32 signext 1, i32 signext 2, i32 signext 3, i32 signext 4, i128 {{.*}}, i32 signext 6, i32 signext 7, i32 8, i32 9) + // CHECK: call noundef signext i32 (i32, ...) @f_va_callee(i32 noundef signext 1, i32 noundef signext 2, i32 noundef signext 3, i32 noundef signext 4, i128 {{.*}}, i32 noundef signext 6, i32 noundef signext 7, i32 noundef 8, i32 noundef 9) f_va_callee(1, 2i32, 3i32, 4i32, SmallAligned { a: 5 }, 6i32, 7i32, 8i32, 9i32); } diff --git a/tests/codegen/sanitizer-cfi-emit-type-checks.rs b/tests/codegen/sanitizer-cfi-emit-type-checks.rs index 8be5186de9e7..82334693d58e 100644 --- a/tests/codegen/sanitizer-cfi-emit-type-checks.rs +++ b/tests/codegen/sanitizer-cfi-emit-type-checks.rs @@ -11,7 +11,7 @@ pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { // CHECK: [[TT:%.+]] = call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"{{[[:print:]]+}}") // CHECK-NEXT: br i1 [[TT]], label %type_test.pass, label %type_test.fail // CHECK: type_test.pass: - // CHECK-NEXT: {{%.+}} = call i32 %f(i32 %arg) + // CHECK-NEXT: {{%.+}} = call noundef i32 %f(i32 noundef %arg) // CHECK-NEXT: br label %bb1 // CHECK: type_test.fail: // CHECK-NEXT: call void @llvm.trap() diff --git a/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi.rs b/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi.rs index 8e0d02550ee9..43e520bd6cfd 100644 --- a/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi.rs +++ b/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi.rs @@ -21,21 +21,21 @@ impl Copy for i32 {} pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { // CHECK-LABEL: define{{.*}}foo // CHECK-SAME: {{.*}}!{{|kcfi_type}} ![[TYPE1:[0-9]+]] - // CHECK: call i32 %f(i32 %arg){{.*}}[ "kcfi"(i32 -1666898348) ] + // CHECK: call noundef i32 %f(i32 noundef %arg){{.*}}[ "kcfi"(i32 -1666898348) ] f(arg) } pub fn bar(f: fn(i32, i32) -> i32, arg1: i32, arg2: i32) -> i32 { // CHECK-LABEL: define{{.*}}bar // CHECK-SAME: {{.*}}!{{|kcfi_type}} ![[TYPE2:[0-9]+]] - // CHECK: call i32 %f(i32 %arg1, i32 %arg2){{.*}}[ "kcfi"(i32 -1789026986) ] + // CHECK: call noundef i32 %f(i32 noundef %arg1, i32 noundef %arg2){{.*}}[ "kcfi"(i32 -1789026986) ] f(arg1, arg2) } pub fn baz(f: fn(i32, i32, i32) -> i32, arg1: i32, arg2: i32, arg3: i32) -> i32 { // CHECK-LABEL: define{{.*}}baz // CHECK-SAME: {{.*}}!{{|kcfi_type}} ![[TYPE3:[0-9]+]] - // CHECK: call i32 %f(i32 %arg1, i32 %arg2, i32 %arg3){{.*}}[ "kcfi"(i32 1248878270) ] + // CHECK: call noundef i32 %f(i32 noundef %arg1, i32 noundef %arg2, i32 noundef %arg3){{.*}}[ "kcfi"(i32 1248878270) ] f(arg1, arg2, arg3) } diff --git a/tests/codegen/sanitizer-recover.rs b/tests/codegen/sanitizer-recover.rs index 7ce0fa0a20fc..899c67be6ce5 100644 --- a/tests/codegen/sanitizer-recover.rs +++ b/tests/codegen/sanitizer-recover.rs @@ -16,27 +16,27 @@ // MSAN-RECOVER: @__msan_keep_going = weak_odr {{.*}}constant i32 1 // MSAN-RECOVER-LTO: @__msan_keep_going = weak_odr {{.*}}constant i32 1 -// ASAN-LABEL: define dso_local i32 @penguin( +// ASAN-LABEL: define dso_local noundef i32 @penguin( // ASAN: call void @__asan_report_load4(i64 %0) // ASAN: unreachable // ASAN: } // -// ASAN-RECOVER-LABEL: define dso_local i32 @penguin( +// ASAN-RECOVER-LABEL: define dso_local noundef i32 @penguin( // ASAN-RECOVER: call void @__asan_report_load4_noabort( // ASAN-RECOVER-NOT: unreachable // ASAN: } // -// MSAN-LABEL: define dso_local i32 @penguin( +// MSAN-LABEL: define dso_local noundef i32 @penguin( // MSAN: call void @__msan_warning{{(_with_origin_noreturn\(i32 0\)|_noreturn\(\))}} // MSAN: unreachable // MSAN: } // -// MSAN-RECOVER-LABEL: define dso_local i32 @penguin( +// MSAN-RECOVER-LABEL: define dso_local noundef i32 @penguin( // MSAN-RECOVER: call void @__msan_warning{{(_with_origin\(i32 0\)|\(\))}} // MSAN-RECOVER-NOT: unreachable // MSAN-RECOVER: } // -// MSAN-RECOVER-LTO-LABEL: define dso_local i32 @penguin( +// MSAN-RECOVER-LTO-LABEL: define dso_local noundef i32 @penguin( // MSAN-RECOVER-LTO: call void @__msan_warning{{(_with_origin\(i32 0\)|\(\))}} // MSAN-RECOVER-LTO-NOT: unreachable // MSAN-RECOVER-LTO: } diff --git a/tests/codegen/scalar-pair-bool.rs b/tests/codegen/scalar-pair-bool.rs index 264f28fdb5fe..8e8365b6a673 100644 --- a/tests/codegen/scalar-pair-bool.rs +++ b/tests/codegen/scalar-pair-bool.rs @@ -8,13 +8,13 @@ pub fn pair_bool_bool(pair: (bool, bool)) -> (bool, bool) { pair } -// CHECK: define{{.*}}{ i8, i32 } @pair_bool_i32(i1 noundef zeroext %pair.0, i32 %pair.1) +// CHECK: define{{.*}}{ i8, i32 } @pair_bool_i32(i1 noundef zeroext %pair.0, i32 noundef %pair.1) #[no_mangle] pub fn pair_bool_i32(pair: (bool, i32)) -> (bool, i32) { pair } -// CHECK: define{{.*}}{ i32, i8 } @pair_i32_bool(i32 %pair.0, i1 noundef zeroext %pair.1) +// CHECK: define{{.*}}{ i32, i8 } @pair_i32_bool(i32 noundef %pair.0, i1 noundef zeroext %pair.1) #[no_mangle] pub fn pair_i32_bool(pair: (i32, bool)) -> (i32, bool) { pair diff --git a/tests/codegen/some-abis-do-extend-params-to-32-bits.rs b/tests/codegen/some-abis-do-extend-params-to-32-bits.rs index 7fc34af3da72..86acbfba6a0f 100644 --- a/tests/codegen/some-abis-do-extend-params-to-32-bits.rs +++ b/tests/codegen/some-abis-do-extend-params-to-32-bits.rs @@ -31,85 +31,85 @@ // The patterns in this file are written in the style of a table to make the // uniformities and distinctions more apparent. // -// ZERO/SIGN-EXTENDING TO 32 BITS NON-EXTENDING -// ============================== ======================= -// x86_64: void @c_arg_u8(i8 zeroext %_a) -// i686: void @c_arg_u8(i8 zeroext %_a) -// aarch64-apple: void @c_arg_u8(i8 zeroext %_a) -// aarch64-windows: void @c_arg_u8(i8 %_a) -// aarch64-linux: void @c_arg_u8(i8 %_a) -// arm: void @c_arg_u8(i8 zeroext %_a) -// riscv: void @c_arg_u8(i8 zeroext %_a) +// ZERO/SIGN-EXTENDING TO 32 BITS NON-EXTENDING +// ====================================== =============================== +// x86_64: void @c_arg_u8(i8 noundef zeroext %_a) +// i686: void @c_arg_u8(i8 noundef zeroext %_a) +// aarch64-apple: void @c_arg_u8(i8 noundef zeroext %_a) +// aarch64-windows: void @c_arg_u8(i8 noundef %_a) +// aarch64-linux: void @c_arg_u8(i8 noundef %_a) +// arm: void @c_arg_u8(i8 noundef zeroext %_a) +// riscv: void @c_arg_u8(i8 noundef zeroext %_a) #[no_mangle] pub extern "C" fn c_arg_u8(_a: u8) { } -// x86_64: void @c_arg_u16(i16 zeroext %_a) -// i686: void @c_arg_u16(i16 zeroext %_a) -// aarch64-apple: void @c_arg_u16(i16 zeroext %_a) -// aarch64-windows: void @c_arg_u16(i16 %_a) -// aarch64-linux: void @c_arg_u16(i16 %_a) -// arm: void @c_arg_u16(i16 zeroext %_a) -// riscv: void @c_arg_u16(i16 zeroext %_a) +// x86_64: void @c_arg_u16(i16 noundef zeroext %_a) +// i686: void @c_arg_u16(i16 noundef zeroext %_a) +// aarch64-apple: void @c_arg_u16(i16 noundef zeroext %_a) +// aarch64-windows: void @c_arg_u16(i16 noundef %_a) +// aarch64-linux: void @c_arg_u16(i16 noundef %_a) +// arm: void @c_arg_u16(i16 noundef zeroext %_a) +// riscv: void @c_arg_u16(i16 noundef zeroext %_a) #[no_mangle] pub extern "C" fn c_arg_u16(_a: u16) { } -// x86_64: void @c_arg_u32(i32 %_a) -// i686: void @c_arg_u32(i32 %_a) -// aarch64-apple: void @c_arg_u32(i32 %_a) -// aarch64-windows: void @c_arg_u32(i32 %_a) -// aarch64-linux: void @c_arg_u32(i32 %_a) -// arm: void @c_arg_u32(i32 %_a) -// riscv: void @c_arg_u32(i32 signext %_a) +// x86_64: void @c_arg_u32(i32 noundef %_a) +// i686: void @c_arg_u32(i32 noundef %_a) +// aarch64-apple: void @c_arg_u32(i32 noundef %_a) +// aarch64-windows: void @c_arg_u32(i32 noundef %_a) +// aarch64-linux: void @c_arg_u32(i32 noundef %_a) +// arm: void @c_arg_u32(i32 noundef %_a) +// riscv: void @c_arg_u32(i32 noundef signext %_a) #[no_mangle] pub extern "C" fn c_arg_u32(_a: u32) { } -// x86_64: void @c_arg_u64(i64 %_a) -// i686: void @c_arg_u64(i64 %_a) -// aarch64-apple: void @c_arg_u64(i64 %_a) -// aarch64-windows: void @c_arg_u64(i64 %_a) -// aarch64-linux: void @c_arg_u64(i64 %_a) -// arm: void @c_arg_u64(i64 %_a) -// riscv: void @c_arg_u64(i64 %_a) +// x86_64: void @c_arg_u64(i64 noundef %_a) +// i686: void @c_arg_u64(i64 noundef %_a) +// aarch64-apple: void @c_arg_u64(i64 noundef %_a) +// aarch64-windows: void @c_arg_u64(i64 noundef %_a) +// aarch64-linux: void @c_arg_u64(i64 noundef %_a) +// arm: void @c_arg_u64(i64 noundef %_a) +// riscv: void @c_arg_u64(i64 noundef %_a) #[no_mangle] pub extern "C" fn c_arg_u64(_a: u64) { } -// x86_64: void @c_arg_i8(i8 signext %_a) -// i686: void @c_arg_i8(i8 signext %_a) -// aarch64-apple: void @c_arg_i8(i8 signext %_a) -// aarch64-windows: void @c_arg_i8(i8 %_a) -// aarch64-linux: void @c_arg_i8(i8 %_a) -// arm: void @c_arg_i8(i8 signext %_a) -// riscv: void @c_arg_i8(i8 signext %_a) +// x86_64: void @c_arg_i8(i8 noundef signext %_a) +// i686: void @c_arg_i8(i8 noundef signext %_a) +// aarch64-apple: void @c_arg_i8(i8 noundef signext %_a) +// aarch64-windows: void @c_arg_i8(i8 noundef %_a) +// aarch64-linux: void @c_arg_i8(i8 noundef %_a) +// arm: void @c_arg_i8(i8 noundef signext %_a) +// riscv: void @c_arg_i8(i8 noundef signext %_a) #[no_mangle] pub extern "C" fn c_arg_i8(_a: i8) { } -// x86_64: void @c_arg_i16(i16 signext %_a) -// i686: void @c_arg_i16(i16 signext %_a) -// aarch64-apple: void @c_arg_i16(i16 signext %_a) -// aarch64-windows: void @c_arg_i16(i16 %_a) -// aarch64-linux: void @c_arg_i16(i16 %_a) -// arm: void @c_arg_i16(i16 signext %_a) -// riscv: void @c_arg_i16(i16 signext %_a) +// x86_64: void @c_arg_i16(i16 noundef signext %_a) +// i686: void @c_arg_i16(i16 noundef signext %_a) +// aarch64-apple: void @c_arg_i16(i16 noundef signext %_a) +// aarch64-windows: void @c_arg_i16(i16 noundef %_a) +// aarch64-linux: void @c_arg_i16(i16 noundef %_a) +// arm: void @c_arg_i16(i16 noundef signext %_a) +// riscv: void @c_arg_i16(i16 noundef signext %_a) #[no_mangle] pub extern "C" fn c_arg_i16(_a: i16) { } -// x86_64: void @c_arg_i32(i32 %_a) -// i686: void @c_arg_i32(i32 %_a) -// aarch64-apple: void @c_arg_i32(i32 %_a) -// aarch64-windows: void @c_arg_i32(i32 %_a) -// aarch64-linux: void @c_arg_i32(i32 %_a) -// arm: void @c_arg_i32(i32 %_a) -// riscv: void @c_arg_i32(i32 signext %_a) +// x86_64: void @c_arg_i32(i32 noundef %_a) +// i686: void @c_arg_i32(i32 noundef %_a) +// aarch64-apple: void @c_arg_i32(i32 noundef %_a) +// aarch64-windows: void @c_arg_i32(i32 noundef %_a) +// aarch64-linux: void @c_arg_i32(i32 noundef %_a) +// arm: void @c_arg_i32(i32 noundef %_a) +// riscv: void @c_arg_i32(i32 noundef signext %_a) #[no_mangle] pub extern "C" fn c_arg_i32(_a: i32) { } -// x86_64: void @c_arg_i64(i64 %_a) -// i686: void @c_arg_i64(i64 %_a) -// aarch64-apple: void @c_arg_i64(i64 %_a) -// aarch64-windows: void @c_arg_i64(i64 %_a) -// aarch64-linux: void @c_arg_i64(i64 %_a) -// arm: void @c_arg_i64(i64 %_a) -// riscv: void @c_arg_i64(i64 %_a) +// x86_64: void @c_arg_i64(i64 noundef %_a) +// i686: void @c_arg_i64(i64 noundef %_a) +// aarch64-apple: void @c_arg_i64(i64 noundef %_a) +// aarch64-windows: void @c_arg_i64(i64 noundef %_a) +// aarch64-linux: void @c_arg_i64(i64 noundef %_a) +// arm: void @c_arg_i64(i64 noundef %_a) +// riscv: void @c_arg_i64(i64 noundef %_a) #[no_mangle] pub extern "C" fn c_arg_i64(_a: i64) { } // x86_64: zeroext i8 @c_ret_u8() // i686: zeroext i8 @c_ret_u8() // aarch64-apple: zeroext i8 @c_ret_u8() -// aarch64-windows: i8 @c_ret_u8() -// aarch64-linux: i8 @c_ret_u8() +// aarch64-windows: i8 @c_ret_u8() +// aarch64-linux: i8 @c_ret_u8() // arm: zeroext i8 @c_ret_u8() // riscv: zeroext i8 @c_ret_u8() #[no_mangle] pub extern "C" fn c_ret_u8() -> u8 { 0 } @@ -117,8 +117,8 @@ // x86_64: zeroext i16 @c_ret_u16() // i686: zeroext i16 @c_ret_u16() // aarch64-apple: zeroext i16 @c_ret_u16() -// aarch64-windows: i16 @c_ret_u16() -// aarch64-linux: i16 @c_ret_u16() +// aarch64-windows: i16 @c_ret_u16() +// aarch64-linux: i16 @c_ret_u16() // arm: zeroext i16 @c_ret_u16() // riscv: zeroext i16 @c_ret_u16() #[no_mangle] pub extern "C" fn c_ret_u16() -> u16 { 0 } @@ -126,8 +126,8 @@ // x86_64: i32 @c_ret_u32() // i686: i32 @c_ret_u32() // aarch64-apple: i32 @c_ret_u32() -// aarch64-windows: i32 @c_ret_u32() -// aarch64-linux: i32 @c_ret_u32() +// aarch64-windows: i32 @c_ret_u32() +// aarch64-linux: i32 @c_ret_u32() // arm: i32 @c_ret_u32() // riscv: signext i32 @c_ret_u32() #[no_mangle] pub extern "C" fn c_ret_u32() -> u32 { 0 } @@ -135,8 +135,8 @@ // x86_64: i64 @c_ret_u64() // i686: i64 @c_ret_u64() // aarch64-apple: i64 @c_ret_u64() -// aarch64-windows: i64 @c_ret_u64() -// aarch64-linux: i64 @c_ret_u64() +// aarch64-windows: i64 @c_ret_u64() +// aarch64-linux: i64 @c_ret_u64() // arm: i64 @c_ret_u64() // riscv: i64 @c_ret_u64() #[no_mangle] pub extern "C" fn c_ret_u64() -> u64 { 0 } @@ -144,8 +144,8 @@ // x86_64: signext i8 @c_ret_i8() // i686: signext i8 @c_ret_i8() // aarch64-apple: signext i8 @c_ret_i8() -// aarch64-windows: i8 @c_ret_i8() -// aarch64-linux: i8 @c_ret_i8() +// aarch64-windows: i8 @c_ret_i8() +// aarch64-linux: i8 @c_ret_i8() // arm: signext i8 @c_ret_i8() // riscv: signext i8 @c_ret_i8() #[no_mangle] pub extern "C" fn c_ret_i8() -> i8 { 0 } @@ -153,8 +153,8 @@ // x86_64: signext i16 @c_ret_i16() // i686: signext i16 @c_ret_i16() // aarch64-apple: signext i16 @c_ret_i16() -// aarch64-windows: i16 @c_ret_i16() -// aarch64-linux: i16 @c_ret_i16() +// aarch64-windows: i16 @c_ret_i16() +// aarch64-linux: i16 @c_ret_i16() // arm: signext i16 @c_ret_i16() // riscv: signext i16 @c_ret_i16() #[no_mangle] pub extern "C" fn c_ret_i16() -> i16 { 0 } @@ -162,8 +162,8 @@ // x86_64: i32 @c_ret_i32() // i686: i32 @c_ret_i32() // aarch64-apple: i32 @c_ret_i32() -// aarch64-windows: i32 @c_ret_i32() -// aarch64-linux: i32 @c_ret_i32() +// aarch64-windows: i32 @c_ret_i32() +// aarch64-linux: i32 @c_ret_i32() // arm: i32 @c_ret_i32() // riscv: signext i32 @c_ret_i32() #[no_mangle] pub extern "C" fn c_ret_i32() -> i32 { 0 } @@ -171,8 +171,8 @@ // x86_64: i64 @c_ret_i64() // i686: i64 @c_ret_i64() // aarch64-apple: i64 @c_ret_i64() -// aarch64-windows: i64 @c_ret_i64() -// aarch64-linux: i64 @c_ret_i64() +// aarch64-windows: i64 @c_ret_i64() +// aarch64-linux: i64 @c_ret_i64() // arm: i64 @c_ret_i64() // riscv: i64 @c_ret_i64() #[no_mangle] pub extern "C" fn c_ret_i64() -> i64 { 0 } diff --git a/tests/codegen/transmute-scalar.rs b/tests/codegen/transmute-scalar.rs index a7e5deeffd8e..260dcbac0fc4 100644 --- a/tests/codegen/transmute-scalar.rs +++ b/tests/codegen/transmute-scalar.rs @@ -5,7 +5,7 @@ // FIXME(eddyb) all of these tests show memory stores and loads, even after a // scalar `bitcast`, more special-casing is required to remove `alloca` usage. -// CHECK-LABEL: define{{.*}}i32 @f32_to_bits(float %x) +// CHECK-LABEL: define{{.*}}i32 @f32_to_bits(float noundef %x) // CHECK: store i32 %{{.*}}, {{.*}} %0 // CHECK-NEXT: %[[RES:.*]] = load i32, {{.*}} %0 // CHECK: ret i32 %[[RES]] @@ -24,7 +24,7 @@ pub fn bool_to_byte(b: bool) -> u8 { unsafe { std::mem::transmute(b) } } -// CHECK-LABEL: define{{.*}}noundef zeroext i1 @byte_to_bool(i8 %byte) +// CHECK-LABEL: define{{.*}}noundef zeroext i1 @byte_to_bool(i8 noundef %byte) // CHECK: %1 = trunc i8 %byte to i1 // CHECK-NEXT: %2 = zext i1 %1 to i8 // CHECK-NEXT: store i8 %2, {{.*}} %0 @@ -36,7 +36,7 @@ pub unsafe fn byte_to_bool(byte: u8) -> bool { std::mem::transmute(byte) } -// CHECK-LABEL: define{{.*}}{{i8\*|ptr}} @ptr_to_ptr({{i16\*|ptr}} %p) +// CHECK-LABEL: define{{.*}}{{i8\*|ptr}} @ptr_to_ptr({{i16\*|ptr}} noundef %p) // CHECK: store {{i8\*|ptr}} %{{.*}}, {{.*}} %0 // CHECK-NEXT: %[[RES:.*]] = load {{i8\*|ptr}}, {{.*}} %0 // CHECK: ret {{i8\*|ptr}} %[[RES]] @@ -52,7 +52,7 @@ pub fn ptr_to_ptr(p: *mut u16) -> *mut u8 { // Tests below show the non-special-cased behavior (with the possible // future special-cased instructions in the "NOTE(eddyb)" comments). -// CHECK: define{{.*}}[[USIZE:i[0-9]+]] @ptr_to_int({{i16\*|ptr}} %p) +// CHECK: define{{.*}}[[USIZE:i[0-9]+]] @ptr_to_int({{i16\*|ptr}} noundef %p) // NOTE(eddyb) see above, the following two CHECK lines should ideally be this: // %2 = ptrtoint i16* %p to [[USIZE]] @@ -66,7 +66,7 @@ pub fn ptr_to_int(p: *mut u16) -> usize { unsafe { std::mem::transmute(p) } } -// CHECK: define{{.*}}{{i16\*|ptr}} @int_to_ptr([[USIZE]] %i) +// CHECK: define{{.*}}{{i16\*|ptr}} @int_to_ptr([[USIZE]] noundef %i) // NOTE(eddyb) see above, the following two CHECK lines should ideally be this: // %2 = inttoptr [[USIZE]] %i to i16* diff --git a/tests/codegen/tuple-layout-opt.rs b/tests/codegen/tuple-layout-opt.rs index e86c75f3f482..ad33d6643c29 100644 --- a/tests/codegen/tuple-layout-opt.rs +++ b/tests/codegen/tuple-layout-opt.rs @@ -6,31 +6,31 @@ #![crate_type="lib"] type ScalarZstLast = (u128, ()); -// CHECK: define i128 @test_ScalarZstLast(i128 %_1) +// CHECK: define noundef i128 @test_ScalarZstLast(i128 noundef %_1) #[no_mangle] pub fn test_ScalarZstLast(_: ScalarZstLast) -> ScalarZstLast { loop {} } type ScalarZstFirst = ((), u128); -// CHECK: define i128 @test_ScalarZstFirst(i128 %_1) +// CHECK: define noundef i128 @test_ScalarZstFirst(i128 noundef %_1) #[no_mangle] pub fn test_ScalarZstFirst(_: ScalarZstFirst) -> ScalarZstFirst { loop {} } type ScalarPairZstLast = (u8, u128, ()); -// CHECK: define { i128, i8 } @test_ScalarPairZstLast(i128 %_1.0, i8 %_1.1) +// CHECK: define { i128, i8 } @test_ScalarPairZstLast(i128 noundef %_1.0, i8 noundef %_1.1) #[no_mangle] pub fn test_ScalarPairZstLast(_: ScalarPairZstLast) -> ScalarPairZstLast { loop {} } type ScalarPairZstFirst = ((), u8, u128); -// CHECK: define { i8, i128 } @test_ScalarPairZstFirst(i8 %_1.0, i128 %_1.1) +// CHECK: define { i8, i128 } @test_ScalarPairZstFirst(i8 noundef %_1.0, i128 noundef %_1.1) #[no_mangle] pub fn test_ScalarPairZstFirst(_: ScalarPairZstFirst) -> ScalarPairZstFirst { loop {} } type ScalarPairLotsOfZsts = ((), u8, (), u128, ()); -// CHECK: define { i128, i8 } @test_ScalarPairLotsOfZsts(i128 %_1.0, i8 %_1.1) +// CHECK: define { i128, i8 } @test_ScalarPairLotsOfZsts(i128 noundef %_1.0, i8 noundef %_1.1) #[no_mangle] pub fn test_ScalarPairLotsOfZsts(_: ScalarPairLotsOfZsts) -> ScalarPairLotsOfZsts { loop {} } type ScalarPairLottaNesting = (((), ((), u8, (), u128, ())), ()); -// CHECK: define { i128, i8 } @test_ScalarPairLottaNesting(i128 %_1.0, i8 %_1.1) +// CHECK: define { i128, i8 } @test_ScalarPairLottaNesting(i128 noundef %_1.0, i8 noundef %_1.1) #[no_mangle] pub fn test_ScalarPairLottaNesting(_: ScalarPairLottaNesting) -> ScalarPairLottaNesting { loop {} } diff --git a/tests/codegen/var-names.rs b/tests/codegen/var-names.rs index 8f1b038708e6..d4715efad73c 100644 --- a/tests/codegen/var-names.rs +++ b/tests/codegen/var-names.rs @@ -2,7 +2,7 @@ #![crate_type = "lib"] -// CHECK-LABEL: define{{.*}}i32 @test(i32 %a, i32 %b) +// CHECK-LABEL: define{{.*}}i32 @test(i32 noundef %a, i32 noundef %b) #[no_mangle] pub fn test(a: u32, b: u32) -> u32 { let c = a + b; diff --git a/tests/codegen/zst-offset.rs b/tests/codegen/zst-offset.rs index 844d5870a846..27e435e9cf04 100644 --- a/tests/codegen/zst-offset.rs +++ b/tests/codegen/zst-offset.rs @@ -4,7 +4,7 @@ #![feature(repr_simd)] // Hack to get the correct size for the length part in slices -// CHECK: @helper([[USIZE:i[0-9]+]] %_1) +// CHECK: @helper([[USIZE:i[0-9]+]] noundef %_1) #[no_mangle] pub fn helper(_: usize) { } From af23ad93cd3309e90ccb2c49b7a7b2ac913e0d06 Mon Sep 17 00:00:00 2001 From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> Date: Fri, 30 Dec 2022 21:11:17 +0100 Subject: [PATCH 2/3] Improve comments --- compiler/rustc_ty_utils/src/abi.rs | 6 ------ tests/codegen/loads.rs | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/compiler/rustc_ty_utils/src/abi.rs b/compiler/rustc_ty_utils/src/abi.rs index ce50b6fb43f5..669f84ae1b47 100644 --- a/compiler/rustc_ty_utils/src/abi.rs +++ b/compiler/rustc_ty_utils/src/abi.rs @@ -219,7 +219,6 @@ fn adjust_for_rust_scalar<'tcx>( return; } - // Scalars which have invalid values cannot be undef. if !scalar.is_uninit_valid() { attrs.set(ArgAttribute::NoUndef); } @@ -246,11 +245,6 @@ fn adjust_for_rust_scalar<'tcx>( PointerKind::SharedMutable | PointerKind::UniqueOwned => Size::ZERO, }; - // `Box`, `&T`, and `&mut T` cannot be undef. - // Note that this only applies to the value of the pointer itself; - // this attribute doesn't make it UB for the pointed-to data to be undef. - attrs.set(ArgAttribute::NoUndef); - // The aliasing rules for `Box` are still not decided, but currently we emit // `noalias` for it. This can be turned off using an unstable flag. // See https://github.com/rust-lang/unsafe-code-guidelines/issues/326 diff --git a/tests/codegen/loads.rs b/tests/codegen/loads.rs index c97281970925..7c3bf07cc811 100644 --- a/tests/codegen/loads.rs +++ b/tests/codegen/loads.rs @@ -50,7 +50,7 @@ pub fn load_scalar_pair<'a>(x: &(&'a i32, &'a Align16)) -> (&'a i32, &'a Align16 // CHECK-LABEL: @load_raw_pointer #[no_mangle] pub fn load_raw_pointer<'a>(x: &*const i32) -> *const i32 { - // loaded raw pointer should not have !nonnull, !align, or !noundef metadata + // loaded raw pointer should not have !nonnull or !align metadata // CHECK: load {{i32\*|ptr}}, {{i32\*\*|ptr}} %x, align [[PTR_ALIGNMENT]], !noundef !2{{$}} *x } From f1255380ac1cb7be1b6b0ac0eda5b1274b29eff6 Mon Sep 17 00:00:00 2001 From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> Date: Fri, 30 Dec 2022 21:11:30 +0100 Subject: [PATCH 3/3] Add more codegen tests --- tests/codegen/abi-sysv64.rs | 4 +- tests/codegen/abi-x86-interrupt.rs | 4 +- tests/codegen/adjustments.rs | 4 +- tests/codegen/c-variadic.rs | 6 +- tests/codegen/call-llvm-intrinsics.rs | 4 +- tests/codegen/dllimports/main.rs | 10 +- tests/codegen/frame-pointer.rs | 4 +- tests/codegen/function-arguments.rs | 28 +++- tests/codegen/intrinsics/const_eval_select.rs | 4 +- tests/codegen/intrinsics/mask.rs | 5 +- tests/codegen/issue-32031.rs | 6 +- tests/codegen/issue-58881.rs | 4 +- tests/codegen/iter-repeat-n-trivial-drop.rs | 2 +- tests/codegen/loads.rs | 6 +- tests/codegen/naked-functions.rs | 4 +- tests/codegen/pic-relocation-model.rs | 6 +- tests/codegen/pie-relocation-model.rs | 6 +- tests/codegen/refs.rs | 4 +- .../codegen/sanitizer-cfi-emit-type-checks.rs | 4 +- ...mit-kcfi-operand-bundle-itanium-cxx-abi.rs | 8 +- tests/codegen/sanitizer-recover.rs | 8 +- .../some-abis-do-extend-params-to-32-bits.rs | 150 +++++++++--------- tests/codegen/static-relocation-model-msvc.rs | 4 +- tests/codegen/tuple-layout-opt.rs | 14 +- tests/codegen/vec-calloc.rs | 2 +- tests/codegen/zst-offset.rs | 4 +- 26 files changed, 166 insertions(+), 139 deletions(-) diff --git a/tests/codegen/abi-sysv64.rs b/tests/codegen/abi-sysv64.rs index e84c86b9ad04..3c2d4e719d42 100644 --- a/tests/codegen/abi-sysv64.rs +++ b/tests/codegen/abi-sysv64.rs @@ -3,7 +3,7 @@ // of the sysv64 abi. // // needs-llvm-components: x86 -// compile-flags: -C no-prepopulate-passes --target=x86_64-unknown-linux-gnu +// compile-flags: -C no-prepopulate-passes --target=x86_64-unknown-linux-gnu -Copt-level=0 #![crate_type = "lib"] #![no_core] @@ -15,7 +15,7 @@ trait Sized {} trait Copy {} impl Copy for i64 {} -// CHECK: define x86_64_sysvcc noundef i64 @has_sysv64_abi +// CHECK: define x86_64_sysvcc i64 @has_sysv64_abi #[no_mangle] pub extern "sysv64" fn has_sysv64_abi(a: i64) -> i64 { a diff --git a/tests/codegen/abi-x86-interrupt.rs b/tests/codegen/abi-x86-interrupt.rs index 94df1cb9f78b..928ad5a9bbd6 100644 --- a/tests/codegen/abi-x86-interrupt.rs +++ b/tests/codegen/abi-x86-interrupt.rs @@ -3,7 +3,7 @@ // of the x86-interrupt abi. // needs-llvm-components: x86 -// compile-flags: -C no-prepopulate-passes --target=x86_64-unknown-linux-gnu +// compile-flags: -C no-prepopulate-passes --target=x86_64-unknown-linux-gnu -Copt-level=0 #![crate_type = "lib"] #![no_core] @@ -15,7 +15,7 @@ trait Sized {} trait Copy {} impl Copy for i64 {} -// CHECK: define x86_intrcc noundef i64 @has_x86_interrupt_abi +// CHECK: define x86_intrcc i64 @has_x86_interrupt_abi #[no_mangle] pub extern "x86-interrupt" fn has_x86_interrupt_abi(a: i64) -> i64 { a diff --git a/tests/codegen/adjustments.rs b/tests/codegen/adjustments.rs index d09bdfa09d29..6d2247517527 100644 --- a/tests/codegen/adjustments.rs +++ b/tests/codegen/adjustments.rs @@ -1,9 +1,9 @@ -// compile-flags: -C no-prepopulate-passes +// compile-flags: -C no-prepopulate-passes -Copt-level=0 #![crate_type = "lib"] // Hack to get the correct size for the length part in slices -// CHECK: @helper([[USIZE:i[0-9]+]] noundef %_1) +// CHECK: @helper([[USIZE:i[0-9]+]] %_1) #[no_mangle] pub fn helper(_: usize) { } diff --git a/tests/codegen/c-variadic.rs b/tests/codegen/c-variadic.rs index 1f16550d3b60..cab32652210d 100644 --- a/tests/codegen/c-variadic.rs +++ b/tests/codegen/c-variadic.rs @@ -1,5 +1,5 @@ // ignore-wasm32-bare compiled with panic=abort by default -// compile-flags: -C no-prepopulate-passes +// compile-flags: -C no-prepopulate-passes -Copt-level=0 // #![crate_type = "lib"] @@ -15,7 +15,7 @@ extern "C" { pub unsafe extern "C" fn use_foreign_c_variadic_0() { // Ensure that we correctly call foreign C-variadic functions. - // CHECK: call void (i32, ...) @foreign_c_variadic_0([[PARAM:i32 noundef( signext)?]] 0) + // CHECK: call void (i32, ...) @foreign_c_variadic_0([[PARAM:i32( signext)?]] 0) foreign_c_variadic_0(0); // CHECK: call void (i32, ...) @foreign_c_variadic_0([[PARAM]] 0, [[PARAM]] 42) foreign_c_variadic_0(0, 42i32); @@ -61,7 +61,7 @@ pub unsafe extern "C" fn c_variadic(n: i32, mut ap: ...) -> i32 { // Ensure that we generate the correct `call` signature when calling a Rust // defined C-variadic. pub unsafe fn test_c_variadic_call() { - // CHECK: call [[RET:noundef( signext)? i32]] (i32, ...) @c_variadic([[PARAM]] 0) + // CHECK: call [[RET:(signext )?i32]] (i32, ...) @c_variadic([[PARAM]] 0) c_variadic(0); // CHECK: call [[RET]] (i32, ...) @c_variadic([[PARAM]] 0, [[PARAM]] 42) c_variadic(0, 42i32); diff --git a/tests/codegen/call-llvm-intrinsics.rs b/tests/codegen/call-llvm-intrinsics.rs index 8e0327f84b4a..cb8abae198ee 100644 --- a/tests/codegen/call-llvm-intrinsics.rs +++ b/tests/codegen/call-llvm-intrinsics.rs @@ -1,4 +1,4 @@ -// compile-flags: -C no-prepopulate-passes +// compile-flags: -C no-prepopulate-passes -Copt-level=0 // ignore-riscv64 @@ -23,7 +23,7 @@ pub fn do_call() { unsafe { // Ensure that we `call` LLVM intrinsics instead of trying to `invoke` them - // CHECK: call noundef float @llvm.sqrt.f32(float noundef 4.000000e+00 + // CHECK: call float @llvm.sqrt.f32(float 4.000000e+00 sqrt(4.0); } } diff --git a/tests/codegen/dllimports/main.rs b/tests/codegen/dllimports/main.rs index ab599992ffd7..383940e95906 100644 --- a/tests/codegen/dllimports/main.rs +++ b/tests/codegen/dllimports/main.rs @@ -1,4 +1,4 @@ -// This test is for *-windows-msvc only. + // This test is for *-windows-msvc only. // only-windows // ignore-gnu @@ -15,10 +15,10 @@ extern crate wrapper; // CHECK: @static_global1 = external local_unnamed_addr global i32 // CHECK: @static_global2 = external local_unnamed_addr global i32 -// CHECK: declare dllimport i32 @dylib_func1(i32) -// CHECK: declare dllimport i32 @dylib_func2(i32) -// CHECK: declare i32 @static_func1(i32) -// CHECK: declare i32 @static_func2(i32) +// CHECK: declare dllimport noundef i32 @dylib_func1(i32 noundef) +// CHECK: declare dllimport noundef i32 @dylib_func2(i32 noundef) +// CHECK: declare noundef i32 @static_func1(i32 noundef) +// CHECK: declare noundef i32 @static_func2(i32 noundef) #[link(name = "dummy", kind="dylib")] extern "C" { diff --git a/tests/codegen/frame-pointer.rs b/tests/codegen/frame-pointer.rs index da7f2ec80460..d8933262e528 100644 --- a/tests/codegen/frame-pointer.rs +++ b/tests/codegen/frame-pointer.rs @@ -1,4 +1,4 @@ -// compile-flags: --crate-type=rlib +// compile-flags: --crate-type=rlib -Copt-level=0 // revisions: aarch64-apple aarch64-linux force x64-apple x64-linux // [aarch64-apple] needs-llvm-components: aarch64 // [aarch64-apple] compile-flags: --target=aarch64-apple-darwin @@ -20,7 +20,7 @@ trait Copy { } impl Copy for u32 {} -// CHECK: define noundef i32 @peach{{.*}}[[PEACH_ATTRS:\#[0-9]+]] { +// CHECK: define i32 @peach{{.*}}[[PEACH_ATTRS:\#[0-9]+]] { #[no_mangle] pub fn peach(x: u32) -> u32 { x diff --git a/tests/codegen/function-arguments.rs b/tests/codegen/function-arguments.rs index 20519978a0d1..1f979d7b90a7 100644 --- a/tests/codegen/function-arguments.rs +++ b/tests/codegen/function-arguments.rs @@ -1,11 +1,11 @@ // compile-flags: -O -C no-prepopulate-passes #![crate_type = "lib"] -#![feature(rustc_attrs)] use std::mem::MaybeUninit; use std::num::NonZeroU64; use std::marker::PhantomPinned; +use std::ptr::NonNull; pub struct S { _field: [i32; 8], @@ -138,11 +138,27 @@ pub fn indirect_struct(_: S) { pub fn borrowed_struct(_: &S) { } +// CHECK: @option_borrow({{i32\*|ptr}} noalias noundef readonly align 4 dereferenceable_or_null(4) %x) +#[no_mangle] +pub fn option_borrow(x: Option<&i32>) { +} + +// CHECK: @option_borrow_mut({{i32\*|ptr}} noalias noundef align 4 dereferenceable_or_null(4) %x) +#[no_mangle] +pub fn option_borrow_mut(x: Option<&mut i32>) { +} + // CHECK: @raw_struct({{%S\*|ptr}} noundef %_1) #[no_mangle] pub fn raw_struct(_: *const S) { } +// CHECK: @raw_option_nonnull_struct({{i32\*|ptr}} noundef %_1) +#[no_mangle] +pub fn raw_option_nonnull_struct(_: Option>) { +} + + // `Box` can get deallocated during execution of the function, so it should // not get `dereferenceable`. // CHECK: noundef nonnull align 4 {{i32\*|ptr}} @_box({{i32\*|ptr}} noalias noundef nonnull align 4 %x) @@ -200,6 +216,16 @@ pub fn str(_: &[u8]) { pub fn trait_borrow(_: &dyn Drop) { } +// CHECK: @option_trait_borrow({{i8\*|ptr}} noundef align 1 %x.0, {{i8\*|ptr}} %x.1) +#[no_mangle] +pub fn option_trait_borrow(x: Option<&dyn Drop>) { +} + +// CHECK: @option_trait_borrow_mut({{i8\*|ptr}} noundef align 1 %x.0, {{i8\*|ptr}} %x.1) +#[no_mangle] +pub fn option_trait_borrow_mut(x: Option<&mut dyn Drop>) { +} + // CHECK: @trait_raw({{\{\}\*|ptr}} noundef %_1.0, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}) %_1.1) #[no_mangle] pub fn trait_raw(_: *const dyn Drop) { diff --git a/tests/codegen/intrinsics/const_eval_select.rs b/tests/codegen/intrinsics/const_eval_select.rs index 424157158f6c..f3877dc6b96a 100644 --- a/tests/codegen/intrinsics/const_eval_select.rs +++ b/tests/codegen/intrinsics/const_eval_select.rs @@ -1,4 +1,4 @@ -// compile-flags: -C no-prepopulate-passes +// compile-flags: -C no-prepopulate-passes -Copt-level=0 #![crate_type = "lib"] #![feature(const_eval_select)] @@ -13,6 +13,6 @@ pub fn hi(n: i32) -> i32 { n } #[no_mangle] pub unsafe fn hey() { - // CHECK: call noundef i32 @hi(i32 + // CHECK: call i32 @hi(i32 const_eval_select((42,), foo, hi); } diff --git a/tests/codegen/intrinsics/mask.rs b/tests/codegen/intrinsics/mask.rs index c7a2e4ba06dd..8f93da2e5da4 100644 --- a/tests/codegen/intrinsics/mask.rs +++ b/tests/codegen/intrinsics/mask.rs @@ -1,11 +1,12 @@ +// compile-flags: -Copt-level=0 #![crate_type = "lib"] #![feature(core_intrinsics)] // CHECK-LABEL: @mask_ptr -// CHECK-SAME: [[WORD:i[0-9]+]] noundef %mask +// CHECK-SAME: [[WORD:i[0-9]+]] %mask #[no_mangle] pub fn mask_ptr(ptr: *const u16, mask: usize) -> *const u16 { // CHECK: call - // CHECK-SAME: @llvm.ptrmask.{{p0|p0i8}}.[[WORD]]({{ptr|i8\*}} {{%ptr|%0}}, [[WORD]] %mask) + // CHECK-SAME: @llvm.ptrmask.{{p0|p0i8}}.[[WORD]]({{ptr|i8\*}} {{%ptr|%1}}, [[WORD]] %mask) core::intrinsics::ptr_mask(ptr, mask) } diff --git a/tests/codegen/issue-32031.rs b/tests/codegen/issue-32031.rs index b181079785cf..abef92c19b61 100644 --- a/tests/codegen/issue-32031.rs +++ b/tests/codegen/issue-32031.rs @@ -1,11 +1,11 @@ -// compile-flags: -C no-prepopulate-passes +// compile-flags: -C no-prepopulate-passes -Copt-level=0 #![crate_type = "lib"] #[no_mangle] pub struct F32(f32); -// CHECK: define{{.*}}float @add_newtype_f32(float noundef %a, float noundef %b) +// CHECK: define{{.*}}float @add_newtype_f32(float %a, float %b) #[inline(never)] #[no_mangle] pub fn add_newtype_f32(a: F32, b: F32) -> F32 { @@ -15,7 +15,7 @@ pub fn add_newtype_f32(a: F32, b: F32) -> F32 { #[no_mangle] pub struct F64(f64); -// CHECK: define{{.*}}double @add_newtype_f64(double noundef %a, double noundef %b) +// CHECK: define{{.*}}double @add_newtype_f64(double %a, double %b) #[inline(never)] #[no_mangle] pub fn add_newtype_f64(a: F64, b: F64) -> F64 { diff --git a/tests/codegen/issue-58881.rs b/tests/codegen/issue-58881.rs index 9349b78f9620..00f8953d9495 100644 --- a/tests/codegen/issue-58881.rs +++ b/tests/codegen/issue-58881.rs @@ -1,4 +1,4 @@ -// compile-flags: -C no-prepopulate-passes +// compile-flags: -C no-prepopulate-passes -Copt-level=0 // // only-x86_64 // ignore-windows @@ -16,6 +16,6 @@ struct Bar(u64, u64, u64); // Ensure that emit arguments of the correct type. pub unsafe fn test_call_variadic() { - // CHECK: call void (i32, ...) @variadic_fn(i32 noundef 0, i8 {{.*}}, {{%Bar\*|ptr}} {{.*}}) + // CHECK: call void (i32, ...) @variadic_fn(i32 0, i8 {{.*}}, {{%Bar\*|ptr}} {{.*}}) variadic_fn(0, Foo(0), Bar(0, 0, 0)) } diff --git a/tests/codegen/iter-repeat-n-trivial-drop.rs b/tests/codegen/iter-repeat-n-trivial-drop.rs index 20e1d9b4d598..24059f190acf 100644 --- a/tests/codegen/iter-repeat-n-trivial-drop.rs +++ b/tests/codegen/iter-repeat-n-trivial-drop.rs @@ -46,7 +46,7 @@ pub fn iter_repeat_n_next(it: &mut std::iter::RepeatN) -> Option Vec { - // CHECK: %[[ADDR:.+]] = tail call dereferenceable_or_null(1234) ptr @__rust_alloc(i64 1234, i64 1) + // CHECK: %[[ADDR:.+]] = tail call noundef dereferenceable_or_null(1234) ptr @__rust_alloc(i64 noundef 1234, i64 noundef 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; diff --git a/tests/codegen/loads.rs b/tests/codegen/loads.rs index 7c3bf07cc811..f29a26596bfd 100644 --- a/tests/codegen/loads.rs +++ b/tests/codegen/loads.rs @@ -51,7 +51,7 @@ pub fn load_scalar_pair<'a>(x: &(&'a i32, &'a Align16)) -> (&'a i32, &'a Align16 #[no_mangle] pub fn load_raw_pointer<'a>(x: &*const i32) -> *const i32 { // loaded raw pointer should not have !nonnull or !align metadata - // CHECK: load {{i32\*|ptr}}, {{i32\*\*|ptr}} %x, align [[PTR_ALIGNMENT]], !noundef !2{{$}} + // CHECK: load {{i32\*|ptr}}, {{i32\*\*|ptr}} %x, align [[PTR_ALIGNMENT]], !noundef ![[NOUNDEF:[0-9]+]]{{$}} *x } @@ -93,7 +93,7 @@ pub fn load_maybeuninit_enum_bool(x: &MaybeUninit) -> MaybeUninit u16 { - // CHECK: load i16, {{i16\*|ptr}} %x, align 2, !noundef !2{{$}} + // CHECK: load i16, {{i16\*|ptr}} %x, align 2, !noundef ![[NOUNDEF]]{{$}} *x } @@ -107,7 +107,7 @@ pub fn load_nonzero_int(x: &NonZeroU16) -> NonZeroU16 { // CHECK-LABEL: @load_option_nonzero_int #[no_mangle] pub fn load_option_nonzero_int(x: &Option) -> Option { - // CHECK: load i16, {{i16\*|ptr}} %x, align 2, !noundef !2{{$}} + // CHECK: load i16, {{i16\*|ptr}} %x, align 2, !noundef ![[NOUNDEF]]{{$}} *x } diff --git a/tests/codegen/naked-functions.rs b/tests/codegen/naked-functions.rs index 725c0a67a006..e05bbc26e830 100644 --- a/tests/codegen/naked-functions.rs +++ b/tests/codegen/naked-functions.rs @@ -1,4 +1,4 @@ -// compile-flags: -C no-prepopulate-passes +// compile-flags: -C no-prepopulate-passes -Copt-level=0 // needs-asm-support // only-x86_64 @@ -19,7 +19,7 @@ pub unsafe extern "C" fn naked_empty() { } // CHECK: Function Attrs: naked -// CHECK-NEXT: define{{.*}}i{{[0-9]+}} @naked_with_args_and_return(i64 noundef %a, i64 noundef %b) +// CHECK-NEXT: define{{.*}}i{{[0-9]+}} @naked_with_args_and_return(i64 %a, i64 %b) #[no_mangle] #[naked] pub unsafe extern "C" fn naked_with_args_and_return(a: isize, b: isize) -> isize { diff --git a/tests/codegen/pic-relocation-model.rs b/tests/codegen/pic-relocation-model.rs index 7b4f0d9bae5d..518e949ffe34 100644 --- a/tests/codegen/pic-relocation-model.rs +++ b/tests/codegen/pic-relocation-model.rs @@ -1,8 +1,8 @@ -// compile-flags: -C relocation-model=pic +// compile-flags: -C relocation-model=pic -Copt-level=0 #![crate_type = "rlib"] -// CHECK: define noundef i8 @call_foreign_fn() +// CHECK: define i8 @call_foreign_fn() #[no_mangle] pub fn call_foreign_fn() -> u8 { unsafe { @@ -13,7 +13,7 @@ pub fn call_foreign_fn() -> u8 { // (Allow but do not require `zeroext` here, because it is not worth effort to // spell out which targets have it and which ones do not; see rust#97800.) -// CHECK: declare noundef{{( zeroext)?}} i8 @foreign_fn() +// CHECK: declare{{( zeroext)?}} i8 @foreign_fn() extern "C" {fn foreign_fn() -> u8;} // CHECK: !{i32 {{[78]}}, !"PIC Level", i32 2} diff --git a/tests/codegen/pie-relocation-model.rs b/tests/codegen/pie-relocation-model.rs index a59216c3eee5..941cca922bd3 100644 --- a/tests/codegen/pie-relocation-model.rs +++ b/tests/codegen/pie-relocation-model.rs @@ -1,11 +1,11 @@ -// compile-flags: -C relocation-model=pie +// compile-flags: -C relocation-model=pie -Copt-level=0 // only-x86_64-unknown-linux-gnu #![crate_type = "rlib"] // With PIE we know local functions cannot be interpositioned, we can mark them // as dso_local. -// CHECK: define dso_local noundef i8 @call_foreign_fn() +// CHECK: define dso_local i8 @call_foreign_fn() #[no_mangle] pub fn call_foreign_fn() -> u8 { unsafe { @@ -15,7 +15,7 @@ pub fn call_foreign_fn() -> u8 { // External functions are still marked as non-dso_local, since we don't know if the symbol // is defined in the binary or in the shared library. -// CHECK: declare noundef zeroext i8 @foreign_fn() +// CHECK: declare zeroext i8 @foreign_fn() extern "C" {fn foreign_fn() -> u8;} // CHECK: !{i32 {{[78]}}, !"PIC Level", i32 2} diff --git a/tests/codegen/refs.rs b/tests/codegen/refs.rs index 579fd901ee66..a52897667111 100644 --- a/tests/codegen/refs.rs +++ b/tests/codegen/refs.rs @@ -1,9 +1,9 @@ -// compile-flags: -C no-prepopulate-passes -Zmir-opt-level=0 +// compile-flags: -C no-prepopulate-passes -Zmir-opt-level=0 -Copt-level=0 #![crate_type = "lib"] // Hack to get the correct size for the length part in slices -// CHECK: @helper([[USIZE:i[0-9]+]] noundef %_1) +// CHECK: @helper([[USIZE:i[0-9]+]] %_1) #[no_mangle] pub fn helper(_: usize) { } diff --git a/tests/codegen/sanitizer-cfi-emit-type-checks.rs b/tests/codegen/sanitizer-cfi-emit-type-checks.rs index 82334693d58e..597b867ebad1 100644 --- a/tests/codegen/sanitizer-cfi-emit-type-checks.rs +++ b/tests/codegen/sanitizer-cfi-emit-type-checks.rs @@ -1,7 +1,7 @@ // Verifies that pointer type membership tests for indirect calls are emitted. // // needs-sanitizer-cfi -// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi +// compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0 #![crate_type="lib"] @@ -11,7 +11,7 @@ pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { // CHECK: [[TT:%.+]] = call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"{{[[:print:]]+}}") // CHECK-NEXT: br i1 [[TT]], label %type_test.pass, label %type_test.fail // CHECK: type_test.pass: - // CHECK-NEXT: {{%.+}} = call noundef i32 %f(i32 noundef %arg) + // CHECK-NEXT: {{%.+}} = call i32 %f(i32 %arg) // CHECK-NEXT: br label %bb1 // CHECK: type_test.fail: // CHECK-NEXT: call void @llvm.trap() diff --git a/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi.rs b/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi.rs index 43e520bd6cfd..2537df80a90b 100644 --- a/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi.rs +++ b/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi.rs @@ -5,7 +5,7 @@ // [aarch64] needs-llvm-components: aarch64 // [x86_64] compile-flags: --target x86_64-unknown-none // [x86_64] needs-llvm-components: -// compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi +// compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Copt-level=0 #![crate_type="lib"] #![feature(no_core, lang_items)] @@ -21,21 +21,21 @@ impl Copy for i32 {} pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { // CHECK-LABEL: define{{.*}}foo // CHECK-SAME: {{.*}}!{{|kcfi_type}} ![[TYPE1:[0-9]+]] - // CHECK: call noundef i32 %f(i32 noundef %arg){{.*}}[ "kcfi"(i32 -1666898348) ] + // CHECK: call i32 %f(i32 %arg){{.*}}[ "kcfi"(i32 -1666898348) ] f(arg) } pub fn bar(f: fn(i32, i32) -> i32, arg1: i32, arg2: i32) -> i32 { // CHECK-LABEL: define{{.*}}bar // CHECK-SAME: {{.*}}!{{|kcfi_type}} ![[TYPE2:[0-9]+]] - // CHECK: call noundef i32 %f(i32 noundef %arg1, i32 noundef %arg2){{.*}}[ "kcfi"(i32 -1789026986) ] + // CHECK: call i32 %f(i32 %arg1, i32 %arg2){{.*}}[ "kcfi"(i32 -1789026986) ] f(arg1, arg2) } pub fn baz(f: fn(i32, i32, i32) -> i32, arg1: i32, arg2: i32, arg3: i32) -> i32 { // CHECK-LABEL: define{{.*}}baz // CHECK-SAME: {{.*}}!{{|kcfi_type}} ![[TYPE3:[0-9]+]] - // CHECK: call noundef i32 %f(i32 noundef %arg1, i32 noundef %arg2, i32 noundef %arg3){{.*}}[ "kcfi"(i32 1248878270) ] + // CHECK: call i32 %f(i32 %arg1, i32 %arg2, i32 %arg3){{.*}}[ "kcfi"(i32 1248878270) ] f(arg1, arg2, arg3) } diff --git a/tests/codegen/sanitizer-recover.rs b/tests/codegen/sanitizer-recover.rs index 899c67be6ce5..7b00fcf8e1bd 100644 --- a/tests/codegen/sanitizer-recover.rs +++ b/tests/codegen/sanitizer-recover.rs @@ -6,8 +6,8 @@ // revisions:ASAN ASAN-RECOVER MSAN MSAN-RECOVER MSAN-RECOVER-LTO // no-prefer-dynamic // -//[ASAN] compile-flags: -Zsanitizer=address -//[ASAN-RECOVER] compile-flags: -Zsanitizer=address -Zsanitizer-recover=address +//[ASAN] compile-flags: -Zsanitizer=address -Copt-level=0 +//[ASAN-RECOVER] compile-flags: -Zsanitizer=address -Zsanitizer-recover=address -Copt-level=0 //[MSAN] compile-flags: -Zsanitizer=memory //[MSAN-RECOVER] compile-flags: -Zsanitizer=memory -Zsanitizer-recover=memory //[MSAN-RECOVER-LTO] compile-flags: -Zsanitizer=memory -Zsanitizer-recover=memory -C lto=fat @@ -16,12 +16,12 @@ // MSAN-RECOVER: @__msan_keep_going = weak_odr {{.*}}constant i32 1 // MSAN-RECOVER-LTO: @__msan_keep_going = weak_odr {{.*}}constant i32 1 -// ASAN-LABEL: define dso_local noundef i32 @penguin( +// ASAN-LABEL: define dso_local i32 @penguin( // ASAN: call void @__asan_report_load4(i64 %0) // ASAN: unreachable // ASAN: } // -// ASAN-RECOVER-LABEL: define dso_local noundef i32 @penguin( +// ASAN-RECOVER-LABEL: define dso_local i32 @penguin( // ASAN-RECOVER: call void @__asan_report_load4_noabort( // ASAN-RECOVER-NOT: unreachable // ASAN: } diff --git a/tests/codegen/some-abis-do-extend-params-to-32-bits.rs b/tests/codegen/some-abis-do-extend-params-to-32-bits.rs index 86acbfba6a0f..9f2d9d06524f 100644 --- a/tests/codegen/some-abis-do-extend-params-to-32-bits.rs +++ b/tests/codegen/some-abis-do-extend-params-to-32-bits.rs @@ -1,4 +1,4 @@ -// compile-flags: -Cno-prepopulate-passes +// compile-flags: -Cno-prepopulate-passes -Copt-level=0 // revisions:x86_64 i686 aarch64-apple aarch64-windows aarch64-linux arm riscv @@ -31,85 +31,85 @@ // The patterns in this file are written in the style of a table to make the // uniformities and distinctions more apparent. // -// ZERO/SIGN-EXTENDING TO 32 BITS NON-EXTENDING -// ====================================== =============================== -// x86_64: void @c_arg_u8(i8 noundef zeroext %_a) -// i686: void @c_arg_u8(i8 noundef zeroext %_a) -// aarch64-apple: void @c_arg_u8(i8 noundef zeroext %_a) -// aarch64-windows: void @c_arg_u8(i8 noundef %_a) -// aarch64-linux: void @c_arg_u8(i8 noundef %_a) -// arm: void @c_arg_u8(i8 noundef zeroext %_a) -// riscv: void @c_arg_u8(i8 noundef zeroext %_a) +// ZERO/SIGN-EXTENDING TO 32 BITS NON-EXTENDING +// ============================== ======================= +// x86_64: void @c_arg_u8(i8 zeroext %_a) +// i686: void @c_arg_u8(i8 zeroext %_a) +// aarch64-apple: void @c_arg_u8(i8 zeroext %_a) +// aarch64-windows: void @c_arg_u8(i8 %_a) +// aarch64-linux: void @c_arg_u8(i8 %_a) +// arm: void @c_arg_u8(i8 zeroext %_a) +// riscv: void @c_arg_u8(i8 zeroext %_a) #[no_mangle] pub extern "C" fn c_arg_u8(_a: u8) { } -// x86_64: void @c_arg_u16(i16 noundef zeroext %_a) -// i686: void @c_arg_u16(i16 noundef zeroext %_a) -// aarch64-apple: void @c_arg_u16(i16 noundef zeroext %_a) -// aarch64-windows: void @c_arg_u16(i16 noundef %_a) -// aarch64-linux: void @c_arg_u16(i16 noundef %_a) -// arm: void @c_arg_u16(i16 noundef zeroext %_a) -// riscv: void @c_arg_u16(i16 noundef zeroext %_a) +// x86_64: void @c_arg_u16(i16 zeroext %_a) +// i686: void @c_arg_u16(i16 zeroext %_a) +// aarch64-apple: void @c_arg_u16(i16 zeroext %_a) +// aarch64-windows: void @c_arg_u16(i16 %_a) +// aarch64-linux: void @c_arg_u16(i16 %_a) +// arm: void @c_arg_u16(i16 zeroext %_a) +// riscv: void @c_arg_u16(i16 zeroext %_a) #[no_mangle] pub extern "C" fn c_arg_u16(_a: u16) { } -// x86_64: void @c_arg_u32(i32 noundef %_a) -// i686: void @c_arg_u32(i32 noundef %_a) -// aarch64-apple: void @c_arg_u32(i32 noundef %_a) -// aarch64-windows: void @c_arg_u32(i32 noundef %_a) -// aarch64-linux: void @c_arg_u32(i32 noundef %_a) -// arm: void @c_arg_u32(i32 noundef %_a) -// riscv: void @c_arg_u32(i32 noundef signext %_a) +// x86_64: void @c_arg_u32(i32 %_a) +// i686: void @c_arg_u32(i32 %_a) +// aarch64-apple: void @c_arg_u32(i32 %_a) +// aarch64-windows: void @c_arg_u32(i32 %_a) +// aarch64-linux: void @c_arg_u32(i32 %_a) +// arm: void @c_arg_u32(i32 %_a) +// riscv: void @c_arg_u32(i32 signext %_a) #[no_mangle] pub extern "C" fn c_arg_u32(_a: u32) { } -// x86_64: void @c_arg_u64(i64 noundef %_a) -// i686: void @c_arg_u64(i64 noundef %_a) -// aarch64-apple: void @c_arg_u64(i64 noundef %_a) -// aarch64-windows: void @c_arg_u64(i64 noundef %_a) -// aarch64-linux: void @c_arg_u64(i64 noundef %_a) -// arm: void @c_arg_u64(i64 noundef %_a) -// riscv: void @c_arg_u64(i64 noundef %_a) +// x86_64: void @c_arg_u64(i64 %_a) +// i686: void @c_arg_u64(i64 %_a) +// aarch64-apple: void @c_arg_u64(i64 %_a) +// aarch64-windows: void @c_arg_u64(i64 %_a) +// aarch64-linux: void @c_arg_u64(i64 %_a) +// arm: void @c_arg_u64(i64 %_a) +// riscv: void @c_arg_u64(i64 %_a) #[no_mangle] pub extern "C" fn c_arg_u64(_a: u64) { } -// x86_64: void @c_arg_i8(i8 noundef signext %_a) -// i686: void @c_arg_i8(i8 noundef signext %_a) -// aarch64-apple: void @c_arg_i8(i8 noundef signext %_a) -// aarch64-windows: void @c_arg_i8(i8 noundef %_a) -// aarch64-linux: void @c_arg_i8(i8 noundef %_a) -// arm: void @c_arg_i8(i8 noundef signext %_a) -// riscv: void @c_arg_i8(i8 noundef signext %_a) +// x86_64: void @c_arg_i8(i8 signext %_a) +// i686: void @c_arg_i8(i8 signext %_a) +// aarch64-apple: void @c_arg_i8(i8 signext %_a) +// aarch64-windows: void @c_arg_i8(i8 %_a) +// aarch64-linux: void @c_arg_i8(i8 %_a) +// arm: void @c_arg_i8(i8 signext %_a) +// riscv: void @c_arg_i8(i8 signext %_a) #[no_mangle] pub extern "C" fn c_arg_i8(_a: i8) { } -// x86_64: void @c_arg_i16(i16 noundef signext %_a) -// i686: void @c_arg_i16(i16 noundef signext %_a) -// aarch64-apple: void @c_arg_i16(i16 noundef signext %_a) -// aarch64-windows: void @c_arg_i16(i16 noundef %_a) -// aarch64-linux: void @c_arg_i16(i16 noundef %_a) -// arm: void @c_arg_i16(i16 noundef signext %_a) -// riscv: void @c_arg_i16(i16 noundef signext %_a) +// x86_64: void @c_arg_i16(i16 signext %_a) +// i686: void @c_arg_i16(i16 signext %_a) +// aarch64-apple: void @c_arg_i16(i16 signext %_a) +// aarch64-windows: void @c_arg_i16(i16 %_a) +// aarch64-linux: void @c_arg_i16(i16 %_a) +// arm: void @c_arg_i16(i16 signext %_a) +// riscv: void @c_arg_i16(i16 signext %_a) #[no_mangle] pub extern "C" fn c_arg_i16(_a: i16) { } -// x86_64: void @c_arg_i32(i32 noundef %_a) -// i686: void @c_arg_i32(i32 noundef %_a) -// aarch64-apple: void @c_arg_i32(i32 noundef %_a) -// aarch64-windows: void @c_arg_i32(i32 noundef %_a) -// aarch64-linux: void @c_arg_i32(i32 noundef %_a) -// arm: void @c_arg_i32(i32 noundef %_a) -// riscv: void @c_arg_i32(i32 noundef signext %_a) +// x86_64: void @c_arg_i32(i32 %_a) +// i686: void @c_arg_i32(i32 %_a) +// aarch64-apple: void @c_arg_i32(i32 %_a) +// aarch64-windows: void @c_arg_i32(i32 %_a) +// aarch64-linux: void @c_arg_i32(i32 %_a) +// arm: void @c_arg_i32(i32 %_a) +// riscv: void @c_arg_i32(i32 signext %_a) #[no_mangle] pub extern "C" fn c_arg_i32(_a: i32) { } -// x86_64: void @c_arg_i64(i64 noundef %_a) -// i686: void @c_arg_i64(i64 noundef %_a) -// aarch64-apple: void @c_arg_i64(i64 noundef %_a) -// aarch64-windows: void @c_arg_i64(i64 noundef %_a) -// aarch64-linux: void @c_arg_i64(i64 noundef %_a) -// arm: void @c_arg_i64(i64 noundef %_a) -// riscv: void @c_arg_i64(i64 noundef %_a) +// x86_64: void @c_arg_i64(i64 %_a) +// i686: void @c_arg_i64(i64 %_a) +// aarch64-apple: void @c_arg_i64(i64 %_a) +// aarch64-windows: void @c_arg_i64(i64 %_a) +// aarch64-linux: void @c_arg_i64(i64 %_a) +// arm: void @c_arg_i64(i64 %_a) +// riscv: void @c_arg_i64(i64 %_a) #[no_mangle] pub extern "C" fn c_arg_i64(_a: i64) { } // x86_64: zeroext i8 @c_ret_u8() // i686: zeroext i8 @c_ret_u8() // aarch64-apple: zeroext i8 @c_ret_u8() -// aarch64-windows: i8 @c_ret_u8() -// aarch64-linux: i8 @c_ret_u8() +// aarch64-windows: i8 @c_ret_u8() +// aarch64-linux: i8 @c_ret_u8() // arm: zeroext i8 @c_ret_u8() // riscv: zeroext i8 @c_ret_u8() #[no_mangle] pub extern "C" fn c_ret_u8() -> u8 { 0 } @@ -117,8 +117,8 @@ // x86_64: zeroext i16 @c_ret_u16() // i686: zeroext i16 @c_ret_u16() // aarch64-apple: zeroext i16 @c_ret_u16() -// aarch64-windows: i16 @c_ret_u16() -// aarch64-linux: i16 @c_ret_u16() +// aarch64-windows: i16 @c_ret_u16() +// aarch64-linux: i16 @c_ret_u16() // arm: zeroext i16 @c_ret_u16() // riscv: zeroext i16 @c_ret_u16() #[no_mangle] pub extern "C" fn c_ret_u16() -> u16 { 0 } @@ -126,8 +126,8 @@ // x86_64: i32 @c_ret_u32() // i686: i32 @c_ret_u32() // aarch64-apple: i32 @c_ret_u32() -// aarch64-windows: i32 @c_ret_u32() -// aarch64-linux: i32 @c_ret_u32() +// aarch64-windows: i32 @c_ret_u32() +// aarch64-linux: i32 @c_ret_u32() // arm: i32 @c_ret_u32() // riscv: signext i32 @c_ret_u32() #[no_mangle] pub extern "C" fn c_ret_u32() -> u32 { 0 } @@ -135,8 +135,8 @@ // x86_64: i64 @c_ret_u64() // i686: i64 @c_ret_u64() // aarch64-apple: i64 @c_ret_u64() -// aarch64-windows: i64 @c_ret_u64() -// aarch64-linux: i64 @c_ret_u64() +// aarch64-windows: i64 @c_ret_u64() +// aarch64-linux: i64 @c_ret_u64() // arm: i64 @c_ret_u64() // riscv: i64 @c_ret_u64() #[no_mangle] pub extern "C" fn c_ret_u64() -> u64 { 0 } @@ -144,8 +144,8 @@ // x86_64: signext i8 @c_ret_i8() // i686: signext i8 @c_ret_i8() // aarch64-apple: signext i8 @c_ret_i8() -// aarch64-windows: i8 @c_ret_i8() -// aarch64-linux: i8 @c_ret_i8() +// aarch64-windows: i8 @c_ret_i8() +// aarch64-linux: i8 @c_ret_i8() // arm: signext i8 @c_ret_i8() // riscv: signext i8 @c_ret_i8() #[no_mangle] pub extern "C" fn c_ret_i8() -> i8 { 0 } @@ -153,8 +153,8 @@ // x86_64: signext i16 @c_ret_i16() // i686: signext i16 @c_ret_i16() // aarch64-apple: signext i16 @c_ret_i16() -// aarch64-windows: i16 @c_ret_i16() -// aarch64-linux: i16 @c_ret_i16() +// aarch64-windows: i16 @c_ret_i16() +// aarch64-linux: i16 @c_ret_i16() // arm: signext i16 @c_ret_i16() // riscv: signext i16 @c_ret_i16() #[no_mangle] pub extern "C" fn c_ret_i16() -> i16 { 0 } @@ -162,8 +162,8 @@ // x86_64: i32 @c_ret_i32() // i686: i32 @c_ret_i32() // aarch64-apple: i32 @c_ret_i32() -// aarch64-windows: i32 @c_ret_i32() -// aarch64-linux: i32 @c_ret_i32() +// aarch64-windows: i32 @c_ret_i32() +// aarch64-linux: i32 @c_ret_i32() // arm: i32 @c_ret_i32() // riscv: signext i32 @c_ret_i32() #[no_mangle] pub extern "C" fn c_ret_i32() -> i32 { 0 } @@ -171,8 +171,8 @@ // x86_64: i64 @c_ret_i64() // i686: i64 @c_ret_i64() // aarch64-apple: i64 @c_ret_i64() -// aarch64-windows: i64 @c_ret_i64() -// aarch64-linux: i64 @c_ret_i64() +// aarch64-windows: i64 @c_ret_i64() +// aarch64-linux: i64 @c_ret_i64() // arm: i64 @c_ret_i64() // riscv: i64 @c_ret_i64() #[no_mangle] pub extern "C" fn c_ret_i64() -> i64 { 0 } diff --git a/tests/codegen/static-relocation-model-msvc.rs b/tests/codegen/static-relocation-model-msvc.rs index b2afc7deb679..735ef7081c95 100644 --- a/tests/codegen/static-relocation-model-msvc.rs +++ b/tests/codegen/static-relocation-model-msvc.rs @@ -15,8 +15,8 @@ extern crate extern_decl; // it to be marked `dso_local` as well, given the static relocation model. // // CHECK: @extern_static = external dso_local local_unnamed_addr global i8 -// CHECK: define dso_local i8 @access_extern() {{.*}} -// CHECK: declare dso_local i8 @extern_fn() {{.*}} +// CHECK: define dso_local noundef i8 @access_extern() {{.*}} +// CHECK: declare dso_local noundef i8 @extern_fn() {{.*}} #[no_mangle] pub fn access_extern() -> u8 { diff --git a/tests/codegen/tuple-layout-opt.rs b/tests/codegen/tuple-layout-opt.rs index ad33d6643c29..35f760851451 100644 --- a/tests/codegen/tuple-layout-opt.rs +++ b/tests/codegen/tuple-layout-opt.rs @@ -1,36 +1,36 @@ // ignore-emscripten -// compile-flags: -C no-prepopulate-passes +// 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) #![crate_type="lib"] type ScalarZstLast = (u128, ()); -// CHECK: define noundef i128 @test_ScalarZstLast(i128 noundef %_1) +// CHECK: define i128 @test_ScalarZstLast(i128 %_1) #[no_mangle] pub fn test_ScalarZstLast(_: ScalarZstLast) -> ScalarZstLast { loop {} } type ScalarZstFirst = ((), u128); -// CHECK: define noundef i128 @test_ScalarZstFirst(i128 noundef %_1) +// CHECK: define i128 @test_ScalarZstFirst(i128 %_1) #[no_mangle] pub fn test_ScalarZstFirst(_: ScalarZstFirst) -> ScalarZstFirst { loop {} } type ScalarPairZstLast = (u8, u128, ()); -// CHECK: define { i128, i8 } @test_ScalarPairZstLast(i128 noundef %_1.0, i8 noundef %_1.1) +// CHECK: define { i128, i8 } @test_ScalarPairZstLast(i128 %_1.0, i8 %_1.1) #[no_mangle] pub fn test_ScalarPairZstLast(_: ScalarPairZstLast) -> ScalarPairZstLast { loop {} } type ScalarPairZstFirst = ((), u8, u128); -// CHECK: define { i8, i128 } @test_ScalarPairZstFirst(i8 noundef %_1.0, i128 noundef %_1.1) +// CHECK: define { i8, i128 } @test_ScalarPairZstFirst(i8 %_1.0, i128 %_1.1) #[no_mangle] pub fn test_ScalarPairZstFirst(_: ScalarPairZstFirst) -> ScalarPairZstFirst { loop {} } type ScalarPairLotsOfZsts = ((), u8, (), u128, ()); -// CHECK: define { i128, i8 } @test_ScalarPairLotsOfZsts(i128 noundef %_1.0, i8 noundef %_1.1) +// CHECK: define { i128, i8 } @test_ScalarPairLotsOfZsts(i128 %_1.0, i8 %_1.1) #[no_mangle] pub fn test_ScalarPairLotsOfZsts(_: ScalarPairLotsOfZsts) -> ScalarPairLotsOfZsts { loop {} } type ScalarPairLottaNesting = (((), ((), u8, (), u128, ())), ()); -// CHECK: define { i128, i8 } @test_ScalarPairLottaNesting(i128 noundef %_1.0, i8 noundef %_1.1) +// CHECK: define { i128, i8 } @test_ScalarPairLottaNesting(i128 %_1.0, i8 %_1.1) #[no_mangle] pub fn test_ScalarPairLottaNesting(_: ScalarPairLottaNesting) -> ScalarPairLottaNesting { loop {} } diff --git a/tests/codegen/vec-calloc.rs b/tests/codegen/vec-calloc.rs index ae6e448f172f..442cdd41dc66 100644 --- a/tests/codegen/vec-calloc.rs +++ b/tests/codegen/vec-calloc.rs @@ -162,6 +162,6 @@ pub fn vec_option_bool(n: usize) -> Vec> { } // Ensure that __rust_alloc_zeroed gets the right attributes for LLVM to optimize it away. -// CHECK: declare noalias ptr @__rust_alloc_zeroed(i64, i64 allocalign) unnamed_addr [[RUST_ALLOC_ZEROED_ATTRS:#[0-9]+]] +// CHECK: declare noalias noundef ptr @__rust_alloc_zeroed(i64 noundef, i64 allocalign noundef) unnamed_addr [[RUST_ALLOC_ZEROED_ATTRS:#[0-9]+]] // CHECK-DAG: attributes [[RUST_ALLOC_ZEROED_ATTRS]] = { {{.*}} allockind("alloc,zeroed,aligned") allocsize(0) uwtable "alloc-family"="__rust_alloc" {{.*}} } diff --git a/tests/codegen/zst-offset.rs b/tests/codegen/zst-offset.rs index 27e435e9cf04..cef4b9bdaaf0 100644 --- a/tests/codegen/zst-offset.rs +++ b/tests/codegen/zst-offset.rs @@ -1,10 +1,10 @@ -// compile-flags: -C no-prepopulate-passes +// compile-flags: -C no-prepopulate-passes -Copt-level=0 #![crate_type = "lib"] #![feature(repr_simd)] // Hack to get the correct size for the length part in slices -// CHECK: @helper([[USIZE:i[0-9]+]] noundef %_1) +// CHECK: @helper([[USIZE:i[0-9]+]] %_1) #[no_mangle] pub fn helper(_: usize) { }