Skip to content

Commit 688275a

Browse files
committed
librustc: Convert -C pgo-gen and -C pgo-use into -Z flags.
Signed-off-by: Emilio Cobos Álvarez <[email protected]>
1 parent 036e0d7 commit 688275a

File tree

6 files changed

+28
-26
lines changed

6 files changed

+28
-26
lines changed

src/librustc/session/config.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,11 +1027,6 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
10271027
"`-C save-temps` might not produce all requested temporary products \
10281028
when incremental compilation is enabled.")],
10291029
"save all temporary output files during compilation"),
1030-
pgo_gen: Option<String> = (None, parse_opt_string, [TRACKED],
1031-
"Generate PGO profile data, to a given file, or to the default \
1032-
location if it's empty."),
1033-
pgo_use: String = (String::new(), parse_string, [TRACKED],
1034-
"Use PGO profile data from the given profile file."),
10351030
rpath: bool = (false, parse_bool, [UNTRACKED],
10361031
"set rpath values in libs/exes"),
10371032
overflow_checks: Option<bool> = (None, parse_opt_bool, [TRACKED],
@@ -1254,6 +1249,11 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
12541249
"extra arguments to prepend to the linker invocation (space separated)"),
12551250
profile: bool = (false, parse_bool, [TRACKED],
12561251
"insert profiling code"),
1252+
pgo_gen: Option<String> = (None, parse_opt_string, [TRACKED],
1253+
"Generate PGO profile data, to a given file, or to the default \
1254+
location if it's empty."),
1255+
pgo_use: String = (String::new(), parse_string, [TRACKED],
1256+
"Use PGO profile data from the given profile file."),
12571257
relro_level: Option<RelroLevel> = (None, parse_relro_level, [TRACKED],
12581258
"choose which RELRO level to use"),
12591259
nll: bool = (false, parse_bool, [UNTRACKED],
@@ -1776,6 +1776,13 @@ pub fn build_session_options_and_crate_config(
17761776
);
17771777
}
17781778

1779+
if debugging_opts.pgo_gen.is_some() && !debugging_opts.pgo_use.is_empty() {
1780+
early_error(
1781+
error_format,
1782+
"options `-Z pgo-gen` and `-Z pgo-use` are exclusive",
1783+
);
1784+
}
1785+
17791786
let mut output_types = BTreeMap::new();
17801787
if !debugging_opts.parse_only {
17811788
for list in matches.opt_strs("emit") {
@@ -1806,13 +1813,6 @@ pub fn build_session_options_and_crate_config(
18061813
let mut codegen_units = cg.codegen_units;
18071814
let mut disable_thinlto = false;
18081815

1809-
if cg.pgo_gen.is_some() && !cg.pgo_use.is_empty() {
1810-
early_error(
1811-
error_format,
1812-
"options `-C pgo-gen` and `-C pgo-use` are exclussive",
1813-
);
1814-
}
1815-
18161816
// Issue #30063: if user requests llvm-related output to one
18171817
// particular path, disable codegen-units.
18181818
let incompatible: Vec<_> = output_types
@@ -2836,14 +2836,6 @@ mod tests {
28362836
opts.cg.lto = Lto::Fat;
28372837
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
28382838

2839-
opts = reference.clone();
2840-
opts.cg.pgo_gen = Some(String::from("abc"));
2841-
assert_ne!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
2842-
2843-
opts = reference.clone();
2844-
opts.cg.pgo_use = String::from("abc");
2845-
assert_ne!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
2846-
28472839
opts = reference.clone();
28482840
opts.cg.target_cpu = Some(String::from("abc"));
28492841
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
@@ -2904,6 +2896,14 @@ mod tests {
29042896
opts.debugging_opts.tls_model = Some(String::from("tls model"));
29052897
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
29062898

2899+
opts = reference.clone();
2900+
opts.debugging_opts.pgo_gen = Some(String::from("abc"));
2901+
assert_ne!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
2902+
2903+
opts = reference.clone();
2904+
opts.debugging_opts.pgo_use = String::from("abc");
2905+
assert_ne!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
2906+
29072907
opts = reference.clone();
29082908
opts.cg.metadata = vec![String::from("A"), String::from("B")];
29092909
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());

src/librustc_metadata/creader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ impl<'a> CrateLoader<'a> {
785785

786786
fn inject_profiler_runtime(&mut self) {
787787
if self.sess.opts.debugging_opts.profile ||
788-
self.sess.opts.cg.pgo_gen.is_some()
788+
self.sess.opts.debugging_opts.pgo_gen.is_some()
789789
{
790790
info!("loading profiler");
791791

src/librustc_trans/attributes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ pub fn set_probestack(cx: &CodegenCx, llfn: ValueRef) {
9393
}
9494

9595
// probestack doesn't play nice either with pgo-gen.
96-
if cx.sess().opts.cg.pgo_gen.is_some() {
96+
if cx.sess().opts.debugging_opts.pgo_gen.is_some() {
9797
return;
9898
}
9999

src/librustc_trans/back/link.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1095,7 +1095,9 @@ fn link_args(cmd: &mut Linker,
10951095
//
10961096
// Though it may be worth to try to revert those changes upstream, since the
10971097
// overhead of the initialization should be minor.
1098-
if sess.opts.cg.pgo_gen.is_some() && sess.target.target.options.linker_is_gnu {
1098+
if sess.opts.debugging_opts.pgo_gen.is_some() &&
1099+
sess.target.target.options.linker_is_gnu
1100+
{
10991101
cmd.args(&["-u".to_owned(), "__llvm_profile_runtime".to_owned()]);
11001102
}
11011103

src/librustc_trans/back/write.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -943,8 +943,8 @@ pub fn start_async_translation(tcx: TyCtxt,
943943
modules_config.passes.push("insert-gcov-profiling".to_owned())
944944
}
945945

946-
modules_config.pgo_gen = sess.opts.cg.pgo_gen.clone();
947-
modules_config.pgo_use = sess.opts.cg.pgo_use.clone();
946+
modules_config.pgo_gen = sess.opts.debugging_opts.pgo_gen.clone();
947+
modules_config.pgo_use = sess.opts.debugging_opts.pgo_use.clone();
948948

949949
modules_config.opt_level = Some(get_llvm_opt_level(sess.opts.optimize));
950950
modules_config.opt_size = Some(get_llvm_opt_size(sess.opts.optimize));

src/test/run-make/pgo-gen/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
all:
44
ifeq ($(PROFILER_SUPPORT),1)
5-
$(RUSTC) -g -C pgo-gen=test.profraw test.rs
5+
$(RUSTC) -g -Z pgo-gen=test.profraw test.rs
66
$(call RUN,test) || exit 1
77
[ -e "$(TMPDIR)/test.profraw" ] || (echo "No .profraw file"; exit 1)
88
endif

0 commit comments

Comments
 (0)