about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-08-08 15:41:44 +0000
committerbors <bors@rust-lang.org>2023-08-08 15:41:44 +0000
commitf525bb4e2afac6d2491a86c178aa98e3f3931130 (patch)
treed44d3c836016870be589a48d9df7e4b6d222b123 /tests
parentbf62436bce9668118bc4d5f7795f08745d478ac0 (diff)
parent9d417d7c86259498855fc50ba0e853edbb13320d (diff)
downloadrust-f525bb4e2afac6d2491a86c178aa98e3f3931130.tar.gz
rust-f525bb4e2afac6d2491a86c178aa98e3f3931130.zip
Auto merge of #114439 - Kobzol:remark-pgo-hotness, r=tmiasko
Add hotness data to LLVM remarks

Slight improvement of https://github.com/rust-lang/rust/pull/113040. This makes sure that if PGO is used, remarks generated using `-Zremark-dir` will include the `Hotness` attribute.

r? `@tmiasko`
Diffstat (limited to 'tests')
-rw-r--r--tests/run-make/optimization-remarks-dir-pgo/Makefile20
-rw-r--r--tests/run-make/optimization-remarks-dir-pgo/foo.rs6
2 files changed, 26 insertions, 0 deletions
diff --git a/tests/run-make/optimization-remarks-dir-pgo/Makefile b/tests/run-make/optimization-remarks-dir-pgo/Makefile
new file mode 100644
index 00000000000..c88ec1e6cb3
--- /dev/null
+++ b/tests/run-make/optimization-remarks-dir-pgo/Makefile
@@ -0,0 +1,20 @@
+# needs-profiler-support
+# ignore-windows-gnu
+
+# FIXME(mati865): MinGW GCC miscompiles compiler-rt profiling library but with Clang it works
+# properly. Since we only have GCC on the CI ignore the test for now.
+
+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/foo.rs b/tests/run-make/optimization-remarks-dir-pgo/foo.rs
new file mode 100644
index 00000000000..f7ca1826338
--- /dev/null
+++ b/tests/run-make/optimization-remarks-dir-pgo/foo.rs
@@ -0,0 +1,6 @@
+#[inline(never)]
+pub fn bar() {}
+
+fn main() {
+    bar();
+}