Skip to content

Commit 4152c4d

Browse files
committed
Introduce -C instrument-coverage=branch to gate branch coverage
1 parent 81b59a7 commit 4152c4d

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

compiler/rustc_session/src/config.rs

+2
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ pub enum MirSpanview {
168168
pub enum InstrumentCoverage {
169169
/// Default `-C instrument-coverage` or `-C instrument-coverage=statement`
170170
All,
171+
/// Additionally, instrument branches and output branch overage
172+
Branch,
171173
/// `-Zunstable-options -C instrument-coverage=except-unused-generics`
172174
ExceptUnusedGenerics,
173175
/// `-Zunstable-options -C instrument-coverage=except-unused-functions`

compiler/rustc_session/src/options.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ mod desc {
382382
pub const parse_mir_spanview: &str = "`statement` (default), `terminator`, or `block`";
383383
pub const parse_dump_mono_stats: &str = "`markdown` (default) or `json`";
384384
pub const parse_instrument_coverage: &str =
385-
"`all` (default), `except-unused-generics`, `except-unused-functions`, or `off`";
385+
"`all` (default), `branch`, `except-unused-generics`, `except-unused-functions`, or `off`";
386386
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`";
387387
pub const parse_unpretty: &str = "`string` or `string=string`";
388388
pub const parse_treat_err_as_bug: &str = "either no value or a number bigger than 0";
@@ -895,6 +895,7 @@ mod parse {
895895

896896
*slot = Some(match v {
897897
"all" => InstrumentCoverage::All,
898+
"branch" => InstrumentCoverage::Branch,
898899
"except-unused-generics" | "except_unused_generics" => {
899900
InstrumentCoverage::ExceptUnusedGenerics
900901
}
@@ -1299,6 +1300,7 @@ options! {
12991300
reports (note, the compiler build config must include `profiler = true`); \
13001301
implies `-C symbol-mangling-version=v0`. Optional values are:
13011302
`=all` (implicit value)
1303+
`=branch`
13021304
`=except-unused-generics`
13031305
`=except-unused-functions`
13041306
`=off` (default)"),
@@ -1547,6 +1549,7 @@ options! {
15471549
reports (note, the compiler build config must include `profiler = true`); \
15481550
implies `-C symbol-mangling-version=v0`. Optional values are:
15491551
`=all` (implicit value)
1552+
`=branch`
15501553
`=except-unused-generics`
15511554
`=except-unused-functions`
15521555
`=off` (default)"),

compiler/rustc_session/src/session.rs

+4
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,10 @@ impl Session {
695695
self.opts.cg.instrument_coverage() != InstrumentCoverage::Off
696696
}
697697

698+
pub fn instrument_coverage_branch(&self) -> bool {
699+
self.opts.cg.instrument_coverage() == InstrumentCoverage::Branch
700+
}
701+
698702
pub fn instrument_coverage_except_unused_generics(&self) -> bool {
699703
self.opts.cg.instrument_coverage() == InstrumentCoverage::ExceptUnusedGenerics
700704
}

0 commit comments

Comments
 (0)