about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/tools/tidy/src/allowed_run_make_makefiles.txt1
-rw-r--r--tests/run-make/optimization-remarks-dir-pgo/Makefile17
-rw-r--r--tests/run-make/optimization-remarks-dir-pgo/rmake.rs19
3 files changed, 19 insertions, 18 deletions
diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt
index 6d135598186..e26a1326f44 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 57ffd6e70f0..00000000000
--- 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 00000000000..678d9c2de8b
--- /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");
+}