Navigation Menu

Skip to content

Commit

Permalink
Use a PathBuf instead of String for representing the pgo-use path int…
Browse files Browse the repository at this point in the history
…ernally.
  • Loading branch information
michaelwoerister committed May 27, 2019
1 parent ab7cf71 commit e943426
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/librustc/session/config.rs
Expand Up @@ -1381,7 +1381,7 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
"insert profiling code"),
pgo_gen: PgoGenerate = (PgoGenerate::Disabled, parse_pgo_generate, [TRACKED],
"Generate PGO profile data, to a given file, or to the default location if it's empty."),
pgo_use: String = (String::new(), parse_string, [TRACKED],
pgo_use: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
"Use PGO profile data from the given profile file."),
disable_instrumentation_preinliner: bool = (false, parse_bool, [TRACKED],
"Disable the instrumentation pre-inliner, useful for profiling / PGO."),
Expand Down Expand Up @@ -2021,7 +2021,7 @@ pub fn build_session_options_and_crate_config(
}
}

if debugging_opts.pgo_gen.enabled() && !debugging_opts.pgo_use.is_empty() {
if debugging_opts.pgo_gen.enabled() && debugging_opts.pgo_use.is_some() {
early_error(
error_format,
"options `-Z pgo-gen` and `-Z pgo-use` are exclusive",
Expand Down
8 changes: 3 additions & 5 deletions src/librustc_codegen_llvm/back/write.rs
Expand Up @@ -721,11 +721,9 @@ pub unsafe fn with_llvm_pmb(llmod: &llvm::Module,
}
};

let pgo_use_path = if config.pgo_use.is_empty() {
None
} else {
Some(CString::new(config.pgo_use.as_bytes()).unwrap())
};
let pgo_use_path = config.pgo_use.as_ref().map(|path_buf| {
CString::new(path_buf.to_string_lossy().as_bytes()).unwrap()
});

llvm::LLVMRustConfigurePassManagerBuilder(
builder,
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_codegen_ssa/back/write.rs
Expand Up @@ -57,7 +57,7 @@ pub struct ModuleConfig {
pub opt_size: Option<config::OptLevel>,

pub pgo_gen: PgoGenerate,
pub pgo_use: String,
pub pgo_use: Option<PathBuf>,

// Flags indicating which outputs to produce.
pub emit_pre_lto_bc: bool,
Expand Down Expand Up @@ -95,7 +95,7 @@ impl ModuleConfig {
opt_size: None,

pgo_gen: PgoGenerate::Disabled,
pgo_use: String::new(),
pgo_use: None,

emit_no_opt_bc: false,
emit_pre_lto_bc: false,
Expand Down

0 comments on commit e943426

Please sign in to comment.