Skip to content

Commit e020f88

Browse files
committed
add a fallback implementation for the prefetch_* intrinsics
The fallback is to just ignore the arguments. That is a valid implementation because this intrinsic is just a hint. I also added `miri::intrinsic_fallback_is_spec` annotation, so that miri now supports these operations. A prefetch intrinsic call is valid on any pointer.
1 parent ce946a6 commit e020f88

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/pass/prefetch.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#![feature(core_intrinsics)]
2+
3+
fn main() {
4+
static X: [u8; 8] = [0; 8];
5+
6+
unsafe {
7+
::std::intrinsics::prefetch_read_data(::std::ptr::null::<u8>(), 1);
8+
::std::intrinsics::prefetch_read_data(::std::ptr::dangling::<u8>(), 2);
9+
::std::intrinsics::prefetch_read_data(X.as_ptr(), 3);
10+
11+
::std::intrinsics::prefetch_write_data(::std::ptr::null::<u8>(), 1);
12+
::std::intrinsics::prefetch_write_data(::std::ptr::dangling::<u8>(), 2);
13+
::std::intrinsics::prefetch_write_data(X.as_ptr(), 3);
14+
15+
::std::intrinsics::prefetch_read_instruction(::std::ptr::null::<u8>(), 1);
16+
::std::intrinsics::prefetch_read_instruction(::std::ptr::dangling::<u8>(), 2);
17+
::std::intrinsics::prefetch_read_instruction(X.as_ptr(), 3);
18+
19+
::std::intrinsics::prefetch_write_instruction(::std::ptr::null::<u8>(), 1);
20+
::std::intrinsics::prefetch_write_instruction(::std::ptr::dangling::<u8>(), 2);
21+
::std::intrinsics::prefetch_write_instruction(X.as_ptr(), 3);
22+
}
23+
}

0 commit comments

Comments
 (0)