@@ -127,15 +127,15 @@ pub enum MirSpanview {
127127 Block ,
128128}
129129
130- /// The different settings that the `-Z instrument-coverage` flag can have.
130+ /// The different settings that the `-C instrument-coverage` flag can have.
131131///
132- /// Coverage instrumentation now supports combining `-Z instrument-coverage`
132+ /// Coverage instrumentation now supports combining `-C instrument-coverage`
133133/// with compiler and linker optimization (enabled with `-O` or `-C opt-level=1`
134134/// and higher). Nevertheless, there are many variables, depending on options
135135/// selected, code structure, and enabled attributes. If errors are encountered,
136136/// either while compiling or when generating `llvm-cov show` reports, consider
137137/// lowering the optimization level, including or excluding `-C link-dead-code`,
138- /// or using `-Z instrument-coverage=except-unused-functions` or `-Z
138+ /// or using `-C instrument-coverage=except-unused-functions` or `-C
139139/// instrument-coverage=except-unused-generics`.
140140///
141141/// Note that `ExceptUnusedFunctions` means: When `mapgen.rs` generates the
@@ -148,13 +148,13 @@ pub enum MirSpanview {
148148/// unless the function has type parameters.
149149#[ derive( Clone , Copy , PartialEq , Hash , Debug ) ]
150150pub enum InstrumentCoverage {
151- /// Default `-Z instrument-coverage` or `-Z instrument-coverage=statement`
151+ /// Default `-C instrument-coverage` or `-C instrument-coverage=statement`
152152 All ,
153- /// `-Z instrument-coverage=except-unused-generics`
153+ /// `-C instrument-coverage=except-unused-generics`
154154 ExceptUnusedGenerics ,
155- /// `-Z instrument-coverage=except-unused-functions`
155+ /// `-C instrument-coverage=except-unused-functions`
156156 ExceptUnusedFunctions ,
157- /// `-Z instrument-coverage=off` (or `no`, etc.)
157+ /// `-C instrument-coverage=off` (or `no`, etc.)
158158 Off ,
159159}
160160
@@ -2144,18 +2144,37 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
21442144 _ => { }
21452145 }
21462146
2147- if debugging_opts. instrument_coverage . is_some ( )
2148- && debugging_opts. instrument_coverage != Some ( InstrumentCoverage :: Off )
2149- {
2147+ // Handle both `-Z instrument-coverage` and `-C instrument-coverage`; the latter takes
2148+ // precedence.
2149+ match ( cg. instrument_coverage , debugging_opts. instrument_coverage ) {
2150+ ( Some ( ic_c) , Some ( ic_z) ) if ic_c != ic_z => {
2151+ early_error (
2152+ error_format,
2153+ "incompatible values passed for `-C instrument-coverage` \
2154+ and `-Z instrument-coverage`",
2155+ ) ;
2156+ }
2157+ ( None , None ) => { }
2158+ ( None , ic) => {
2159+ early_warn (
2160+ error_format,
2161+ "`-Z instrument-coverage` is deprecated; use `-C instrument-coverage`" ,
2162+ ) ;
2163+ cg. instrument_coverage = ic;
2164+ }
2165+ _ => { }
2166+ }
2167+
2168+ if cg. instrument_coverage . is_some ( ) && cg. instrument_coverage != Some ( InstrumentCoverage :: Off ) {
21502169 if cg. profile_generate . enabled ( ) || cg. profile_use . is_some ( ) {
21512170 early_error (
21522171 error_format,
2153- "option `-Z instrument-coverage` is not compatible with either `-C profile-use` \
2172+ "option `-C instrument-coverage` is not compatible with either `-C profile-use` \
21542173 or `-C profile-generate`",
21552174 ) ;
21562175 }
21572176
2158- // `-Z instrument-coverage` implies `-C symbol-mangling-version=v0` - to ensure consistent
2177+ // `-C instrument-coverage` implies `-C symbol-mangling-version=v0` - to ensure consistent
21592178 // and reversible name mangling. Note, LLVM coverage tools can analyze coverage over
21602179 // multiple runs, including some changes to source code; so mangled names must be consistent
21612180 // across compilations.
@@ -2164,7 +2183,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
21642183 Some ( SymbolManglingVersion :: Legacy ) => {
21652184 early_warn (
21662185 error_format,
2167- "-Z instrument-coverage requires symbol mangling version `v0`, \
2186+ "-C instrument-coverage requires symbol mangling version `v0`, \
21682187 but `-C symbol-mangling-version=legacy` was specified",
21692188 ) ;
21702189 }
0 commit comments