Add rustc
option to output LLVM optimization remarks to YAML files
This commit is contained in:
parent
8882507bc7
commit
62728c7aaf
11 changed files with 180 additions and 13 deletions
|
@ -21,6 +21,8 @@ codegen_ssa_create_temp_dir = couldn't create a temp dir: {$error}
|
|||
|
||||
codegen_ssa_erroneous_constant = erroneous constant encountered
|
||||
|
||||
codegen_ssa_error_creating_remark_dir = failed to create remark directory: {$error}
|
||||
|
||||
codegen_ssa_expected_used_symbol = expected `used`, `used(compiler)` or `used(linker)`
|
||||
|
||||
codegen_ssa_extern_funcs_not_found = some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
|
||||
|
|
|
@ -35,6 +35,7 @@ use rustc_span::symbol::sym;
|
|||
use rustc_span::{BytePos, FileName, InnerSpan, Pos, Span};
|
||||
use rustc_target::spec::{MergeFunctions, SanitizerSet};
|
||||
|
||||
use crate::errors::ErrorCreatingRemarkDir;
|
||||
use std::any::Any;
|
||||
use std::borrow::Cow;
|
||||
use std::fs;
|
||||
|
@ -345,6 +346,9 @@ pub struct CodegenContext<B: WriteBackendMethods> {
|
|||
pub diag_emitter: SharedEmitter,
|
||||
/// LLVM optimizations for which we want to print remarks.
|
||||
pub remark: Passes,
|
||||
/// Directory into which should the LLVM optimization remarks be written.
|
||||
/// If `None`, they will be written to stderr.
|
||||
pub remark_dir: Option<PathBuf>,
|
||||
/// Worker thread number
|
||||
pub worker: usize,
|
||||
/// The incremental compilation session directory, or None if we are not
|
||||
|
@ -1041,6 +1045,17 @@ fn start_executing_work<B: ExtraBackendMethods>(
|
|||
tcx.backend_optimization_level(())
|
||||
};
|
||||
let backend_features = tcx.global_backend_features(());
|
||||
|
||||
let remark_dir = if let Some(ref dir) = sess.opts.unstable_opts.remark_dir {
|
||||
let result = fs::create_dir_all(dir).and_then(|_| dir.canonicalize());
|
||||
match result {
|
||||
Ok(dir) => Some(dir),
|
||||
Err(error) => sess.emit_fatal(ErrorCreatingRemarkDir { error }),
|
||||
}
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let cgcx = CodegenContext::<B> {
|
||||
crate_types: sess.crate_types().to_vec(),
|
||||
each_linked_rlib_for_lto,
|
||||
|
@ -1052,6 +1067,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
|
|||
prof: sess.prof.clone(),
|
||||
exported_symbols,
|
||||
remark: sess.opts.cg.remark.clone(),
|
||||
remark_dir,
|
||||
worker: 0,
|
||||
incr_comp_session_dir: sess.incr_comp_session_dir_opt().map(|r| r.clone()),
|
||||
cgu_reuse_tracker: sess.cgu_reuse_tracker.clone(),
|
||||
|
|
|
@ -1023,3 +1023,9 @@ pub struct TargetFeatureSafeTrait {
|
|||
#[label(codegen_ssa_label_def)]
|
||||
pub def: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_ssa_error_creating_remark_dir)]
|
||||
pub struct ErrorCreatingRemarkDir {
|
||||
pub error: std::io::Error,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue