mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-25 05:14:27 +00:00
make black_box a NOP in Miri
This commit is contained in:
parent
e61621c307
commit
8385146ffa
@ -119,9 +119,11 @@ pub fn black_box<T>(dummy: T) -> T {
|
|||||||
// box. This isn't the greatest implementation since it probably deoptimizes
|
// box. This isn't the greatest implementation since it probably deoptimizes
|
||||||
// more than we want, but it's so far good enough.
|
// more than we want, but it's so far good enough.
|
||||||
|
|
||||||
|
#[cfg(not(miri))] // This is just a hint, so it is fine to skip in Miri.
|
||||||
// SAFETY: the inline assembly is a no-op.
|
// SAFETY: the inline assembly is a no-op.
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm_asm!("" : : "r"(&dummy));
|
llvm_asm!("" : : "r"(&dummy));
|
||||||
dummy
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dummy
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user