1
Fork 0

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`
This commit is contained in:
bors 2023-08-08 15:41:44 +00:00
commit f525bb4e2a
5 changed files with 36 additions and 1 deletions

View file

@ -320,6 +320,7 @@ impl<'a> DiagnosticHandlers<'a> {
})
.and_then(|dir| dir.to_str().and_then(|p| CString::new(p).ok()));
let pgo_available = cgcx.opts.cg.profile_use.is_some();
let data = Box::into_raw(Box::new((cgcx, handler)));
unsafe {
let old_handler = llvm::LLVMRustContextGetDiagnosticHandler(llcx);
@ -333,6 +334,7 @@ impl<'a> DiagnosticHandlers<'a> {
// The `as_ref()` is important here, otherwise the `CString` will be dropped
// too soon!
remark_file.as_ref().map(|dir| dir.as_ptr()).unwrap_or(std::ptr::null()),
pgo_available,
);
DiagnosticHandlers { data, llcx, old_handler }
}

View file

@ -2332,6 +2332,7 @@ extern "C" {
remark_passes: *const *const c_char,
remark_passes_len: usize,
remark_file: *const c_char,
pgo_available: bool,
);
#[allow(improper_ctypes)]