]> git.lizzy.rs Git - rust.git/commitdiff
librustc: Convert -C pgo-gen and -C pgo-use into -Z flags.
authorEmilio Cobos Álvarez <emilio@crisal.io>
Mon, 12 Mar 2018 20:11:25 +0000 (21:11 +0100)
committerEmilio Cobos Álvarez <emilio@crisal.io>
Sun, 25 Mar 2018 01:30:06 +0000 (03:30 +0200)
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
src/librustc/session/config.rs
src/librustc_metadata/creader.rs
src/librustc_trans/attributes.rs
src/librustc_trans/back/link.rs
src/librustc_trans/back/write.rs
src/test/run-make/pgo-gen/Makefile

index e5d7a618b355dc7ac38578804357bd98b63e902d..7f92a087ebfc8680b84d75c353a4908e0af8a263 100644 (file)
@@ -1027,11 +1027,6 @@ fn parse_edition(slot: &mut Edition, v: Option<&str>) -> bool {
         "`-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 @@ fn parse_edition(slot: &mut Edition, v: Option<&str>) -> bool {
         "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 @@ fn test_codegen_options_tracking_hash() {
         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 @@ fn test_codegen_options_tracking_hash() {
         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());
index 812bbf29cf19efee7cb446142ab9f1ae6fad57ea..802665b6ddbc51937c52265e6cf59fa45ce3c9b1 100644 (file)
@@ -785,7 +785,7 @@ fn inject_sanitizer_runtime(&mut self) {
 
     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");
 
index f53c1e84f6e8edeb9dd168c8c356e1c7746ecc39..c968b8525a5b1c90784cffbb335192e20a0ff611 100644 (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;
     }
 
index 657563eac2cf8718ee33b979efde473196ee76c8..19f0d5866ef3497ef2387a2cb1b471e83413b542 100644 (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()]);
     }
 
index 99558652d69097563103eede355c0db7a61d9ba5..26cdca1cdbf4d8639f7935c53826c5fe69a62d74 100644 (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));
index a6b7b2c02b287abb816cdc2def4f826b3aa06ab4..bc5cef2370c644641d0ed40c2e9d4082dc40de08 100644 (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