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
3 changed files with 25 additions and 0 deletions
|
@ -1967,6 +1967,9 @@ extern "C" void LLVMRustContextConfigureDiagnosticHandler(
|
||||||
std::unique_ptr<LLVMRemarkStreamer> LlvmRemarkStreamer;
|
std::unique_ptr<LLVMRemarkStreamer> LlvmRemarkStreamer;
|
||||||
|
|
||||||
if (RemarkFilePath != nullptr) {
|
if (RemarkFilePath != nullptr) {
|
||||||
|
// Enable PGO hotness data for remarks, if available
|
||||||
|
unwrap(C)->setDiagnosticsHotnessRequested(true);
|
||||||
|
|
||||||
std::error_code EC;
|
std::error_code EC;
|
||||||
RemarkFile = std::make_unique<ToolOutputFile>(
|
RemarkFile = std::make_unique<ToolOutputFile>(
|
||||||
RemarkFilePath,
|
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…
Add table
Add a link
Reference in a new issue