rewrite optimization-remarks-dir-pgo to rmake

This commit is contained in:
Oneirical 2024-06-19 14:06:17 -04:00
parent 40cad01f2f
commit 73d7dc7f22
3 changed files with 19 additions and 18 deletions

View File

@ -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

View File

@ -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"

View File

@ -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");
}