@@ -1221,7 +1221,11 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
12211221 linker_plugin_lto: LinkerPluginLto = ( LinkerPluginLto :: Disabled ,
12221222 parse_linker_plugin_lto, [ TRACKED ] ,
12231223 "generate build artifacts that are compatible with linker-based LTO." ) ,
1224-
1224+ profile_generate: SwitchWithOptPath = ( SwitchWithOptPath :: Disabled ,
1225+ parse_switch_with_opt_path, [ TRACKED ] ,
1226+ "compile the program with profiling instrumentation" ) ,
1227+ profile_use: Option <PathBuf > = ( None , parse_opt_pathbuf, [ TRACKED ] ,
1228+ "use the given `.profdata` file for profile-guided optimization" ) ,
12251229}
12261230
12271231options ! { DebuggingOptions , DebuggingSetter , basic_debugging_options,
@@ -1395,11 +1399,6 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
13951399 "extra arguments to prepend to the linker invocation (space separated)" ) ,
13961400 profile: bool = ( false , parse_bool, [ TRACKED ] ,
13971401 "insert profiling code" ) ,
1398- pgo_gen: SwitchWithOptPath = ( SwitchWithOptPath :: Disabled ,
1399- parse_switch_with_opt_path, [ TRACKED ] ,
1400- "Generate PGO profile data, to a given file, or to the default location if it's empty." ) ,
1401- pgo_use: Option <PathBuf > = ( None , parse_opt_pathbuf, [ TRACKED ] ,
1402- "Use PGO profile data from the given profile file." ) ,
14031402 disable_instrumentation_preinliner: bool = ( false , parse_bool, [ TRACKED ] ,
14041403 "Disable the instrumentation pre-inliner, useful for profiling / PGO." ) ,
14051404 relro_level: Option <RelroLevel > = ( None , parse_relro_level, [ TRACKED ] ,
@@ -2052,13 +2051,6 @@ pub fn build_session_options_and_crate_config(
20522051 }
20532052 }
20542053
2055- if debugging_opts. pgo_gen . enabled ( ) && debugging_opts. pgo_use . is_some ( ) {
2056- early_error (
2057- error_format,
2058- "options `-Z pgo-gen` and `-Z pgo-use` are exclusive" ,
2059- ) ;
2060- }
2061-
20622054 let mut output_types = BTreeMap :: new ( ) ;
20632055 if !debugging_opts. parse_only {
20642056 for list in matches. opt_strs ( "emit" ) {
@@ -2170,6 +2162,13 @@ pub fn build_session_options_and_crate_config(
21702162 ) ;
21712163 }
21722164
2165+ if cg. profile_generate . enabled ( ) && cg. profile_use . is_some ( ) {
2166+ early_error (
2167+ error_format,
2168+ "options `-C profile-generate` and `-C profile-use` are exclusive" ,
2169+ ) ;
2170+ }
2171+
21732172 let mut prints = Vec :: < PrintRequest > :: new ( ) ;
21742173 if cg. target_cpu . as_ref ( ) . map_or ( false , |s| s == "help" ) {
21752174 prints. push ( PrintRequest :: TargetCPUs ) ;
0 commit comments