-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
coverage. Fix panic when generating mcdc code for inlined functions
- Loading branch information
zhuyunxing
committed
Jul 2, 2024
1 parent
722aea5
commit 49e8e2d
Showing
5 changed files
with
91 additions
and
1 deletion.
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
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 -Cinline-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 -Cinline-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); | ||
} |