Only enable hotness information when PGO is available

This commit is contained in:
Jakub Beránek 2023-08-07 17:56:57 +02:00
parent 93bdc01adf
commit 9d417d7c86
No known key found for this signature in database
GPG key ID: 909CD0D26483516B
4 changed files with 13 additions and 3 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 }
}