Skip to content

Commit

Permalink
fix(tests): dead_code
Browse files Browse the repository at this point in the history
  • Loading branch information
mkroening committed Jan 2, 2025
1 parent 479b3f6 commit f10a7ea
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 14 deletions.
6 changes: 0 additions & 6 deletions tests/basic_math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ use core::hint::black_box;

use common::exit;

// Either use black_box from core::hint or the value_fence definition
// core hint is a nop, but possibly only prevents dead code elimination
// value_fence has higher overhead but should be a bit safer regarding preventing optimizations
// pub fn black_box<T>(x: T) -> T {
// common::value_fence::<T>(x)
// }
mod common;

#[test_case]
Expand Down
8 changes: 0 additions & 8 deletions tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,3 @@ macro_rules! runtime_entry_with_args {
}
};
}

//adapted from: https://rust-lang.github.io/rfcs/2360-bench-black-box.html
#[inline(always)]
pub fn value_fence<T>(x: T) -> T {
let y = unsafe { (&x as *const T).read_volatile() };
//std::hint::forget(x); - doesn't exist (anymore)
y
}

0 comments on commit f10a7ea

Please sign in to comment.