mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
Add hotness data to LLVM remarks
This makes sure that if PGO is used, remarks generated using `-Zremark-dir` will include the `Hotness` attribute.
This commit is contained in:
parent
2e6ac7fe5b
commit
93bdc01adf
@ -1967,6 +1967,9 @@ extern "C" void LLVMRustContextConfigureDiagnosticHandler(
|
||||
std::unique_ptr<LLVMRemarkStreamer> LlvmRemarkStreamer;
|
||||
|
||||
if (RemarkFilePath != nullptr) {
|
||||
// Enable PGO hotness data for remarks, if available
|
||||
unwrap(C)->setDiagnosticsHotnessRequested(true);
|
||||
|
||||
std::error_code EC;
|
||||
RemarkFile = std::make_unique<ToolOutputFile>(
|
||||
RemarkFilePath,
|
||||
|
16
tests/run-make/optimization-remarks-dir-pgo/Makefile
Normal file
16
tests/run-make/optimization-remarks-dir-pgo/Makefile
Normal file
@ -0,0 +1,16 @@
|
||||
# needs-profiler-support
|
||||
|
||||
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"
|
6
tests/run-make/optimization-remarks-dir-pgo/foo.rs
Normal file
6
tests/run-make/optimization-remarks-dir-pgo/foo.rs
Normal file
@ -0,0 +1,6 @@
|
||||
#[inline(never)]
|
||||
pub fn bar() {}
|
||||
|
||||
fn main() {
|
||||
bar();
|
||||
}
|
Loading…
Reference in New Issue
Block a user