coverage: Use -Copt-level=2 by default in run-coverage tests

This is a step towards being able to unify the two coverage test directories.

There are two tests that require adjustment:

- `overflow.rs` requires an explicit `-Coverflow-checks=yes`
- `sort_groups.rs` is sensitive to provably unused instantiations
This commit is contained in:
Zalathar 2023-10-26 21:34:49 +11:00
parent 189d6c71f3
commit 7f8a6de72c
9 changed files with 34 additions and 16 deletions

View File

@ -2481,9 +2481,9 @@ fn make_compile_args(
RunCoverage => { RunCoverage => {
rustc.arg("-Cinstrument-coverage"); rustc.arg("-Cinstrument-coverage");
// Coverage reports are sometimes sensitive to optimizations, // Coverage reports are sometimes sensitive to optimizations,
// and the current snapshots assume no optimization unless // and the current snapshots assume `opt-level=2` unless
// overridden by `compile-flags`. // overridden by `compile-flags`.
rustc.arg("-Copt-level=0"); rustc.arg("-Copt-level=2");
} }
RunPassValgrind | Pretty | DebugInfo | Codegen | Rustdoc | RustdocJson | RunMake RunPassValgrind | Pretty | DebugInfo | Codegen | Rustdoc | RustdocJson | RunMake
| CodegenUnits | JsDocTest | Assembly => { | CodegenUnits | JsDocTest | Assembly => {

View File

@ -1,5 +1,5 @@
Function name: overflow::main Function name: overflow::main
Raw bytes (65): 0x[01, 01, 08, 01, 1b, 05, 1f, 09, 0d, 03, 11, 16, 05, 03, 11, 05, 1f, 09, 0d, 09, 01, 0f, 01, 01, 1b, 03, 02, 0b, 00, 18, 16, 01, 0c, 00, 1a, 05, 00, 1b, 03, 0a, 12, 03, 13, 00, 20, 09, 00, 21, 03, 0a, 0d, 03, 0a, 00, 0b, 1b, 01, 09, 00, 17, 11, 02, 05, 01, 02] Raw bytes (65): 0x[01, 01, 08, 01, 1b, 05, 1f, 09, 0d, 03, 11, 16, 05, 03, 11, 05, 1f, 09, 0d, 09, 01, 10, 01, 01, 1b, 03, 02, 0b, 00, 18, 16, 01, 0c, 00, 1a, 05, 00, 1b, 03, 0a, 12, 03, 13, 00, 20, 09, 00, 21, 03, 0a, 0d, 03, 0a, 00, 0b, 1b, 01, 09, 00, 17, 11, 02, 05, 01, 02]
Number of files: 1 Number of files: 1
- file 0 => global file 1 - file 0 => global file 1
Number of expressions: 8 Number of expressions: 8
@ -12,7 +12,7 @@ Number of expressions: 8
- expression 6 operands: lhs = Counter(1), rhs = Expression(7, Add) - expression 6 operands: lhs = Counter(1), rhs = Expression(7, Add)
- expression 7 operands: lhs = Counter(2), rhs = Counter(3) - expression 7 operands: lhs = Counter(2), rhs = Counter(3)
Number of file 0 mappings: 9 Number of file 0 mappings: 9
- Code(Counter(0)) at (prev + 15, 1) to (start + 1, 27) - Code(Counter(0)) at (prev + 16, 1) to (start + 1, 27)
- Code(Expression(0, Add)) at (prev + 2, 11) to (start + 0, 24) - Code(Expression(0, Add)) at (prev + 2, 11) to (start + 0, 24)
= (c0 + (c1 + (c2 + c3))) = (c0 + (c1 + (c2 + c3)))
- Code(Expression(5, Sub)) at (prev + 1, 12) to (start + 0, 26) - Code(Expression(5, Sub)) at (prev + 1, 12) to (start + 0, 26)
@ -27,14 +27,14 @@ Number of file 0 mappings: 9
- Code(Counter(4)) at (prev + 2, 5) to (start + 1, 2) - Code(Counter(4)) at (prev + 2, 5) to (start + 1, 2)
Function name: overflow::might_overflow Function name: overflow::might_overflow
Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 04, 01, 01, 12, 05, 01, 13, 02, 06, 02, 02, 06, 00, 07, 07, 01, 09, 05, 02] Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 05, 01, 01, 12, 05, 01, 13, 02, 06, 02, 02, 06, 00, 07, 07, 01, 09, 05, 02]
Number of files: 1 Number of files: 1
- file 0 => global file 1 - file 0 => global file 1
Number of expressions: 2 Number of expressions: 2
- expression 0 operands: lhs = Counter(0), rhs = Counter(1) - expression 0 operands: lhs = Counter(0), rhs = Counter(1)
- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) - expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
Number of file 0 mappings: 4 Number of file 0 mappings: 4
- Code(Counter(0)) at (prev + 4, 1) to (start + 1, 18) - Code(Counter(0)) at (prev + 5, 1) to (start + 1, 18)
- Code(Counter(1)) at (prev + 1, 19) to (start + 2, 6) - Code(Counter(1)) at (prev + 1, 19) to (start + 2, 6)
- Code(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7) - Code(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7)
= (c0 - c1) = (c0 - c1)

View File

