Skip to content

Commit

Permalink
Rollup merge of rust-lang#100827 - JakobDegen:better-tests, r=wesleyw…
Browse files Browse the repository at this point in the history
…iser

Simplify MIR opt tests

This commit removes many cases of MIR opt tests emitting `.diff`s for more than one pass. These tests cannot be `unit-test`s, and so they are easy to break, and they also provide little value due to having excessively strong opinions over *how* a piece of code should be optimized.

Where reasonable, we instead add separate test files that only emit the `PreCodegen.after` MIR for code where we want to track what the end to end effect of the optimization pipeline on the example code is.

r? ``@wesleywiser``
  • Loading branch information
Dylan-DPC authored Sep 2, 2022
2 parents 8434dc4 + e5d60af commit ea7db0c
Show file tree
Hide file tree
Showing 58 changed files with 742 additions and 1,509 deletions.
5 changes: 3 additions & 2 deletions src/test/mir-opt/early_otherwise_branch_68867.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// compile-flags: -Z mir-opt-level=4 -Zunsound-mir-opts
// unit-test: EarlyOtherwiseBranch

// FIXME: This test was broken by the derefer change.

// example from #68867
type CSSFloat = f32;
Expand All @@ -11,7 +13,6 @@ pub enum ViewportPercentageLength {
}

// EMIT_MIR early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff
// EMIT_MIR early_otherwise_branch_68867.try_sum EarlyOtherwiseBranch.before SimplifyConstCondition-final.after
#[no_mangle]
pub extern "C" fn try_sum(
x: &ViewportPercentageLength,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
StorageDead(_5); // scope 0 at $DIR/early_otherwise_branch_68867.rs:+5:23: +5:24
_34 = deref_copy (_4.0: &ViewportPercentageLength); // scope 0 at $DIR/early_otherwise_branch_68867.rs:+5:14: +5:24
_11 = discriminant((*_34)); // scope 0 at $DIR/early_otherwise_branch_68867.rs:+5:14: +5:24
switchInt(move _11) -> [0_isize: bb1, 1_isize: bb3, 2_isize: bb4, 3_isize: bb5, otherwise: bb11]; // scope 0 at $DIR/early_otherwise_branch_68867.rs:+5:8: +5:24
switchInt(move _11) -> [0_isize: bb1, 1_isize: bb3, 2_isize: bb4, 3_isize: bb5, otherwise: bb2]; // scope 0 at $DIR/early_otherwise_branch_68867.rs:+5:8: +5:24
}

bb1: {
Expand All @@ -91,14 +91,14 @@

bb2: {
StorageLive(_33); // scope 0 at $DIR/early_otherwise_branch_68867.rs:+10:25: +10:27
nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:+10:25: +10:27
Deinit(_33); // scope 0 at $DIR/early_otherwise_branch_68867.rs:+10:25: +10:27
Deinit(_0); // scope 0 at $DIR/early_otherwise_branch_68867.rs:+10:21: +10:28
nop; // scope 0 at $DIR/early_otherwise_branch_68867.rs:+10:21: +10:28
((_0 as Err).0: ()) = move _33; // scope 0 at $DIR/early_otherwise_branch_68867.rs:+10:21: +10:28
discriminant(_0) = 1; // scope 0 at $DIR/early_otherwise_branch_68867.rs:+10:21: +10:28
StorageDead(_33); // scope 0 at $DIR/early_otherwise_branch_68867.rs:+10:27: +10:28
StorageDead(_3); // scope 0 at $DIR/early_otherwise_branch_68867.rs:+11:6: +11:7
StorageDead(_4); // scope 0 at $DIR/early_otherwise_branch_68867.rs:+12:1: +12:2
return; // scope 0 at $DIR/early_otherwise_branch_68867.rs:+12:2: +12:2
goto -> bb11; // scope 0 at $DIR/early_otherwise_branch_68867.rs:+12:2: +12:2
}

bb3: {
Expand Down Expand Up @@ -221,11 +221,11 @@
discriminant(_0) = 0; // scope 0 at $DIR/early_otherwise_branch_68867.rs:+5:5: +11:7
StorageDead(_3); // scope 0 at $DIR/early_otherwise_branch_68867.rs:+11:6: +11:7
StorageDead(_4); // scope 0 at $DIR/early_otherwise_branch_68867.rs:+12:1: +12:2
return; // scope 0 at $DIR/early_otherwise_branch_68867.rs:+12:2: +12:2
goto -> bb11; // scope 0 at $DIR/early_otherwise_branch_68867.rs:+12:2: +12:2
}

bb11: {
unreachable; // scope 0 at $DIR/early_otherwise_branch_68867.rs:+12:2: +12:2
return; // scope 0 at $DIR/early_otherwise_branch_68867.rs:+12:2: +12:2
}
}

1 change: 0 additions & 1 deletion src/test/mir-opt/issue-73223.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ fn main() {

// EMIT_MIR_FOR_EACH_BIT_WIDTH
// EMIT_MIR issue_73223.main.SimplifyArmIdentity.diff
// EMIT_MIR issue_73223.main.PreCodegen.diff
117 changes: 0 additions & 117 deletions src/test/mir-opt/issue_73223.main.PreCodegen.32bit.diff

This file was deleted.

Loading

0 comments on commit ea7db0c

Please sign in to comment.