librustc_llvm: Show PGO diagnostics properly.

Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
This commit is contained in:
Emilio Cobos Álvarez 2018-03-12 18:11:59 +01:00
parent aaeb40ab3b
commit a95c8c66a7
No known key found for this signature in database
GPG Key ID: 056B727BB9C1027C
4 changed files with 16 additions and 2 deletions

View File

@ -121,6 +121,7 @@ impl InlineAsmDiagnostic {
pub enum Diagnostic {
Optimization(OptimizationDiagnostic),
InlineAsm(InlineAsmDiagnostic),
PGO(DiagnosticInfoRef),
/// LLVM has other types that we do not wrap here.
UnknownDiagnostic(DiagnosticInfoRef),
@ -160,6 +161,10 @@ impl Diagnostic {
Optimization(OptimizationDiagnostic::unpack(OptimizationFailure, di))
}
Dk::PGOProfile => {
PGO(di)
}
_ => UnknownDiagnostic(di),
}
}

View File

@ -322,6 +322,7 @@ pub enum DiagnosticKind {
OptimizationRemarkAnalysisAliasing,
OptimizationRemarkOther,
OptimizationFailure,
PGOProfile,
}
/// LLVMRustArchiveKind

View File

@ -498,8 +498,13 @@ unsafe extern "C" fn diagnostic_handler(info: DiagnosticInfoRef, user: *mut c_vo
opt.message));
}
}
_ => (),
llvm::diagnostic::PGO(diagnostic_ref) => {
let msg = llvm::build_string(|s| {
llvm::LLVMRustWriteDiagnosticInfoToString(diagnostic_ref, s)
}).expect("non-UTF8 PGO diagnostic");
diag_handler.note_without_error(&msg);
}
llvm::diagnostic::UnknownDiagnostic(..) => {},
}
}

View File

@ -1021,6 +1021,7 @@ enum class LLVMRustDiagnosticKind {
OptimizationRemarkAnalysisAliasing,
OptimizationRemarkOther,
OptimizationFailure,
PGOProfile,
};
static LLVMRustDiagnosticKind toRust(DiagnosticKind Kind) {
@ -1043,6 +1044,8 @@ static LLVMRustDiagnosticKind toRust(DiagnosticKind Kind) {
return LLVMRustDiagnosticKind::OptimizationRemarkAnalysisFPCommute;
case DK_OptimizationRemarkAnalysisAliasing:
return LLVMRustDiagnosticKind::OptimizationRemarkAnalysisAliasing;
case DK_PGOProfile:
return LLVMRustDiagnosticKind::PGOProfile;
default:
return (Kind >= DK_FirstRemark && Kind <= DK_LastRemark)
? LLVMRustDiagnosticKind::OptimizationRemarkOther