@ -1,4 +1,5 @@
#![allow(unused_assignments)] #![allow(unused_assignments)]
// compile-flags: -Coverflow-checks=yes
// failure-status: 101 // failure-status: 101
fn might_overflow(to_add: u32) -> u32 { fn might_overflow(to_add: u32) -> u32 {

View File

@ -28,6 +28,21 @@ Number of file 0 mappings: 4
- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2) - Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2)
= (c1 + (c0 - c1)) = (c1 + (c0 - c1))
Function name: sort_groups::generic_fn::<char>
Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 11, 01, 01, 0c, 05, 01, 0d, 02, 06, 02, 02, 06, 00, 07, 07, 01, 01, 00, 02]
Number of files: 1
- file 0 => global file 1
Number of expressions: 2
- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
Number of file 0 mappings: 4
- Code(Counter(0)) at (prev + 17, 1) to (start + 1, 12)
- Code(Counter(1)) at (prev + 1, 13) to (start + 2, 6)
- Code(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7)
= (c0 - c1)
- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2)
= (c1 + (c0 - c1))
Function name: sort_groups::generic_fn::<i32> Function name: sort_groups::generic_fn::<i32>
Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 11, 01, 01, 0c, 05, 01, 0d, 02, 06, 02, 02, 06, 00, 07, 07, 01, 01, 00, 02] Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 11, 01, 01, 0c, 05, 01, 0d, 02, 06, 02, 02, 06, 00, 07, 07, 01, 01, 00, 02]
Number of files: 1 Number of files: 1
@ -44,19 +59,19 @@ Number of file 0 mappings: 4
= (c1 + (c0 - c1)) = (c1 + (c0 - c1))
Function name: sort_groups::main Function name: sort_groups::main
Raw bytes (28): 0x[01, 01, 02, 01, 00, 00, 02, 04, 01, 06, 01, 04, 0d, 00, 04, 0e, 02, 06, 02, 02, 06, 00, 07, 07, 01, 05, 02, 02] Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 06, 01, 04, 23, 05, 04, 24, 02, 06, 02, 02, 06, 00, 07, 07, 01, 05, 02, 02]
Number of files: 1 Number of files: 1
- file 0 => global file 1 - file 0 => global file 1
Number of expressions: 2 Number of expressions: 2
- expression 0 operands: lhs = Counter(0), rhs = Zero - expression 0 operands: lhs = Counter(0), rhs = Counter(1)
- expression 1 operands: lhs = Zero, rhs = Expression(0, Sub) - expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
Number of file 0 mappings: 4 Number of file 0 mappings: 4
- Code(Counter(0)) at (prev + 6, 1) to (start + 4, 13) - Code(Counter(0)) at (prev + 6, 1) to (start + 4, 35)
- Code(Zero) at (prev + 4, 14) to (start + 2, 6) - Code(Counter(1)) at (prev + 4, 36) to (start + 2, 6)
- Code(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7) - Code(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7)
= (c0 - Zero) = (c0 - c1)
- Code(Expression(1, Add)) at (prev + 1, 5) to (start + 2, 2) - Code(Expression(1, Add)) at (prev + 1, 5) to (start + 2, 2)
= (Zero + (c0 - Zero)) = (c1 + (c0 - c1))
Function name: sort_groups::other_fn Function name: sort_groups::other_fn
Raw bytes (9): 0x[01, 01, 00, 01, 01, 17, 01, 00, 11] Raw bytes (9): 0x[01, 01, 00, 01, 01, 17, 01, 00, 11]

View File

@ -7,7 +7,7 @@ fn main() {
let cond = std::env::args().len() > 1; let cond = std::env::args().len() > 1;
generic_fn::<()>(cond); generic_fn::<()>(cond);
generic_fn::<&'static str>(!cond); generic_fn::<&'static str>(!cond);
if false { if std::hint::black_box(false) {
generic_fn::<char>(cond); generic_fn::<char>(cond);
} }
generic_fn::<i32>(cond); generic_fn::<i32>(cond);

View File

@ -1,4 +1,5 @@
LL| |#![allow(unused_assignments)] LL| |#![allow(unused_assignments)]
LL| |// compile-flags: -Coverflow-checks=yes
LL| |// failure-status: 101 LL| |// failure-status: 101
LL| | LL| |
LL| 4|fn might_overflow(to_add: u32) -> u32 { LL| 4|fn might_overflow(to_add: u32) -> u32 {

View File

@ -1,4 +1,5 @@
#![allow(unused_assignments)] #![allow(unused_assignments)]
// compile-flags: -Coverflow-checks=yes
// failure-status: 101 // failure-status: 101
fn might_overflow(to_add: u32) -> u32 { fn might_overflow(to_add: u32) -> u32 {

View File

@ -7,7 +7,7 @@
LL| 1| let cond = std::env::args().len() > 1; LL| 1| let cond = std::env::args().len() > 1;
LL| 1| generic_fn::<()>(cond); LL| 1| generic_fn::<()>(cond);
LL| 1| generic_fn::<&'static str>(!cond); LL| 1| generic_fn::<&'static str>(!cond);
LL| 1| if false { LL| 1| if std::hint::black_box(false) {
LL| 0| generic_fn::<char>(cond); LL| 0| generic_fn::<char>(cond);
LL| 1| } LL| 1| }
LL| 1| generic_fn::<i32>(cond); LL| 1| generic_fn::<i32>(cond);

View File

@ -7,7 +7,7 @@ fn main() {
let cond = std::env::args().len() > 1; let cond = std::env::args().len() > 1;
generic_fn::<()>(cond); generic_fn::<()>(cond);
generic_fn::<&'static str>(!cond); generic_fn::<&'static str>(!cond);
if false { if std::hint::black_box(false) {
generic_fn::<char>(cond); generic_fn::<char>(cond);
} }
generic_fn::<i32>(cond); generic_fn::<i32>(cond);