-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #127234 - ZhuUx:inlined-expr, r=davidtwco,Zalathar
[Coverage][MCDC] Group mcdc tests and fix panic when generating mcdc code for inlined expressions. ### Changes 1. Group all mcdc tests to one directory. 2. Since mcdc instruments different mappings for boolean expressions with normal branch coverage as #125766 introduces, it would be better also trace branch coverage results in mcdc tests. 3. So far rustc does not call `CoverageInfoBuilderMethods::init_coverage` for inlined functions. As a result, it could panic if it tries to instrument mcdc statements for inlined functions due to uninitialized cond bitmaps. We can reproduce this issue by current nightly rustc and [the test](https://github.com/rust-lang/rust/pull/127234/files#diff-c81af6bf4869aa42f5c7334e3e86344475de362f673f54ce439ec75fcb5ac3e5) with flag `--release`. This patch fixes it.
- Loading branch information
Showing
13 changed files
with
181 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Function name: inlined_expressions::inlined_instance | ||
Raw bytes (52): 0x[01, 01, 03, 01, 05, 0b, 02, 09, 0d, 06, 01, 08, 01, 01, 06, 28, 00, 02, 01, 05, 00, 0b, 30, 05, 02, 01, 02, 00, 00, 05, 00, 06, 05, 00, 0a, 00, 0b, 30, 09, 0d, 02, 00, 00, 00, 0a, 00, 0b, 07, 01, 01, 00, 02] | ||
Number of files: 1 | ||
- file 0 => global file 1 | ||
Number of expressions: 3 | ||
- expression 0 operands: lhs = Counter(0), rhs = Counter(1) | ||
- expression 1 operands: lhs = Expression(2, Add), rhs = Expression(0, Sub) | ||
- expression 2 operands: lhs = Counter(2), rhs = Counter(3) | ||
Number of file 0 mappings: 6 | ||
- Code(Counter(0)) at (prev + 8, 1) to (start + 1, 6) | ||
- MCDCDecision { bitmap_idx: 0, conditions_num: 2 } at (prev + 1, 5) to (start + 0, 11) | ||
- MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 5) to (start + 0, 6) | ||
true = c1 | ||
false = (c0 - c1) | ||
- Code(Counter(1)) at (prev + 0, 10) to (start + 0, 11) | ||
- MCDCBranch { true: Counter(2), false: Counter(3), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 10) to (start + 0, 11) | ||
true = c2 | ||
false = c3 | ||
- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2) | ||
= ((c2 + c3) + (c0 - c1)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
LL| |#![feature(coverage_attribute)] | ||
LL| |//@ edition: 2021 | ||
LL| |//@ min-llvm-version: 18 | ||
LL| |//@ compile-flags: -Zcoverage-options=mcdc -Copt-level=z -Cllvm-args=--inline-threshold=0 | ||
LL| |//@ llvm-cov-flags: --show-branches=count --show-mcdc | ||
LL| | | ||
LL| |#[inline(always)] | ||
LL| 3|fn inlined_instance(a: bool, b: bool) -> bool { | ||
LL| 3| a && b | ||
^2 | ||
------------------ | ||
| Branch (LL:5): [True: 2, False: 1] | ||
| Branch (LL:10): [True: 1, False: 1] | ||
------------------ | ||
|---> MC/DC Decision Region (LL:5) to (LL:11) | ||
| | ||
| Number of Conditions: 2 | ||
| Condition C1 --> (LL:5) | ||
| Condition C2 --> (LL:10) | ||
| | ||
| Executed MC/DC Test Vectors: | ||
| | ||
| C1, C2 Result | ||
| 1 { F, - = F } | ||
| 2 { T, F = F } | ||
| 3 { T, T = T } | ||
| | ||
| C1-Pair: covered: (1,3) | ||
| C2-Pair: covered: (2,3) | ||
| MC/DC Coverage for Decision: 100.00% | ||
| | ||
------------------ | ||
LL| 3|} | ||
LL| | | ||
LL| |#[coverage(off)] | ||
LL| |fn main() { | ||
LL| | let _ = inlined_instance(true, false); | ||
LL| | let _ = inlined_instance(false, true); | ||
LL| | let _ = inlined_instance(true, true); | ||
LL| |} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#![feature(coverage_attribute)] | ||
//@ edition: 2021 | ||
//@ min-llvm-version: 18 | ||
//@ compile-flags: -Zcoverage-options=mcdc -Copt-level=z -Cllvm-args=--inline-threshold=0 | ||
//@ llvm-cov-flags: --show-branches=count --show-mcdc | ||
|
||
#[inline(always)] | ||
fn inlined_instance(a: bool, b: bool) -> bool { | ||
a && b | ||
} | ||
|
||
#[coverage(off)] | ||
fn main() { | ||
let _ = inlined_instance(true, false); | ||
let _ = inlined_instance(false, true); | ||
let _ = inlined_instance(true, true); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.