make black_box a NOP in Miri
This commit is contained in:
parent
e61621c307
commit
8385146ffa
1 changed files with 3 additions and 1 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue