Skip to content

Commit 00ac29d

Browse files
committed
Output LLVM optimization remark kind in -Cremark output
1 parent 6f8c055 commit 00ac29d

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

compiler/rustc_codegen_llvm/messages.ftl

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ codegen_llvm_prepare_thin_lto_module_with_llvm_err = failed to prepare thin LTO
8282
codegen_llvm_parse_bitcode = failed to parse bitcode for LTO module
8383
codegen_llvm_parse_bitcode_with_llvm_err = failed to parse bitcode for LTO module: {$llvm_err}
8484
85-
codegen_llvm_from_llvm_optimization_diag = {$filename}:{$line}:{$column} {$pass_name}: {$message}
85+
codegen_llvm_from_llvm_optimization_diag = {$filename}:{$line}:{$column} {$pass_name} ({$kind}): {$message}
8686
codegen_llvm_from_llvm_diag = {$message}
8787
8888
codegen_llvm_write_bytecode = failed to write bytecode to {$path}: {$err}

compiler/rustc_codegen_llvm/src/back/write.rs

+10
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ use rustc_span::symbol::sym;
3131
use rustc_span::InnerSpan;
3232
use rustc_target::spec::{CodeModel, RelocModel, SanitizerSet, SplitDebuginfo};
3333

34+
use crate::llvm::diagnostic::OptimizationDiagnosticKind;
3435
use libc::{c_char, c_int, c_uint, c_void, size_t};
3536
use std::ffi::CString;
3637
use std::fs;
@@ -363,6 +364,15 @@ unsafe extern "C" fn diagnostic_handler(info: &DiagnosticInfo, user: *mut c_void
363364
line: opt.line,
364365
column: opt.column,
365366
pass_name: &opt.pass_name,
367+
kind: match opt.kind {
368+
OptimizationDiagnosticKind::OptimizationRemark => "success",
369+
OptimizationDiagnosticKind::OptimizationMissed
370+
| OptimizationDiagnosticKind::OptimizationFailure => "missed",
371+
OptimizationDiagnosticKind::OptimizationAnalysis
372+
| OptimizationDiagnosticKind::OptimizationAnalysisFPCommute
373+
| OptimizationDiagnosticKind::OptimizationAnalysisAliasing => "analysis",
374+
OptimizationDiagnosticKind::OptimizationRemarkOther => "other",
375+
},
366376
message: &opt.message,
367377
});
368378
}

compiler/rustc_codegen_llvm/src/errors.rs

+1
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ pub(crate) struct FromLlvmOptimizationDiag<'a> {
195195
pub line: std::ffi::c_uint,
196196
pub column: std::ffi::c_uint,
197197
pub pass_name: &'a str,
198+
pub kind: &'a str,
198199
pub message: &'a str,
199200
}
200201

tests/ui/optimization-remark.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// [merge1] compile-flags: -Cremark=all -Cremark=giraffe
1414
// [merge2] compile-flags: -Cremark=inline -Cremark=giraffe
1515
//
16-
// error-pattern: inline: 'f' not inlined into 'g'
16+
// error-pattern: inline (missed): 'f' not inlined into 'g'
1717
// dont-check-compiler-stderr
1818

1919
#[no_mangle]

0 commit comments

Comments
 (0)