Skip to content

Commit cd8d759

Browse files
authored
Unrolled build for rust-lang#136287
Rollup merge of rust-lang#136287 - zmodem:nocapture, r=nikic LLVM changed the nocapture attribute to captures(none) This updates RustWrapper.cpp and tests after llvm/llvm-project#123181
2 parents c37fbd8 + 6e457b8 commit cd8d759

File tree

8 files changed

+35
-18
lines changed

8 files changed

+35
-18
lines changed

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,11 @@ static Attribute::AttrKind fromRust(LLVMRustAttributeKind Kind) {
319319
case LLVMRustAttributeKind::NoAlias:
320320
return Attribute::NoAlias;
321321
case LLVMRustAttributeKind::NoCapture:
322+
#if LLVM_VERSION_GE(21, 0)
323+
report_fatal_error("NoCapture doesn't exist in LLVM 21");
324+
#else
322325
return Attribute::NoCapture;
326+
#endif
323327
case LLVMRustAttributeKind::NoCfCheck:
324328
return Attribute::NoCfCheck;
325329
case LLVMRustAttributeKind::NoInline:
@@ -431,6 +435,12 @@ extern "C" void LLVMRustEraseInstFromParent(LLVMValueRef Instr) {
431435

432436
extern "C" LLVMAttributeRef
433437
LLVMRustCreateAttrNoValue(LLVMContextRef C, LLVMRustAttributeKind RustAttr) {
438+
#if LLVM_VERSION_GE(21, 0)
439+
// LLVM 21 replaced the NoCapture attribute with Captures(none).
440+
if (RustAttr == LLVMRustAttributeKind::NoCapture) {
441+
return wrap(Attribute::getWithCaptureInfo(*unwrap(C), CaptureInfo::none()));
442+
}
443+
#endif
434444
return wrap(Attribute::get(*unwrap(C), fromRust(RustAttr)));
435445
}
436446

tests/codegen/addr-of-mutate.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// Test for the absence of `readonly` on the argument when it is mutated via `&raw const`.
66
// See <https://github.com/rust-lang/rust/issues/111502>.
77

8-
// CHECK: i8 @foo(ptr noalias nocapture noundef align 1 dereferenceable(128) %x)
8+
// CHECK: i8 @foo(ptr noalias{{( nocapture)?}} noundef align 1{{( captures\(none\))?}} dereferenceable(128) %x)
99
#[no_mangle]
1010
pub fn foo(x: [u8; 128]) -> u8 {
1111
let ptr = core::ptr::addr_of!(x).cast_mut();
@@ -15,7 +15,7 @@ pub fn foo(x: [u8; 128]) -> u8 {
1515
x[0]
1616
}
1717

18-
// CHECK: i1 @second(ptr noalias nocapture noundef align {{[0-9]+}} dereferenceable({{[0-9]+}}) %a_ptr_and_b)
18+
// CHECK: i1 @second(ptr noalias{{( nocapture)?}} noundef align {{[0-9]+}}{{( captures\(none\))?}} dereferenceable({{[0-9]+}}) %a_ptr_and_b)
1919
#[no_mangle]
2020
pub unsafe fn second(a_ptr_and_b: (*mut (i32, bool), (i64, bool))) -> bool {
2121
let b_bool_ptr = core::ptr::addr_of!(a_ptr_and_b.1.1).cast_mut();
@@ -24,7 +24,7 @@ pub unsafe fn second(a_ptr_and_b: (*mut (i32, bool), (i64, bool))) -> bool {
2424
}
2525

2626
// If going through a deref (and there are no other mutating accesses), then `readonly` is fine.
27-
// CHECK: i1 @third(ptr noalias nocapture noundef readonly align {{[0-9]+}} dereferenceable({{[0-9]+}}) %a_ptr_and_b)
27+
// CHECK: i1 @third(ptr noalias{{( nocapture)?}} noundef readonly align {{[0-9]+}}{{( captures\(none\))?}} dereferenceable({{[0-9]+}}) %a_ptr_and_b)
2828
#[no_mangle]
2929
pub unsafe fn third(a_ptr_and_b: (*mut (i32, bool), (i64, bool))) -> bool {
3030
let b_bool_ptr = core::ptr::addr_of!((*a_ptr_and_b.0).1).cast_mut();

tests/codegen/cast-target-abi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ pub fn call_fiveu16s() {
392392
}
393393

394394
// CHECK-LABEL: @return_fiveu16s
395-
// CHECK-SAME: (ptr {{.+}} sret([10 x i8]) align [[RUST_ALIGN:2]] dereferenceable(10) [[RET_PTR:%.+]])
395+
// CHECK-SAME: (ptr {{.+}} sret([10 x i8]) align [[RUST_ALIGN:2]] {{.*}}dereferenceable(10) [[RET_PTR:%.+]])
396396
#[no_mangle]
397397
pub fn return_fiveu16s() -> FiveU16s {
398398
// powerpc returns this struct via sret pointer, it doesn't use the cast ABI.

tests/codegen/function-arguments.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ pub fn mutable_notunpin_borrow(_: &mut NotUnpin) {}
135135
#[no_mangle]
136136
pub fn notunpin_borrow(_: &NotUnpin) {}
137137

138-
// CHECK: @indirect_struct(ptr noalias nocapture noundef readonly align 4 dereferenceable(32) %_1)
138+
// CHECK: @indirect_struct(ptr noalias{{( nocapture)?}} noundef readonly align 4{{( captures\(none\))?}} dereferenceable(32) %_1)
139139
#[no_mangle]
140140
pub fn indirect_struct(_: S) {}
141141

@@ -198,7 +198,7 @@ pub fn notunpin_box(x: Box<NotUnpin>) -> Box<NotUnpin> {
198198
x
199199
}
200200

201-
// CHECK: @struct_return(ptr{{( dead_on_unwind)?}} noalias nocapture noundef{{( writable)?}} sret([32 x i8]) align 4 dereferenceable(32){{( %_0)?}})
201+
// CHECK: @struct_return(ptr{{( dead_on_unwind)?}} noalias{{( nocapture)?}} noundef{{( writable)?}} sret([32 x i8]) align 4{{( captures\(none\))?}} dereferenceable(32){{( %_0)?}})
202202
#[no_mangle]
203203
pub fn struct_return() -> S {
204204
S { _field: [0, 0, 0, 0, 0, 0, 0, 0] }

tests/codegen/i128-x86-align.rs

+14-7
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ pub struct ScalarPair {
1919
#[no_mangle]
2020
pub fn load(x: &ScalarPair) -> ScalarPair {
2121
// CHECK-LABEL: @load(
22-
// CHECK-SAME: sret([32 x i8]) align 16 dereferenceable(32) %_0,
23-
// CHECK-SAME: align 16 dereferenceable(32) %x
22+
// CHECK-SAME: sret([32 x i8]) align 16
23+
// CHECK-SAME: dereferenceable(32) %_0,
24+
// CHECK-SAME: align 16
25+
// CHECK-SAME: dereferenceable(32) %x
2426
// CHECK: [[A:%.*]] = load i32, ptr %x, align 16
2527
// CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds i8, ptr %x, i64 16
2628
// CHECK-NEXT: [[B:%.*]] = load i128, ptr [[GEP]], align 16
@@ -34,7 +36,8 @@ pub fn load(x: &ScalarPair) -> ScalarPair {
3436
#[no_mangle]
3537
pub fn store(x: &mut ScalarPair) {
3638
// CHECK-LABEL: @store(
37-
// CHECK-SAME: align 16 dereferenceable(32) %x
39+
// CHECK-SAME: align 16
40+
// CHECK-SAME: dereferenceable(32) %x
3841
// CHECK: store i32 1, ptr %x, align 16
3942
// CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds i8, ptr %x, i64 16
4043
// CHECK-NEXT: store i128 2, ptr [[GEP]], align 16
@@ -55,8 +58,10 @@ pub fn alloca() {
5558
#[no_mangle]
5659
pub fn load_volatile(x: &ScalarPair) -> ScalarPair {
5760
// CHECK-LABEL: @load_volatile(
58-
// CHECK-SAME: sret([32 x i8]) align 16 dereferenceable(32) %_0,
59-
// CHECK-SAME: align 16 dereferenceable(32) %x
61+
// CHECK-SAME: sret([32 x i8]) align 16
62+
// CHECK-SAME: dereferenceable(32) %_0,
63+
// CHECK-SAME: align 16
64+
// CHECK-SAME: dereferenceable(32) %x
6065
// CHECK: [[LOAD:%.*]] = load volatile %ScalarPair, ptr %x, align 16
6166
// CHECK-NEXT: store %ScalarPair [[LOAD]], ptr %_0, align 16
6267
// CHECK-NEXT: ret void
@@ -66,7 +71,8 @@ pub fn load_volatile(x: &ScalarPair) -> ScalarPair {
6671
#[no_mangle]
6772
pub fn transmute(x: ScalarPair) -> (std::mem::MaybeUninit<i128>, i128) {
6873
// CHECK-LABEL: @transmute(
69-
// CHECK-SAME: sret([32 x i8]) align 16 dereferenceable(32) %_0,
74+
// CHECK-SAME: sret([32 x i8]) align 16
75+
// CHECK-SAME: dereferenceable(32) %_0,
7076
// CHECK-SAME: i32 noundef %x.0, i128 noundef %x.1
7177
// CHECK: store i32 %x.0, ptr %_0, align 16
7278
// CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds i8, ptr %_0, i64 16
@@ -86,7 +92,8 @@ pub struct Struct {
8692
#[no_mangle]
8793
pub fn store_struct(x: &mut Struct) {
8894
// CHECK-LABEL: @store_struct(
89-
// CHECK-SAME: align 16 dereferenceable(32) %x
95+
// CHECK-SAME: align 16
96+
// CHECK-SAME: dereferenceable(32) %x
9097
// CHECK: [[TMP:%.*]] = alloca [32 x i8], align 16
9198
// CHECK: store i32 1, ptr [[TMP]], align 16
9299
// CHECK-NEXT: [[GEP1:%.*]] = getelementptr inbounds i8, ptr [[TMP]], i64 4

tests/codegen/loongarch-abi/loongarch64-lp64d-abi.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,11 @@ pub struct IntDoubleInt {
259259
c: i32,
260260
}
261261

262-
// CHECK: define void @f_int_double_int_s_arg(ptr noalias nocapture noundef align 8 dereferenceable(24) %a)
262+
// CHECK: define void @f_int_double_int_s_arg(ptr noalias{{( nocapture)?}} noundef align 8{{( captures\(none\))?}} dereferenceable(24) %a)
263263
#[no_mangle]
264264
pub extern "C" fn f_int_double_int_s_arg(a: IntDoubleInt) {}
265265

266-
// CHECK: define void @f_ret_int_double_int_s(ptr{{( dead_on_unwind)?}} noalias nocapture noundef{{( writable)?}} sret([24 x i8]) align 8 dereferenceable(24) %_0)
266+
// CHECK: define void @f_ret_int_double_int_s(ptr{{( dead_on_unwind)?}} noalias{{( nocapture)?}} noundef{{( writable)?}} sret([24 x i8]) align 8{{( captures\(none\))?}} dereferenceable(24) %_0)
267267
#[no_mangle]
268268
pub extern "C" fn f_ret_int_double_int_s() -> IntDoubleInt {
269269
IntDoubleInt { a: 1, b: 2., c: 3 }

tests/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 [32 x i8]
55-
// CHECK: call void %{{.*}}(ptr noalias nocapture noundef sret{{.*}} dereferenceable(32) [[ALLOCA]])
55+
// CHECK: call void %{{.*}}(ptr{{( captures(none))?}} noalias{{( nocapture)?}} noundef sret{{.*}} dereferenceable(32) [[ALLOCA]])
5656
// CHECK: call void @llvm.memcpy.{{.*}}(ptr align 1 %{{.*}}, ptr 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 [32 x i8]
67-
// CHECK: call void %{{.*}}(ptr noalias nocapture noundef sret{{.*}} dereferenceable(32) [[ALLOCA]])
67+
// CHECK: call void %{{.*}}(ptr{{( captures(none))?}} noalias{{( nocapture)?}} noundef sret{{.*}} dereferenceable(32) [[ALLOCA]])
6868
// CHECK: call void @llvm.memcpy.{{.*}}(ptr align 2 %{{.*}}, ptr 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

tests/codegen/riscv-abi/riscv64-lp64d-abi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ pub struct IntDoubleInt {
263263
#[no_mangle]
264264
pub extern "C" fn f_int_double_int_s_arg(a: IntDoubleInt) {}
265265

266-
// CHECK: define void @f_ret_int_double_int_s(ptr {{.*}} sret([24 x i8]) align 8 dereferenceable(24) %_0)
266+
// CHECK: define void @f_ret_int_double_int_s(ptr {{.*}} sret([24 x i8]) align 8 {{.*}}dereferenceable(24) %_0)
267267
#[no_mangle]
268268
pub extern "C" fn f_ret_int_double_int_s() -> IntDoubleInt {
269269
IntDoubleInt { a: 1, b: 2., c: 3 }

0 commit comments

Comments
 (0)