Skip to content

Dead code elimination in benchmarks #8261

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-testsuiteArea: The testsuite used to check the correctness of rustc

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions