Skip to content

Commit e943426

Browse files
Use a PathBuf instead of String for representing the pgo-use path internally.
1 parent ab7cf71 commit e943426

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

src/librustc/session/config.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1381,7 +1381,7 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
13811381
"insert profiling code"),
13821382
pgo_gen: PgoGenerate = (PgoGenerate::Disabled, parse_pgo_generate, [TRACKED],
13831383
"Generate PGO profile data, to a given file, or to the default location if it's empty."),
1384-
pgo_use: String = (String::new(), parse_string, [TRACKED],
1384+
pgo_use: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
13851385
"Use PGO profile data from the given profile file."),
13861386
disable_instrumentation_preinliner: bool = (false, parse_bool, [TRACKED],
13871387
"Disable the instrumentation pre-inliner, useful for profiling / PGO."),
@@ -2021,7 +2021,7 @@ pub fn build_session_options_and_crate_config(
20212021
}
20222022
}
20232023

2024-
if debugging_opts.pgo_gen.enabled() && !debugging_opts.pgo_use.is_empty() {
2024+
if debugging_opts.pgo_gen.enabled() && debugging_opts.pgo_use.is_some() {
20252025
early_error(
20262026
error_format,
20272027
"options `-Z pgo-gen` and `-Z pgo-use` are exclusive",

src/librustc_codegen_llvm/back/write.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -721,11 +721,9 @@ pub unsafe fn with_llvm_pmb(llmod: &llvm::Module,
721721
}
722722
};
723723

724-
let pgo_use_path = if config.pgo_use.is_empty() {
725-
None
726-
} else {
727-
Some(CString::new(config.pgo_use.as_bytes()).unwrap())
728-
};
724+
let pgo_use_path = config.pgo_use.as_ref().map(|path_buf| {
725+
CString::new(path_buf.to_string_lossy().as_bytes()).unwrap()
726+
});
729727

730728
llvm::LLVMRustConfigurePassManagerBuilder(
731729
builder,

src/librustc_codegen_ssa/back/write.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub struct ModuleConfig {
5757
pub opt_size: Option<config::OptLevel>,
5858

5959
pub pgo_gen: PgoGenerate,
60-
pub pgo_use: String,
60+
pub pgo_use: Option<PathBuf>,
6161

6262
// Flags indicating which outputs to produce.
6363
pub emit_pre_lto_bc: bool,
@@ -95,7 +95,7 @@ impl ModuleConfig {
9595
opt_size: None,
9696

9797
pgo_gen: PgoGenerate::Disabled,
98-
pgo_use: String::new(),
98+
pgo_use: None,
9999

100100
emit_no_opt_bc: false,
101101
emit_pre_lto_bc: false,

0 commit comments

Comments
 (0)