Skip to content

Commit 3246ebc

Browse files
committed
rustup: update to nightly-2024-05-01.
1 parent d5fd255 commit 3246ebc

File tree

4 files changed

+74
-57
lines changed

4 files changed

+74
-57
lines changed

crates/rustc_codegen_spirv/build.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ use std::{env, fs, mem};
1515
/// `cargo publish`. We need to figure out a way to do this properly, but let's hardcode it for now :/
1616
//const REQUIRED_RUST_TOOLCHAIN: &str = include_str!("../../rust-toolchain.toml");
1717
const REQUIRED_RUST_TOOLCHAIN: &str = r#"[toolchain]
18-
channel = "nightly-2024-04-24"
18+
channel = "nightly-2024-05-01"
1919
components = ["rust-src", "rustc-dev", "llvm-tools"]
20-
# commit_hash = 244da22fabd9fa677bbd0ac601a88e5ca6917526"#;
20+
# commit_hash = f705de59625bb76067a5d102edc1575ff23b8845"#;
2121

2222
fn rustc_output(arg: &str) -> Result<String, Box<dyn Error>> {
2323
let rustc = env::var("RUSTC").unwrap_or_else(|_| "rustc".into());
@@ -187,6 +187,13 @@ mod win {",
187187
fn typed_alloca(&mut self, ty: Self::Type, align: Align) -> Self::Value;
188188
fn alloca(",
189189
);
190+
} else if relative_path == Path::new("src/mir/place.rs") {
191+
src = src.replace(
192+
"alloca(layout.size,",
193+
"typed_alloca(bx.cx().backend_type(layout),",
194+
);
195+
} else if relative_path == Path::new("src/mir/operand.rs") {
196+
src = src.replace("alloca(field.size,", "typed_alloca(llfield_ty,");
190197
}
191198

192199
fs::write(out_path, src)?;

crates/rustc_codegen_spirv/src/builder/builder_methods.rs

Lines changed: 45 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
339339
let exit_bb = self.append_sibling_block("memset_exit");
340340

341341
let count = self.udiv(size_bytes, size_elem_const);
342-
let index = self.alloca(count.ty, zero_align);
342+
let index = self.alloca(self.lookup_type(count.ty).sizeof(self).unwrap(), zero_align);
343343
self.store(zero, index, zero_align);
344344
self.br(header_bb);
345345

@@ -919,6 +919,45 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
919919
s1
920920
}
921921
}
922+
923+
// HACK(eddyb) helper shared by `typed_alloca` and `alloca`.
924+
fn declare_func_local_var(
925+
&mut self,
926+
ty: <Self as BackendTypes>::Type,
927+
_align: Align,
928+
) -> SpirvValue {
929+
let ptr_ty = self.type_ptr_to(ty);
930+
931+
// "All OpVariable instructions in a function must be the first instructions in the first block."
932+
let mut builder = self.emit();
933+
builder.select_block(Some(0)).unwrap();
934+
let index = {
935+
let block = &builder.module_ref().functions[builder.selected_function().unwrap()]
936+
.blocks[builder.selected_block().unwrap()];
937+
block
938+
.instructions
939+
.iter()
940+
.enumerate()
941+
.find_map(|(index, inst)| {
942+
if inst.class.opcode != Op::Variable {
943+
Some(InsertPoint::FromBegin(index))
944+
} else {
945+
None
946+
}
947+
})
948+
.unwrap_or(InsertPoint::End)
949+
};
950+
// TODO: rspirv doesn't have insert_variable function
951+
let result_id = builder.id();
952+
let inst = Instruction::new(
953+
Op::Variable,
954+
Some(ptr_ty),
955+
Some(result_id),
956+
vec![Operand::StorageClass(StorageClass::Function)],
957+
);
958+
builder.insert_into_block(index, inst).unwrap();
959+
result_id.with_type(ptr_ty)
960+
}
922961
}
923962

