librustc: Convert -C pgo-gen and -C pgo-use into -Z flags.

Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
This commit is contained in:
Emilio Cobos Álvarez 2018-03-12 21:11:25 +01:00
parent 036e0d7943
commit 688275a400
No known key found for this signature in database
GPG Key ID: 056B727BB9C1027C
6 changed files with 28 additions and 26 deletions

View File

@ -1027,11 +1027,6 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
"`-C save-temps` might not produce all requested temporary products \
when incremental compilation is enabled.")],
"save all temporary output files during compilation"),
pgo_gen: Option<String> = (None, parse_opt_string, [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],
"Use PGO profile data from the given profile file."),
rpath: bool = (false, parse_bool, [UNTRACKED],
"set rpath values in libs/exes"),
overflow_checks: Option<bool> = (None, parse_opt_bool, [TRACKED],
@ -1254,6 +1249,11 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
"extra arguments to prepend to the linker invocation (space separated)"),
profile: bool = (false, parse_bool, [TRACKED],
"insert profiling code"),
pgo_gen: Option<String> = (None, parse_opt_string, [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],
"Use PGO profile data from the given profile file."),
relro_level: Option<RelroLevel> = (None, parse_relro_level, [TRACKED],
"choose which RELRO level to use"),
nll: bool = (false, parse_bool, [UNTRACKED],
@ -1776,6 +1776,13 @@ pub fn build_session_options_and_crate_config(
);
}
if debugging_opts.pgo_gen.is_some() && !debugging_opts.pgo_use.is_empty() {
early_error(
error_format,
"options `-Z pgo-gen` and `-Z pgo-use` are exclusive",
);
}
let mut output_types = BTreeMap::new();
if !debugging_opts.parse_only {
for list in matches.opt_strs("emit") {
@ -1806,13 +1813,6 @@ pub fn build_session_options_and_crate_config(
let mut codegen_units = cg.codegen_units;
let mut disable_thinlto = false;
if cg.pgo_gen.is_some() && !cg.pgo_use.is_empty() {
early_error(
error_format,
"options `-C pgo-gen` and `-C pgo-use` are exclussive",
);
}
// Issue #30063: if user requests llvm-related output to one
// particular path, disable codegen-units.
let incompatible: Vec<_> = output_types
@ -2836,14 +2836,6 @@ mod tests {
opts.cg.lto = Lto::Fat;
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
opts = reference.clone();
opts.cg.pgo_gen = Some(String::from("abc"));
assert_ne!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
opts = reference.clone();
opts.cg.pgo_use = String::from("abc");
assert_ne!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
opts = reference.clone();
opts.cg.target_cpu = Some(String::from("abc"));
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
@ -2904,6 +2896,14 @@ mod tests {
opts.debugging_opts.tls_model = Some(String::from("tls model"));
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
opts = reference.clone();
opts.debugging_opts.pgo_gen = Some(String::from("abc"));
assert_ne!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
opts = reference.clone();
opts.debugging_opts.pgo_use = String::from("abc");
assert_ne!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
opts = reference.clone();
opts.cg.metadata = vec![String::from("A"), String::from("B")];
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());

View File

@ -785,7 +785,7 @@ impl<'a> CrateLoader<'a> {
fn inject_profiler_runtime(&mut self) {
if self.sess.opts.debugging_opts.profile ||
self.sess.opts.cg.pgo_gen.is_some()
self.sess.opts.debugging_opts.pgo_gen.is_some()
{
info!("loading profiler");

View File

@ -93,7 +93,7 @@ pub fn set_probestack(cx: &CodegenCx, llfn: ValueRef) {
}
// probestack doesn't play nice either with pgo-gen.
if cx.sess().opts.cg.pgo_gen.is_some() {
if cx.sess().opts.debugging_opts.pgo_gen.is_some() {
return;
}

View File

@ -1095,7 +1095,9 @@ fn link_args(cmd: &mut Linker,
//
// Though it may be worth to try to revert those changes upstream, since the
// overhead of the initialization should be minor.
if sess.opts.cg.pgo_gen.is_some() && sess.target.target.options.linker_is_gnu {
if sess.opts.debugging_opts.pgo_gen.is_some() &&
sess.target.target.options.linker_is_gnu
{
cmd.args(&["-u".to_owned(), "__llvm_profile_runtime".to_owned()]);
}

View File

@ -943,8 +943,8 @@ pub fn start_async_translation(tcx: TyCtxt,
modules_config.passes.push("insert-gcov-profiling".to_owned())
}
modules_config.pgo_gen = sess.opts.cg.pgo_gen.clone();
modules_config.pgo_use = sess.opts.cg.pgo_use.clone();
modules_config.pgo_gen = sess.opts.debugging_opts.pgo_gen.clone();
modules_config.pgo_use = sess.opts.debugging_opts.pgo_use.clone();
modules_config.opt_level = Some(get_llvm_opt_level(sess.opts.optimize));
modules_config.opt_size = Some(get_llvm_opt_size(sess.opts.optimize));

View File

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