Skip to content

hint: Make spin_loop_hint a side-effect for all targets #77924

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions library/core/src/hint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ pub fn spin_loop() {
unsafe { crate::arch::arm::__yield() };
}
}
// This makes sure that spin_loop is always a side-effect on all platfomrs,
// allowing users to work around https://github.com/rust-lang/rust/issues/28728
// Remove when that bug is fixed.
#[cfg(not(miri))]
// SAFETY: the inline assembly is a no-op.
unsafe {
// FIXME: Cannot use `asm!` because it doesn't support MIPS and other architectures.
llvm_asm!("" : : : : "volatile");
}
}

/// An identity function that *__hints__* to the compiler to be maximally pessimistic about what
Expand Down