about summary refs log tree commit diff
path: root/tests/run-make/optimization-remarks-dir/rmake.rs
blob: df656302d789c59466175538b79ac7b5cd541ba9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//@ needs-target-std
//
// In this test, the function `bar` has #[inline(never)] and the function `foo`
// does not. This test outputs LLVM optimization remarks twice - first for all
// functions (including `bar`, and the `inline` mention), and then for only `foo`
// (should not have the `inline` mention).
// See https://github.com/rust-lang/rust/pull/113040

use run_make_support::{
    has_extension, has_prefix, invalid_utf8_contains, invalid_utf8_not_contains, not_contains,
    rustc, shallow_find_files,
};

fn main() {
    rustc()
        .opt()
        .input("foo.rs")
        .crate_type("lib")
        .arg("-Cremark=all")
        .arg("-Zremark-dir=profiles_all")
        .run();
    let all_remark_files = shallow_find_files("profiles_all", |path| {
        has_prefix(path, "foo") && has_extension(path, "yaml") && not_contains(path, "codegen")
    });
    for file in all_remark_files {
        invalid_utf8_contains(file, "inline")
    }
    rustc()
        .opt()
        .input("foo.rs")
        .crate_type("lib")
        .arg("-Cremark=foo")
        .arg("-Zremark-dir=profiles_foo")
        .run();
    let foo_remark_files = shallow_find_files("profiles_foo", |path| {
        has_prefix(path, "foo") && has_extension(path, "yaml")
    });
    for file in foo_remark_files {
        invalid_utf8_not_contains(file, "inline")
    }
}