Skip to content

Commit 4346bd1

Browse files
Revert "Auto merge of #93670 - erikdesjardins:noundef, r=nikic"
This reverts commit 5c30d65, reversing changes made to 3cfa4de.
1 parent 30b3f35 commit 4346bd1

File tree

13 files changed

+91
-94
lines changed

13 files changed

+91
-94
lines changed

compiler/rustc_codegen_llvm/src/abi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl ArgAttributeExt for ArgAttribute {
3737
where
3838
F: FnMut(llvm::Attribute),
3939
{
40-
for_each_kind!(self, f, NoAlias, NoCapture, NonNull, ReadOnly, InReg, NoUndef)
40+
for_each_kind!(self, f, NoAlias, NoCapture, NonNull, ReadOnly, InReg)
4141
}
4242
}
4343

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ pub enum Attribute {
189189
StackProtectReq = 30,
190190
StackProtectStrong = 31,
191191
StackProtect = 32,
192-
NoUndef = 33,
193192
}
194193

195194
/// LLVMIntPredicate

compiler/rustc_llvm/llvm-wrapper/LLVMWrapper.h

-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ enum LLVMRustAttribute {
8282
StackProtectReq = 30,
8383
StackProtectStrong = 31,
8484
StackProtect = 32,
85-
NoUndef = 33,
8685
};
8786

8887
typedef struct OpaqueRustString *RustStringRef;

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,6 @@ static Attribute::AttrKind fromRust(LLVMRustAttribute Kind) {
224224
return Attribute::StackProtectStrong;
225225
case StackProtect:
226226
return Attribute::StackProtect;
227-
case NoUndef:
228-
return Attribute::NoUndef;
229227
}
230228
report_fatal_error("bad AttributeKind");
231229
}

compiler/rustc_middle/src/ty/layout.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -3051,10 +3051,9 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
30513051
layout: TyAndLayout<'tcx>,
30523052
offset: Size,
30533053
is_return: bool| {
3054-
// Booleans are always a noundef i1 that needs to be zero-extended.
3054+
// Booleans are always an i1 that needs to be zero-extended.
30553055
if scalar.is_bool() {
30563056
attrs.ext(ArgExtension::Zext);
3057-
attrs.set(ArgAttribute::NoUndef);
30583057
return;
30593058
}
30603059

@@ -3079,11 +3078,6 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
30793078
_ => pointee.size,
30803079
};
30813080

3082-
// `Box`, `&T`, and `&mut T` cannot be undef.
3083-
// Note that this only applies to the value of the pointer itself;
3084-
// this attribute doesn't make it UB for the pointed-to data to be undef.
3085-
attrs.set(ArgAttribute::NoUndef);
3086-
30873081
// `Box` pointer parameters never alias because ownership is transferred
30883082
// `&mut` pointer parameters never alias other parameters,
30893083
// or mutable global data

