Skip to content

Commit ebc94fb

Browse files
committed
update cranelift to match new write_bytes signature
1 parent 115aeee commit ebc94fb

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

compiler/rustc_codegen_cranelift/example/mini_core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ pub mod intrinsics {
666666
#[rustc_intrinsic]
667667
pub fn bswap<T>(x: T) -> T;
668668
#[rustc_intrinsic]
669-
pub unsafe fn write_bytes<T>(dst: *mut T, val: u8, count: usize);
669+
pub unsafe fn write_bytes<T, B>(dst: *mut T, val: B, count: usize);
670670
#[rustc_intrinsic]
671671
pub unsafe fn unreachable() -> !;
672672
}

compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ static NUM_REF: &'static u8 = unsafe { &*&raw const NUM };
125125

126126
unsafe fn zeroed<T>() -> T {
127127
let mut uninit = MaybeUninit { uninit: () };
128-
intrinsics::write_bytes(&mut uninit.value.value as *mut T, 0, 1);
128+
intrinsics::write_bytes(&mut uninit.value.value as *mut T, 0u8, 1);
129129
uninit.value.value
130130
}
131131

compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,12 @@ fn codegen_regular_intrinsic_call<'tcx>(
685685

686686
sym::write_bytes | sym::volatile_set_memory => {
687687
intrinsic_args!(fx, args => (dst, val, count); intrinsic);
688+
if val.layout().size.bytes() != 1 {
689+
// incorrect sizes can be encountered on dead branches
690+
fx.bcx.ins().trap(TrapCode::user(1).unwrap());
691+
return Ok(());
692+
};
693+
688694
let val = val.load_scalar(fx);
689695
let count = count.load_scalar(fx);
690696

0 commit comments

Comments
 (0)