From 651f02363d96ce75ae297d70104153a8b3b0981f Mon Sep 17 00:00:00 2001 From: Oneirical Date: Wed, 19 Jun 2024 14:30:47 -0400 Subject: [PATCH] rewrite optimization-remarks-dir to rmake --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - .../optimization-remarks-dir-pgo/rmake.rs | 16 +++++++++--- .../optimization-remarks-dir/Makefile | 12 --------- .../optimization-remarks-dir/rmake.rs | 26 +++++++++++++++++++ 4 files changed, 39 insertions(+), 16 deletions(-) delete mode 100644 tests/run-make/optimization-remarks-dir/Makefile create mode 100644 tests/run-make/optimization-remarks-dir/rmake.rs diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index e26a1326f44..4516bf86e2b 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -101,7 +101,6 @@ run-make/no-alloc-shim/Makefile run-make/no-builtins-attribute/Makefile run-make/no-duplicate-libs/Makefile run-make/obey-crate-type-flag/Makefile -run-make/optimization-remarks-dir/Makefile run-make/output-type-permutations/Makefile run-make/panic-abort-eh_frame/Makefile run-make/pass-linker-flags-flavor/Makefile diff --git a/tests/run-make/optimization-remarks-dir-pgo/rmake.rs b/tests/run-make/optimization-remarks-dir-pgo/rmake.rs index 678d9c2de8b..e527dcb0bef 100644 --- a/tests/run-make/optimization-remarks-dir-pgo/rmake.rs +++ b/tests/run-make/optimization-remarks-dir-pgo/rmake.rs @@ -7,13 +7,23 @@ //@ needs-profiler-support //@ ignore-cross-compile -use run_make_support::{run, llvm_profdata, rustc, invalid_utf8_contains}; +use run_make_support::{invalid_utf8_contains, llvm_profdata, run, rustc}; fn main() { rustc().profile_generate("profdata").opt().input("foo.rs").output("foo").run(); run("foo"); - llvm_profdata().merge().output("merged.profdata").input("profdata/default_15907418011457399462_0.profraw").run(); - rustc().profile_use("merged.profdata").opt().input("foo.rs").arg("-Cremark=all").arg("-Zremark-dir=profiles").run(); + llvm_profdata() + .merge() + .output("merged.profdata") + .input("profdata/default_15907418011457399462_0.profraw") + .run(); + rustc() + .profile_use("merged.profdata") + .opt() + .input("foo.rs") + .arg("-Cremark=all") + .arg("-Zremark-dir=profiles") + .run(); // Check that PGO hotness is included in the remark files invalid_utf8_contains("profiles/foo.cba44757bc0621b9-cgu.0.opt.opt.yaml", "Hotness"); } diff --git a/tests/run-make/optimization-remarks-dir/Makefile b/tests/run-make/optimization-remarks-dir/Makefile deleted file mode 100644 index a8342c8ad14..00000000000 --- a/tests/run-make/optimization-remarks-dir/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -include ../tools.mk - -PROFILE_DIR=$(TMPDIR)/profiles - -all: check_inline check_filter - -check_inline: - $(RUSTC) -O foo.rs --crate-type=lib -Cremark=all -Zremark-dir=$(PROFILE_DIR) - cat $(PROFILE_DIR)/*.opt.yaml | $(CGREP) -e "inline" -check_filter: - $(RUSTC) -O foo.rs --crate-type=lib -Cremark=foo -Zremark-dir=$(PROFILE_DIR) - cat $(PROFILE_DIR)/*.opt.yaml | $(CGREP) -e -v "inline" diff --git a/tests/run-make/optimization-remarks-dir/rmake.rs b/tests/run-make/optimization-remarks-dir/rmake.rs new file mode 100644 index 00000000000..d0c4ccd72d1 --- /dev/null +++ b/tests/run-make/optimization-remarks-dir/rmake.rs @@ -0,0 +1,26 @@ +// 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::{invalid_utf8_contains, invalid_utf8_not_contains, rustc}; + +fn main() { + rustc() + .opt() + .input("foo.rs") + .crate_type("lib") + .arg("-Cremark=all") + .arg("-Zremark-dir=profiles_all") + .run(); + invalid_utf8_contains("profiles_all/foo.5be5606e1f6aa79b-cgu.0.opt.opt.yaml", "inline"); + rustc() + .opt() + .input("foo.rs") + .crate_type("lib") + .arg("-Cremark=foo") + .arg("-Zremark-dir=profiles_foo") + .run(); + invalid_utf8_not_contains("profiles_foo/foo.5be5606e1f6aa79b-cgu.0.opt.opt.yaml", "inline"); +}