diff --git a/src/shims/foreign_items.rs b/src/shims/foreign_items.rs index 7e7f17b0dbd..e816a35253d 100644 --- a/src/shims/foreign_items.rs +++ b/src/shims/foreign_items.rs @@ -434,10 +434,19 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx } // Target-specific shims - _ => match this.tcx.sess.target.target.target_os.as_str() { - "linux" | "macos" => return posix::EvalContextExt::emulate_foreign_item_by_name(this, link_name, args, dest, ret), - "windows" => return windows::EvalContextExt::emulate_foreign_item_by_name(this, link_name, args, dest, ret), - target => throw_unsup_format!("the target `{}` is not supported", target), + _ => { + match this.tcx.sess.target.target.arch.as_str() { + "x86" | "x86_64" => match link_name { + "llvm.x86.sse2.pause" => return Ok(true), + _ => {} + } + _ => {} + } + match this.tcx.sess.target.target.target_os.as_str() { + "linux" | "macos" => return posix::EvalContextExt::emulate_foreign_item_by_name(this, link_name, args, dest, ret), + "windows" => return windows::EvalContextExt::emulate_foreign_item_by_name(this, link_name, args, dest, ret), + target => throw_unsup_format!("the target `{}` is not supported", target), + } } }; diff --git a/tests/run-pass/sync.rs b/tests/run-pass/sync.rs index 1ede5d42bb4..90885880e68 100644 --- a/tests/run-pass/sync.rs +++ b/tests/run-pass/sync.rs @@ -1,6 +1,7 @@ #![feature(rustc_private)] use std::sync::{Mutex, TryLockError}; +use std::sync::atomic; fn main() { test_mutex_stdlib(); @@ -8,6 +9,7 @@ fn main() { { test_rwlock_stdlib(); } + test_spin_loop_hint(); } fn test_mutex_stdlib() { @@ -50,3 +52,7 @@ impl TryLockErrorExt for TryLockError { } } } + +fn test_spin_loop_hint() { + atomic::spin_loop_hint(); +}