924963
impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
@@ -1418,43 +1457,14 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
14181457
// HACK(eddyb) new method patched into `pqp_cg_ssa` (see `build.rs`).
14191458
#[cfg(not(rustc_codegen_spirv_disable_pqp_cg_ssa))]
14201459
fn typed_alloca(&mut self, ty: Self::Type, align: Align) -> Self::Value {
1421-
self.alloca(ty, align)
1460+
self.declare_func_local_var(ty, align)
14221461
}
1423-
fn alloca(&mut self, ty: Self::Type, _align: Align) -> Self::Value {
1424-
let ptr_ty = self.type_ptr_to(ty);
1425-
// "All OpVariable instructions in a function must be the first instructions in the first block."
1426-
let mut builder = self.emit();
1427-
builder.select_block(Some(0)).unwrap();
1428-
let index = {
1429-
let block = &builder.module_ref().functions[builder.selected_function().unwrap()]
1430-
.blocks[builder.selected_block().unwrap()];
1431-
block
1432-
.instructions
1433-
.iter()
1434-
.enumerate()
1435-
.find_map(|(index, inst)| {
1436-
if inst.class.opcode != Op::Variable {
1437-
Some(InsertPoint::FromBegin(index))
1438-
} else {
1439-
None
1440-
}
1441-
})
1442-
.unwrap_or(InsertPoint::End)
1443-
};
1444-
// TODO: rspirv doesn't have insert_variable function
1445-
let result_id = builder.id();
1446-
let inst = Instruction::new(
1447-
Op::Variable,
1448-
Some(ptr_ty),
1449-
Some(result_id),
1450-
vec![Operand::StorageClass(StorageClass::Function)],
1451-
);
1452-
builder.insert_into_block(index, inst).unwrap();
1453-
result_id.with_type(ptr_ty)
1462+
fn alloca(&mut self, size: Size, align: Align) -> Self::Value {
1463+
self.declare_func_local_var(self.type_array(self.type_i8(), size.bytes()), align)
14541464
}
14551465

1456-
fn byte_array_alloca(&mut self, _len: Self::Value, _align: Align) -> Self::Value {
1457-
self.fatal("array alloca not supported yet")
1466+
fn dynamic_alloca(&mut self, _len: Self::Value, _align: Align) -> Self::Value {
1467+
self.fatal("dynamic alloca not supported yet")
14581468
}
14591469

14601470
fn load(&mut self, ty: Self::Type, ptr: Self::Value, _align: Align) -> Self::Value {

rust-toolchain.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[toolchain]
2-
channel = "nightly-2024-04-24"
2+
channel = "nightly-2024-05-01"
33
components = ["rust-src", "rustc-dev", "llvm-tools"]
4-
# commit_hash = 244da22fabd9fa677bbd0ac601a88e5ca6917526
4+
# commit_hash = f705de59625bb76067a5d102edc1575ff23b8845
55

66
# Whenever changing the nightly channel, update the commit hash above, and make
77
# sure to change `REQUIRED_TOOLCHAIN` in `crates/rustc_codegen_spirv/build.rs` also.

tests/ui/dis/ptr_copy.normal.stderr

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error: cannot memcpy dynamically sized data
2-
--> $CORE_SRC/intrinsics.rs:3076:9
2+
--> $CORE_SRC/intrinsics.rs:3111:9
33
|
4-
3076 | copy(src, dst, count)
4+
3111 | copy(src, dst, count)
55
| ^^^^^^^^^^^^^^^^^^^^^
66
|
77
note: used from within `core::intrinsics::copy::<f32>`
8-
--> $CORE_SRC/intrinsics.rs:3055:21
8+
--> $CORE_SRC/intrinsics.rs:3090:21
99
|
10-
3055 | pub const unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) {
10+
3090 | pub const unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) {
1111
| ^^^^
1212
note: called by `ptr_copy::copy_via_raw_ptr`
1313
--> $DIR/ptr_copy.rs:28:18
@@ -28,27 +28,27 @@ note: called by `main`
2828
error: cannot cast between pointer types
2929
from `*f32`
3030
to `*struct () { }`
31-
--> $CORE_SRC/intrinsics.rs:3064:9
31+
--> $CORE_SRC/intrinsics.rs:3099:9
3232
|
33-
3064 | / ub_checks::assert_unsafe_precondition!(
34-
3065 | | check_language_ub,
35-
3066 | | "ptr::copy_nonoverlapping requires that both pointer arguments are aligned and non-null /
36-
3067 | | and the specified memory ranges do not overlap",
33+
3099 | / ub_checks::assert_unsafe_precondition!(
34+
3100 | | check_language_ub,
35+
3101 | | "ptr::copy_nonoverlapping requires that both pointer arguments are aligned and non-null /
36+
3102 | | and the specified memory ranges do not overlap",
3737
... |
38-
3074 | | && ub_checks::is_aligned_and_not_null(dst, align)
39-
3075 | | );
38+
3109 | | && ub_checks::is_aligned_and_not_null(dst, align)
39+
3110 | | );
4040
| |_________^
4141
|
4242
note: used from within `core::intrinsics::copy::<f32>`
43-
--> $CORE_SRC/intrinsics.rs:3064:9
43+
--> $CORE_SRC/intrinsics.rs:3099:9
4444
|
45-
3064 | / ub_checks::assert_unsafe_precondition!(
46-
3065 | | check_language_ub,
47-
3066 | | "ptr::copy_nonoverlapping requires that both pointer arguments are aligned and non-null /
48-
3067 | | and the specified memory ranges do not overlap",
45+
3099 | / ub_checks::assert_unsafe_precondition!(
46+
3100 | | check_language_ub,
47+
3101 | | "ptr::copy_nonoverlapping requires that both pointer arguments are aligned and non-null /
48+
3102 | | and the specified memory ranges do not overlap",
4949
... |
50-
3074 | | && ub_checks::is_aligned_and_not_null(dst, align)
51-
3075 | | );
50+
3109 | | && ub_checks::is_aligned_and_not_null(dst, align)
51+
3110 | | );
5252
| |_________^
5353
note: called by `ptr_copy::copy_via_raw_ptr`
5454
--> $DIR/ptr_copy.rs:28:18

0 commit comments

Comments
 (0)