Change the documented implicit value of -C instrument-coverage to =yes

This commit is contained in:
Zalathar 2023-10-25 14:57:25 +11:00
parent b77e0184a9
commit 9f287dd7b3
7 changed files with 44 additions and 26 deletions

View File

@ -590,7 +590,7 @@ macro_rules! tracked {
tracked!(force_frame_pointers, Some(false));
tracked!(force_unwind_tables, Some(true));
tracked!(inline_threshold, Some(0xf007ba11));
tracked!(instrument_coverage, InstrumentCoverage::All);
tracked!(instrument_coverage, InstrumentCoverage::Yes);
tracked!(link_dead_code, Some(true));
tracked!(linker_plugin_lto, LinkerPluginLto::LinkerPluginAuto);
tracked!(llvm_args, vec![String::from("1"), String::from("2")]);

View File

@ -146,8 +146,10 @@ pub enum LtoCli {
/// unless the function has type parameters.
#[derive(Clone, Copy, PartialEq, Hash, Debug)]
pub enum InstrumentCoverage {
/// Default `-C instrument-coverage` or `-C instrument-coverage=statement`
All,
/// `-C instrument-coverage=no` (or `off`, `false` etc.)
No,
/// `-C instrument-coverage` or `-C instrument-coverage=yes`
Yes,
/// Additionally, instrument branches and output branch coverage.
/// `-Zunstable-options -C instrument-coverage=branch`
Branch,
@ -155,8 +157,6 @@ pub enum InstrumentCoverage {
ExceptUnusedGenerics,
/// `-Zunstable-options -C instrument-coverage=except-unused-functions`
ExceptUnusedFunctions,
/// `-C instrument-coverage=off` (or `no`, etc.)
Off,
}
/// Settings for `-Z instrument-xray` flag.
@ -2722,7 +2722,7 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
// This is what prevents them from being used on stable compilers.
match cg.instrument_coverage {
// Stable values:
InstrumentCoverage::All | InstrumentCoverage::Off => {}
InstrumentCoverage::Yes | InstrumentCoverage::No => {}
// Unstable values:
InstrumentCoverage::Branch
| InstrumentCoverage::ExceptUnusedFunctions
@ -2736,7 +2736,7 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
}
}
if cg.instrument_coverage != InstrumentCoverage::Off {
if cg.instrument_coverage != InstrumentCoverage::No {
if cg.profile_generate.enabled() || cg.profile_use.is_some() {
early_dcx.early_fatal(
"option `-C instrument-coverage` is not compatible with either `-C profile-use` \

View File

@ -394,8 +394,7 @@ mod desc {
pub const parse_linker_flavor: &str = ::rustc_target::spec::LinkerFlavorCli::one_of();
pub const parse_optimization_fuel: &str = "crate=integer";
pub const parse_dump_mono_stats: &str = "`markdown` (default) or `json`";
pub const parse_instrument_coverage: &str =
"`all` (default), `branch`, `except-unused-generics`, `except-unused-functions`, or `off`";
pub const parse_instrument_coverage: &str = "either a boolean (`yes`, `no`, `on`, `off`, etc) or (unstable) one of `branch`, `except-unused-generics`, `except-unused-functions`";
pub const parse_instrument_xray: &str = "either a boolean (`yes`, `no`, `on`, `off`, etc), or a comma separated list of settings: `always` or `never` (mutually exclusive), `ignore-loops`, `instruction-threshold=N`, `skip-entry`, `skip-exit`";
pub const parse_unpretty: &str = "`string` or `string=string`";
pub const parse_treat_err_as_bug: &str = "either no value or a non-negative number";
@ -918,18 +917,18 @@ pub(crate) fn parse_instrument_coverage(
if v.is_some() {
let mut bool_arg = false;
if parse_bool(&mut bool_arg, v) {
*slot = if bool_arg { InstrumentCoverage::All } else { InstrumentCoverage::Off };
*slot = if bool_arg { InstrumentCoverage::Yes } else { InstrumentCoverage::No };
return true;
}
}
let Some(v) = v else {
*slot = InstrumentCoverage::All;
*slot = InstrumentCoverage::Yes;
return true;
};
*slot = match v {
"all" => InstrumentCoverage::All,
"all" => InstrumentCoverage::Yes,
"branch" => InstrumentCoverage::Branch,
"except-unused-generics" | "except_unused_generics" => {
InstrumentCoverage::ExceptUnusedGenerics
@ -937,7 +936,7 @@ pub(crate) fn parse_instrument_coverage(
"except-unused-functions" | "except_unused_functions" => {
InstrumentCoverage::ExceptUnusedFunctions
}
"off" | "no" | "n" | "false" | "0" => InstrumentCoverage::Off,
"0" => InstrumentCoverage::No,
_ => return false,
};
true
@ -1444,15 +1443,15 @@ pub(crate) fn parse_function_return(slot: &mut FunctionReturn, v: Option<&str>)
inline_threshold: Option<u32> = (None, parse_opt_number, [TRACKED],
"set the threshold for inlining a function"),
#[rustc_lint_opt_deny_field_access("use `Session::instrument_coverage` instead of this field")]
instrument_coverage: InstrumentCoverage = (InstrumentCoverage::Off, parse_instrument_coverage, [TRACKED],
instrument_coverage: InstrumentCoverage = (InstrumentCoverage::No, parse_instrument_coverage, [TRACKED],
"instrument the generated code to support LLVM source-based code coverage \
reports (note, the compiler build config must include `profiler = true`); \
implies `-C symbol-mangling-version=v0`. Optional values are:
`=all` (implicit value)
`=branch`
`=except-unused-generics`
`=except-unused-functions`
`=off` (default)"),
`=no` `=n` `=off` `=false` (default)
`=yes` `=y` `=on` `=true` (implicit value)
`=branch` (unstable)
`=except-unused-generics` (unstable)
`=except-unused-functions` (unstable)"),
link_arg: (/* redirected to link_args */) = ((), parse_string_push, [UNTRACKED],
"a single extra argument to append to the linker invocation (can be used several times)"),
link_args: Vec<String> = (Vec::new(), parse_list, [UNTRACKED],

View File

@ -352,7 +352,7 @@ pub fn enable_internal_lints(&self) -> bool {
}
pub fn instrument_coverage(&self) -> bool {
self.opts.cg.instrument_coverage() != InstrumentCoverage::Off
self.opts.cg.instrument_coverage() != InstrumentCoverage::No
}
pub fn instrument_coverage_branch(&self) -> bool {

View File

@ -331,10 +331,29 @@ $ llvm-cov report \
## `-C instrument-coverage=<options>`
- `-C instrument-coverage=all`: Instrument all functions, including unused functions and unused generics. (This is the same as `-C instrument-coverage`, with no value.)
- `-C instrument-coverage=off`: Do not instrument any functions. (This is the same as simply not including the `-C instrument-coverage` option.)
- `-Zunstable-options -C instrument-coverage=except-unused-generics`: Instrument all functions except unused generics.
- `-Zunstable-options -C instrument-coverage=except-unused-functions`: Instrument only used (called) functions and instantiated generic functions.
- `-C instrument-coverage=no` (or `n`/`off`/`false`):
Don't enable coverage instrumentation. No functions will be instrumented for coverage.
- This is the same as not using the `-C instrument-coverage` flag at all.
- `-C instrument-coverage=yes` (or `y`/`on`/`true`):
Enable coverage instrumentation with the default behaviour.
Currently this instruments all functions, including unused functions and unused generics.
- This is the same as `-C instrument-coverage` with no value.
### Other values
- `-C instrument-coverage=all`:
Currently an alias for `yes`, but may behave differently in the future if
more fine-grained coverage options are added.
Using this value is currently not recommended.
### Unstable values
- `-Z unstable-options -C instrument-coverage=branch`:
Placeholder for potential branch coverage support in the future.
- `-Z unstable-options -C instrument-coverage=except-unused-generics`:
Instrument all functions except unused generics.
- `-Z unstable-options -C instrument-coverage=except-unused-functions`:
Instrument only used (called) functions and instantiated generic functions.
## Other references

View File

@ -1,2 +1,2 @@
error: incorrect value `bad-value` for codegen option `instrument-coverage` - `all` (default), `branch`, `except-unused-generics`, `except-unused-functions`, or `off` was expected
error: incorrect value `bad-value` for codegen option `instrument-coverage` - either a boolean (`yes`, `no`, `on`, `off`, etc) or (unstable) one of `branch`, `except-unused-generics`, `except-unused-functions` was expected

View File

@ -1,2 +1,2 @@
error: incorrect value `` for codegen option `instrument-coverage` - `all` (default), `branch`, `except-unused-generics`, `except-unused-functions`, or `off` was expected
error: incorrect value `` for codegen option `instrument-coverage` - either a boolean (`yes`, `no`, `on`, `off`, etc) or (unstable) one of `branch`, `except-unused-generics`, `except-unused-functions` was expected