diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index e74d66a859926..4c6f46ef0dcee 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -2481,9 +2481,9 @@ impl<'test> TestCx<'test> { RunCoverage => { rustc.arg("-Cinstrument-coverage"); // 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`. - rustc.arg("-Copt-level=0"); + rustc.arg("-Copt-level=2"); } RunPassValgrind | Pretty | DebugInfo | Codegen | Rustdoc | RustdocJson | RunMake | CodegenUnits | JsDocTest | Assembly => { diff --git a/tests/coverage-map/status-quo/overflow.cov-map b/tests/coverage-map/status-quo/overflow.cov-map index bfffd9b2ab515..39a5c05f879ad 100644 --- a/tests/coverage-map/status-quo/overflow.cov-map +++ b/tests/coverage-map/status-quo/overflow.cov-map @@ -1,5 +1,5 @@ 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 - file 0 => global file 1 Number of expressions: 8 @@ -12,7 +12,7 @@ Number of expressions: 8 - expression 6 operands: lhs = Counter(1), rhs = Expression(7, Add) - expression 7 operands: lhs = Counter(2), rhs = Counter(3) 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) = (c0 + (c1 + (c2 + c3))) - 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) 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 - 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 + 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(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7) = (c0 - c1) diff --git a/tests/coverage-map/status-quo/overflow.rs b/tests/coverage-map/status-quo/overflow.rs index bbb65c1b35df6..1c40771b27478 100644 --- a/tests/coverage-map/status-quo/overflow.rs +++ b/tests/coverage-map/status-quo/overflow.rs @@ -1,4 +1,5 @@ #![allow(unused_assignments)] +// compile-flags: -Coverflow-checks=yes // failure-status: 101 fn might_overflow(to_add: u32) -> u32 { diff --git a/tests/coverage-map/status-quo/sort_groups.cov-map b/tests/coverage-map/status-quo/sort_groups.cov-map index db027f3dc3249..3cbda6fbe1ab8 100644 --- a/tests/coverage-map/status-quo/sort_groups.cov-map +++ b/tests/coverage-map/status-quo/sort_groups.cov-map @@ -28,6 +28,21 @@ Number of file 0 mappings: 4 - Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2) = (c1 + (c0 - c1)) +Function name: sort_groups::generic_fn:: +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:: 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 @@ -44,19 +59,19 @@ Number of file 0 mappings: 4 = (c1 + (c0 - c1)) 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 - file 0 => global file 1 Number of expressions: 2 -- expression 0 operands: lhs = Counter(0), rhs = Zero -- expression 1 operands: lhs = Zero, rhs = Expression(0, Sub) +- 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 + 6, 1) to (start + 4, 13) -- Code(Zero) at (prev + 4, 14) to (start + 2, 6) +- Code(Counter(0)) at (prev + 6, 1) to (start + 4, 35) +- Code(Counter(1)) at (prev + 4, 36) to (start + 2, 6) - 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) - = (Zero + (c0 - Zero)) + = (c1 + (c0 - c1)) Function name: sort_groups::other_fn Raw bytes (9): 0x[01, 01, 00, 01, 01, 17, 01, 00, 11] diff --git a/tests/coverage-map/status-quo/sort_groups.rs b/tests/coverage-map/status-quo/sort_groups.rs index f89f9f3ec61fa..5adbbc6a87d1f 100644 --- a/tests/coverage-map/status-quo/sort_groups.rs +++ b/tests/coverage-map/status-quo/sort_groups.rs @@ -7,7 +7,7 @@ fn main() { let cond = std::env::args().len() > 1; generic_fn::<()>(cond); generic_fn::<&'static str>(!cond); - if false { + if std::hint::black_box(false) { generic_fn::(cond); } generic_fn::(cond); diff --git a/tests/run-coverage/overflow.coverage b/tests/run-coverage/overflow.coverage index cee076e88cd43..4f8dffc0c4814 100644 --- a/tests/run-coverage/overflow.coverage +++ b/tests/run-coverage/overflow.coverage @@ -1,4 +1,5 @@ LL| |#![allow(unused_assignments)] + LL| |// compile-flags: -Coverflow-checks=yes LL| |// failure-status: 101 LL| | LL| 4|fn might_overflow(to_add: u32) -> u32 { diff --git a/tests/run-coverage/overflow.rs b/tests/run-coverage/overflow.rs index bbb65c1b35df6..1c40771b27478 100644 --- a/tests/run-coverage/overflow.rs +++ b/tests/run-coverage/overflow.rs @@ -1,4 +1,5 @@ #![allow(unused_assignments)] +// compile-flags: -Coverflow-checks=yes // failure-status: 101 fn might_overflow(to_add: u32) -> u32 { diff --git a/tests/run-coverage/sort_groups.coverage b/tests/run-coverage/sort_groups.coverage index 8733bf48a9c8d..c70d7b3b28253 100644 --- a/tests/run-coverage/sort_groups.coverage +++ b/tests/run-coverage/sort_groups.coverage @@ -7,7 +7,7 @@ LL| 1| let cond = std::env::args().len() > 1; LL| 1| generic_fn::<()>(cond); LL| 1| generic_fn::<&'static str>(!cond); - LL| 1| if false { + LL| 1| if std::hint::black_box(false) { LL| 0| generic_fn::(cond); LL| 1| } LL| 1| generic_fn::(cond); diff --git a/tests/run-coverage/sort_groups.rs b/tests/run-coverage/sort_groups.rs index f89f9f3ec61fa..5adbbc6a87d1f 100644 --- a/tests/run-coverage/sort_groups.rs +++ b/tests/run-coverage/sort_groups.rs @@ -7,7 +7,7 @@ fn main() { let cond = std::env::args().len() > 1; generic_fn::<()>(cond); generic_fn::<&'static str>(!cond); - if false { + if std::hint::black_box(false) { generic_fn::(cond); } generic_fn::(cond);