From 73d7dc7f220c8e451defc1f3817b99ed70079a4e Mon Sep 17 00:00:00 2001 From: Oneirical Date: Wed, 19 Jun 2024 14:06:17 -0400 Subject: [PATCH] rewrite optimization-remarks-dir-pgo to rmake --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - .../optimization-remarks-dir-pgo/Makefile | 17 ----------------- .../optimization-remarks-dir-pgo/rmake.rs | 19 +++++++++++++++++++ 3 files changed, 19 insertions(+), 18 deletions(-) delete mode 100644 tests/run-make/optimization-remarks-dir-pgo/Makefile create mode 100644 tests/run-make/optimization-remarks-dir-pgo/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 6d1355981866..e26a1326f443 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-pgo/Makefile run-make/optimization-remarks-dir/Makefile run-make/output-type-permutations/Makefile run-make/panic-abort-eh_frame/Makefile diff --git a/tests/run-make/optimization-remarks-dir-pgo/Makefile b/tests/run-make/optimization-remarks-dir-pgo/Makefile deleted file mode 100644 index 57ffd6e70f00..000000000000 --- a/tests/run-make/optimization-remarks-dir-pgo/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -# needs-profiler-support -# ignore-cross-compile - -include ../tools.mk - -PROFILE_DIR=$(TMPDIR)/profiles - -check_hotness: - $(RUSTC) -Cprofile-generate="$(TMPDIR)"/profdata -O foo.rs -o$(TMPDIR)/foo - $(TMPDIR)/foo - "$(LLVM_BIN_DIR)"/llvm-profdata merge \ - -o "$(TMPDIR)"/merged.profdata \ - "$(TMPDIR)"/profdata/*.profraw - $(RUSTC) -Cprofile-use=$(TMPDIR)/merged.profdata -O foo.rs -Cremark=all -Zremark-dir=$(PROFILE_DIR) - - # Check that PGO hotness is included in the remark files - cat $(PROFILE_DIR)/*.opt.yaml | $(CGREP) -e "Hotness" diff --git a/tests/run-make/optimization-remarks-dir-pgo/rmake.rs b/tests/run-make/optimization-remarks-dir-pgo/rmake.rs new file mode 100644 index 000000000000..678d9c2de8b4 --- /dev/null +++ b/tests/run-make/optimization-remarks-dir-pgo/rmake.rs @@ -0,0 +1,19 @@ +// This test checks the -Zremark-dir flag, which writes LLVM +// optimization remarks to the YAML format. When using PGO (Profile +// Guided Optimization), the Hotness attribute should be included in +// the output remark files. +// See https://github.com/rust-lang/rust/pull/114439 + +//@ needs-profiler-support +//@ ignore-cross-compile + +use run_make_support::{run, llvm_profdata, rustc, invalid_utf8_contains}; + +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(); + // Check that PGO hotness is included in the remark files + invalid_utf8_contains("profiles/foo.cba44757bc0621b9-cgu.0.opt.opt.yaml", "Hotness"); +}