compiler/rustc_target/src/abi/call/mod.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ mod attr_impl {
7474
// or not to actually emit the attribute. It can also be controlled
7575
// with the `-Zmutable-noalias` debugging option.
7676
const NoAliasMutRef = 1 << 6;
77-
const NoUndef = 1 << 7;
7877
}
7978
}
8079
}
@@ -496,11 +495,7 @@ impl<'a, Ty> ArgAbi<'a, Ty> {
496495
// For non-immediate arguments the callee gets its own copy of
497496
// the value on the stack, so there are no aliases. It's also
498497
// program-invisible so can't possibly capture
499-
attrs
500-
.set(ArgAttribute::NoAlias)
501-
.set(ArgAttribute::NoCapture)
502-
.set(ArgAttribute::NonNull)
503-
.set(ArgAttribute::NoUndef);
498+
attrs.set(ArgAttribute::NoAlias).set(ArgAttribute::NoCapture).set(ArgAttribute::NonNull);
504499
attrs.pointee_size = layout.size;
505500
// FIXME(eddyb) We should be doing this, but at least on
506501
// i686-pc-windows-msvc, it results in wrong stack offsets.

src/test/codegen/fastcall-inreg.rs

+45-10
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,52 @@
22
// as "inreg" like the C/C++ compilers for the platforms.
33
// x86 only.
44

5-
// compile-flags: --target i686-unknown-linux-gnu -C no-prepopulate-passes
6-
// needs-llvm-components: x86
5+
// ignore-aarch64
6+
// ignore-aarch64_be
7+
// ignore-arm
8+
// ignore-armeb
9+
// ignore-avr
10+
// ignore-bpfel
11+
// ignore-bpfeb
12+
// ignore-hexagon
13+
// ignore-mips
14+
// ignore-mips64
15+
// ignore-msp430
16+
// ignore-powerpc64
17+
// ignore-powerpc64le
18+
// ignore-powerpc
19+
// ignore-r600
20+
// ignore-riscv64
21+
// ignore-amdgcn
22+
// ignore-sparc
23+
// ignore-sparc64
24+
// ignore-sparcv9
25+
// ignore-sparcel
26+
// ignore-s390x
27+
// ignore-tce
28+
// ignore-thumb
29+
// ignore-thumbeb
30+
// ignore-x86_64
31+
// ignore-xcore
32+
// ignore-nvptx
33+
// ignore-nvptx64
34+
// ignore-le32
35+
// ignore-le64
36+
// ignore-amdil
37+
// ignore-amdil64
38+
// ignore-hsail
39+
// ignore-hsail64
40+
// ignore-spir
41+
// ignore-spir64
42+
// ignore-kalimba
43+
// ignore-shave
44+
// ignore-wasm32
45+
// ignore-wasm64
46+
// ignore-emscripten
747

8-
#![crate_type = "lib"]
9-
#![no_core]
10-
#![feature(no_core, lang_items)]
48+
// compile-flags: -C no-prepopulate-passes
1149

12-
#[lang = "sized"]
13-
trait Sized {}
14-
#[lang = "copy"]
15-
trait Copy {}
50+
#![crate_type = "lib"]
1651

1752
pub mod tests {
1853
// CHECK: @f1(i32 inreg %_1, i32 inreg %_2, i32 %_3)
@@ -35,7 +70,7 @@ pub mod tests {
3570
#[no_mangle]
3671
pub extern "fastcall" fn f5(_: i64, _: i32) {}
3772

38-
// CHECK: @f6(i1 inreg noundef zeroext %_1, i32 inreg %_2, i32 %_3)
73+
// CHECK: @f6(i1 inreg zeroext %_1, i32 inreg %_2, i32 %_3)
3974
#[no_mangle]
4075
pub extern "fastcall" fn f6(_: bool, _: i32, _: i32) {}
4176
}

src/test/codegen/function-arguments.rs

+20-43
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
#![crate_type = "lib"]
44
#![feature(rustc_attrs)]
55

6-
use std::mem::MaybeUninit;
7-
86
pub struct S {
97
_field: [i32; 8],
108
}
@@ -13,79 +11,68 @@ pub struct UnsafeInner {
1311
_field: std::cell::UnsafeCell<i16>,
1412
}
1513

16-
// CHECK: noundef zeroext i1 @boolean(i1 noundef zeroext %x)
14+
// CHECK: zeroext i1 @boolean(i1 zeroext %x)
1715
#[no_mangle]
1816
pub fn boolean(x: bool) -> bool {
1917
x
2018
}
2119

22-
// CHECK: i8 @maybeuninit_boolean(i8 %x)
23-
#[no_mangle]
24-
pub fn maybeuninit_boolean(x: MaybeUninit<bool>) -> MaybeUninit<bool> {
25-
x
26-
}
27-
28-
// CHECK: @readonly_borrow(i32* noalias noundef readonly align 4 dereferenceable(4) %_1)
20+
// CHECK: @readonly_borrow(i32* noalias readonly align 4 dereferenceable(4) %_1)
2921
// FIXME #25759 This should also have `nocapture`
3022
#[no_mangle]
3123
pub fn readonly_borrow(_: &i32) {
3224
}
3325

34-
// CHECK: @static_borrow(i32* noalias noundef readonly align 4 dereferenceable(4) %_1)
26+
// CHECK: @static_borrow(i32* noalias readonly align 4 dereferenceable(4) %_1)
3527
// static borrow may be captured
3628
#[no_mangle]
3729
pub fn static_borrow(_: &'static i32) {
3830
}
3931

40-
// CHECK: @named_borrow(i32* noalias noundef readonly align 4 dereferenceable(4) %_1)
32+
// CHECK: @named_borrow(i32* noalias readonly align 4 dereferenceable(4) %_1)
4133
// borrow with named lifetime may be captured
4234
#[no_mangle]
4335
pub fn named_borrow<'r>(_: &'r i32) {
4436
}
4537

46-
// CHECK: @unsafe_borrow(i16* noundef align 2 dereferenceable(2) %_1)
38+
// CHECK: @unsafe_borrow(i16* align 2 dereferenceable(2) %_1)
4739
// unsafe interior means this isn't actually readonly and there may be aliases ...
4840
#[no_mangle]
4941
pub fn unsafe_borrow(_: &UnsafeInner) {
5042
}
5143

52-
// CHECK: @mutable_unsafe_borrow(i16* noalias noundef align 2 dereferenceable(2) %_1)
44+
// CHECK: @mutable_unsafe_borrow(i16* noalias align 2 dereferenceable(2) %_1)
5345
// ... unless this is a mutable borrow, those never alias
5446
#[no_mangle]
5547
pub fn mutable_unsafe_borrow(_: &mut UnsafeInner) {
5648
}
5749

58-
// CHECK: @mutable_borrow(i32* noalias noundef align 4 dereferenceable(4) %_1)
50+
// CHECK: @mutable_borrow(i32* noalias align 4 dereferenceable(4) %_1)
5951
// FIXME #25759 This should also have `nocapture`
6052
#[no_mangle]
6153
pub fn mutable_borrow(_: &mut i32) {
6254
}
6355

64-
// CHECK: @indirect_struct(%S* noalias nocapture noundef dereferenceable(32) %_1)
56+
// CHECK: @indirect_struct(%S* noalias nocapture dereferenceable(32) %_1)
6557
#[no_mangle]
6658
pub fn indirect_struct(_: S) {
6759
}
6860

69-
// CHECK: @borrowed_struct(%S* noalias noundef readonly align 4 dereferenceable(32) %_1)
61+
// CHECK: @borrowed_struct(%S* noalias readonly align 4 dereferenceable(32) %_1)
7062
// FIXME #25759 This should also have `nocapture`
7163
#[no_mangle]
7264
pub fn borrowed_struct(_: &S) {
7365
}
7466

75-
// CHECK: @raw_struct(%S* %_1)
76-
#[no_mangle]
77-
pub fn raw_struct(_: *const S) {
78-
}
79-
8067
// `Box` can get deallocated during execution of the function, so it should
8168
// not get `dereferenceable`.
82-
// CHECK: noalias noundef nonnull align 4 i32* @_box(i32* noalias noundef nonnull align 4 %x)
69+
// CHECK: noalias nonnull align 4 i32* @_box(i32* noalias nonnull align 4 %x)
8370
#[no_mangle]
8471
pub fn _box(x: Box<i32>) -> Box<i32> {
8572
x
8673
}
8774

88-
// CHECK: @struct_return(%S* noalias nocapture noundef sret(%S) dereferenceable(32){{( %0)?}})
75+
// CHECK: @struct_return(%S* noalias nocapture sret(%S) dereferenceable(32){{( %0)?}})
8976
#[no_mangle]
9077
pub fn struct_return() -> S {
9178
S {
@@ -99,58 +86,48 @@ pub fn struct_return() -> S {
9986
pub fn helper(_: usize) {
10087
}
10188

102-
// CHECK: @slice([0 x i8]* noalias noundef nonnull readonly align 1 %_1.0, [[USIZE]] %_1.1)
89+
// CHECK: @slice([0 x i8]* noalias nonnull readonly align 1 %_1.0, [[USIZE]] %_1.1)
10390
// FIXME #25759 This should also have `nocapture`
10491
#[no_mangle]
10592
pub fn slice(_: &[u8]) {
10693
}
10794

108-
// CHECK: @mutable_slice([0 x i8]* noalias noundef nonnull align 1 %_1.0, [[USIZE]] %_1.1)
95+
// CHECK: @mutable_slice([0 x i8]* noalias nonnull align 1 %_1.0, [[USIZE]] %_1.1)
10996
// FIXME #25759 This should also have `nocapture`
11097
#[no_mangle]
11198
pub fn mutable_slice(_: &mut [u8]) {
11299
}
113100

114-
// CHECK: @unsafe_slice([0 x i16]* noundef nonnull align 2 %_1.0, [[USIZE]] %_1.1)
101+
// CHECK: @unsafe_slice([0 x i16]* nonnull align 2 %_1.0, [[USIZE]] %_1.1)
115102
// unsafe interior means this isn't actually readonly and there may be aliases ...
116103
#[no_mangle]
117104
pub fn unsafe_slice(_: &[UnsafeInner]) {
118105
}
119106

120-
// CHECK: @raw_slice([0 x i8]* %_1.0, [[USIZE]] %_1.1)
121-
#[no_mangle]
122-
pub fn raw_slice(_: *const [u8]) {
123-
}
124-
125-
// CHECK: @str([0 x i8]* noalias noundef nonnull readonly align 1 %_1.0, [[USIZE]] %_1.1)
107+
// CHECK: @str([0 x i8]* noalias nonnull readonly align 1 %_1.0, [[USIZE]] %_1.1)
126108
// FIXME #25759 This should also have `nocapture`
127109
#[no_mangle]
128110
pub fn str(_: &[u8]) {
129111
}
130112

131-
// CHECK: @trait_borrow({}* noundef nonnull align 1 %_1.0, [3 x [[USIZE]]]* noalias noundef readonly align {{.*}} dereferenceable({{.*}}) %_1.1)
113+
// CHECK: @trait_borrow({}* nonnull align 1 %_1.0, [3 x [[USIZE]]]* noalias readonly align {{.*}} dereferenceable({{.*}}) %_1.1)
132114
// FIXME #25759 This should also have `nocapture`
133115
#[no_mangle]
134116
pub fn trait_borrow(_: &Drop) {
135117
}
136118

137-
// CHECK: @trait_raw({}* %_1.0, [3 x [[USIZE]]]* noalias noundef readonly align {{.*}} dereferenceable({{.*}}) %_1.1)
138-
#[no_mangle]
139-
pub fn trait_raw(_: *const Drop) {
140-
}
141-
142-
// CHECK: @trait_box({}* noalias noundef nonnull align 1{{( %0)?}}, [3 x [[USIZE]]]* noalias noundef readonly align {{.*}} dereferenceable({{.*}}){{( %1)?}})
119+
// CHECK: @trait_box({}* noalias nonnull align 1{{( %0)?}}, [3 x [[USIZE]]]* noalias readonly align {{.*}} dereferenceable({{.*}}){{( %1)?}})
143120
#[no_mangle]
144121
pub fn trait_box(_: Box<Drop>) {
145122
}
146123

147-
// CHECK: { i8*, i8* } @trait_option(i8* noalias noundef align 1 %x.0, i8* %x.1)
124+
// CHECK: { i8*, i8* } @trait_option(i8* noalias align 1 %x.0, i8* %x.1)
148125
#[no_mangle]
149126
pub fn trait_option(x: Option<Box<Drop>>) -> Option<Box<Drop>> {
150127
x
151128
}
152129

153-
// CHECK: { [0 x i16]*, [[USIZE]] } @return_slice([0 x i16]* noalias noundef nonnull readonly align 2 %x.0, [[USIZE]] %x.1)
130+
// CHECK: { [0 x i16]*, [[USIZE]] } @return_slice([0 x i16]* noalias nonnull readonly align 2 %x.0, [[USIZE]] %x.1)
154131
#[no_mangle]
155132
pub fn return_slice(x: &[u16]) -> &[u16] {
156133
x
@@ -162,7 +139,7 @@ pub fn enum_id_1(x: Option<Result<u16, u16>>) -> Option<Result<u16, u16>> {
162139
x
163140
}
164141

165-
// CHECK: { i8, i8 } @enum_id_2(i1 noundef zeroext %x.0, i8 %x.1)
142+
// CHECK: { i8, i8 } @enum_id_2(i1 zeroext %x.0, i8 %x.1)
166143
#[no_mangle]
167144
pub fn enum_id_2(x: Option<u8>) -> Option<u8> {
168145
x

src/test/codegen/packed.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub struct BigPacked2 {
5252
#[no_mangle]
5353
pub fn call_pkd1(f: fn() -> Array) -> BigPacked1 {
5454
// CHECK: [[ALLOCA:%[_a-z0-9]+]] = alloca %Array
55-
// CHECK: call void %{{.*}}(%Array* noalias nocapture noundef sret{{.*}} dereferenceable(32) [[ALLOCA]])
55+
// CHECK: call void %{{.*}}(%Array* noalias nocapture sret{{.*}} dereferenceable(32) [[ALLOCA]])
5656
// CHECK: call void @llvm.memcpy.{{.*}}(i8* align 1 %{{.*}}, i8* align 4 %{{.*}}, i{{[0-9]+}} 32, i1 false)
5757
// check that calls whose destination is a field of a packed struct
5858
// go through an alloca rather than calling the function with an
@@ -64,7 +64,7 @@ pub fn call_pkd1(f: fn() -> Array) -> BigPacked1 {
6464
#[no_mangle]
6565
pub fn call_pkd2(f: fn() -> Array) -> BigPacked2 {
6666
// CHECK: [[ALLOCA:%[_a-z0-9]+]] = alloca %Array
67-
// CHECK: call void %{{.*}}(%Array* noalias nocapture noundef sret{{.*}} dereferenceable(32) [[ALLOCA]])
67+
// CHECK: call void %{{.*}}(%Array* noalias nocapture sret{{.*}} dereferenceable(32) [[ALLOCA]])
6868
// CHECK: call void @llvm.memcpy.{{.*}}(i8* align 2 %{{.*}}, i8* align 4 %{{.*}}, i{{[0-9]+}} 32, i1 false)
6969
// check that calls whose destination is a field of a packed struct
7070
// go through an alloca rather than calling the function with an

0 commit comments

Comments
 (0)