about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <emilio@crisal.io>2018-03-12 21:11:25 +0100
committerEmilio Cobos Álvarez <emilio@crisal.io>2018-03-25 03:30:06 +0200
commit688275a4009a7a87fb211f0b690f386fc2de8740 (patch)
tree858fdce83c1fbc85db0fcf3433fd670af3bc6863
parent036e0d7943f274fc3269a9cd67d2c922e397fcaf (diff)
downloadrust-688275a4009a7a87fb211f0b690f386fc2de8740.tar.gz
rust-688275a4009a7a87fb211f0b690f386fc2de8740.zip
librustc: Convert -C pgo-gen and -C pgo-use into -Z flags.
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
-rw-r--r--src/librustc/session/config.rs40
-rw-r--r--src/librustc_metadata/creader.rs2
-rw-r--r--src/librustc_trans/attributes.rs2
-rw-r--r--src/librustc_trans/back/link.rs4
-rw-r--r--src/librustc_trans/back/write.rs4
-rw-r--r--src/test/run-make/pgo-gen/Makefile2
6 files changed, 28 insertions, 26 deletions
diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs
index e5d7a618b35..7f92a087ebf 100644
--- a/src/librustc/session/config.rs
+++ b/src/librustc/session/config.rs
@@ -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
@@ -2837,14 +2837,6 @@ mod tests {
         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());
 
@@ -2905,6 +2897,14 @@ mod tests {
         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());
 
diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs
index 812bbf29cf1..802665b6ddb 100644
--- a/src/librustc_metadata/creader.rs
+++ b/src/librustc_metadata/creader.rs
@@ -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");
 
diff --git a/src/librustc_trans/attributes.rs b/src/librustc_trans/attributes.rs
index f53c1e84f6e..c968b8525a5 100644
--- a/src/librustc_trans/attributes.rs
+++ b/src/librustc_trans/attributes.rs
@@ -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;
     }
 
diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs
index 657563eac2c..19f0d5866ef 100644
--- a/src/librustc_trans/back/link.rs
+++ b/src/librustc_trans/back/link.rs
@@ -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()]);
     }
 
diff --git a/src/librustc_trans/back/write.rs b/src/librustc_trans/back/write.rs
index 99558652d69..26cdca1cdbf 100644
--- a/src/librustc_trans/back/write.rs
+++ b/src/librustc_trans/back/write.rs
@@ -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));
diff --git a/src/test/run-make/pgo-gen/Makefile b/src/test/run-make/pgo-gen/Makefile
index a6b7b2c02b2..bc5cef2370c 100644
--- a/src/test/run-make/pgo-gen/Makefile
+++ b/src/test/run-make/pgo-gen/Makefile
@@ -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