Closed
Description
It is very easy for the body of bh.iter { ... }
to be turned into a noop by DCE. e.g.
extern mod extra;
use extra::test::BenchHarness;
#[bench]
fn match_option_some(bh: &mut BenchHarness) {
let x = Some(10);
do bh.iter {
let _q = match x {
Some(y) => y,
None => 11
};
}
}
Compiling with rustc -O --emit-llvm -S
, the relevant part of the IR is:
define internal void @_ZN17match_option_some4anon12expr_fn_4234E({ i64, %tydesc*, i8*, i8*, i8 }* nocapture) #2 {
"function top level":
ret void
}
This likely means that quite a few of the benchmarks currently in the tree are pointless.