Skip to content

Commit

Permalink
Simplify MIR opt tests
Browse files Browse the repository at this point in the history
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 result of the net result of the optimization pipeline's output
is.
  • Loading branch information
JakobDegen committed Aug 31, 2022
1 parent 9f4d5d2 commit 4a33bf3
Show file tree
Hide file tree
Showing 53 changed files with 733 additions and 1,502 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 4a33bf3

Please sign in to comment.