forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace the default branch with an unreachable branch If it is the la…
…st variant
- Loading branch information
Showing
14 changed files
with
419 additions
and
11 deletions.
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,24 @@ | ||
// compile-flags: -O | ||
|
||
#![crate_type = "lib"] | ||
|
||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] | ||
pub struct Int(u32); | ||
|
||
const A: Int = Int(201); | ||
const B: Int = Int(270); | ||
const C: Int = Int(153); | ||
|
||
// CHECK-LABEL: @foo | ||
// CHECK-SAME: [[TMP0:%.*]]) | ||
// CHECK-NEXT: start: | ||
// CHECK-NEXT: [[TMP1:%.*]] = add i32 [[TMP0]], -201 | ||
// CHECK-NEXT: [[OR_COND:%.*]] = icmp ult i32 [[TMP1]], 70 | ||
// CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP0]], 153 | ||
// CHECK-NEXT: [[SPEC_SELECT:%.*]] = or i1 [[OR_COND]], [[TMP2]] | ||
// CHECK-NEXT: ret i1 [[SPEC_SELECT]] | ||
#[no_mangle] | ||
pub fn foo(x: Int) -> bool { | ||
(x >= A && x <= B) | ||
|| x == C | ||
} |
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
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
53 changes: 53 additions & 0 deletions
53
tests/mir-opt/uninhabited_enum_branching.otherwise_t1.UninhabitedEnumBranching.diff
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,53 @@ | ||
- // MIR for `otherwise_t1` before UninhabitedEnumBranching | ||
+ // MIR for `otherwise_t1` after UninhabitedEnumBranching | ||
|
||
fn otherwise_t1() -> () { | ||
let mut _0: (); | ||
let _1: &str; | ||
let mut _2: Test1; | ||
let mut _3: isize; | ||
let _4: &str; | ||
let _5: &str; | ||
|
||
bb0: { | ||
StorageLive(_1); | ||
StorageLive(_2); | ||
_2 = Test1::C; | ||
_3 = discriminant(_2); | ||
- switchInt(move _3) -> [0: bb2, 1: bb3, otherwise: bb1]; | ||
+ switchInt(move _3) -> [0: bb5, 1: bb5, 2: bb1, otherwise: bb5]; | ||
} | ||
|
||
bb1: { | ||
StorageLive(_5); | ||
_5 = const "C"; | ||
_1 = &(*_5); | ||
StorageDead(_5); | ||
goto -> bb4; | ||
} | ||
|
||
bb2: { | ||
_1 = const "A(Empty)"; | ||
goto -> bb4; | ||
} | ||
|
||
bb3: { | ||
StorageLive(_4); | ||
_4 = const "B(Empty)"; | ||
_1 = &(*_4); | ||
StorageDead(_4); | ||
goto -> bb4; | ||
} | ||
|
||
bb4: { | ||
StorageDead(_2); | ||
StorageDead(_1); | ||
_0 = const (); | ||
return; | ||
+ } | ||
+ | ||
+ bb5: { | ||
+ unreachable; | ||
} | ||
} | ||
|
44 changes: 44 additions & 0 deletions
44
tests/mir-opt/uninhabited_enum_branching.otherwise_t2.UninhabitedEnumBranching.diff
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,44 @@ | ||
- // MIR for `otherwise_t2` before UninhabitedEnumBranching | ||
+ // MIR for `otherwise_t2` after UninhabitedEnumBranching | ||
|
||
fn otherwise_t2() -> () { | ||
let mut _0: (); | ||
let _1: &str; | ||
let mut _2: Test2; | ||
let mut _3: isize; | ||
let _4: &str; | ||
|
||
bb0: { | ||
StorageLive(_1); | ||
StorageLive(_2); | ||
_2 = Test2::D; | ||
_3 = discriminant(_2); | ||
- switchInt(move _3) -> [4: bb2, otherwise: bb1]; | ||
+ switchInt(move _3) -> [4: bb2, 5: bb1, otherwise: bb4]; | ||
} | ||
|
||
bb1: { | ||
StorageLive(_4); | ||
_4 = const "E"; | ||
_1 = &(*_4); | ||
StorageDead(_4); | ||
goto -> bb3; | ||
} | ||
|
||
bb2: { | ||
_1 = const "D"; | ||
goto -> bb3; | ||
} | ||
|
||
bb3: { | ||
StorageDead(_2); | ||
StorageDead(_1); | ||
_0 = const (); | ||
return; | ||
+ } | ||
+ | ||
+ bb4: { | ||
+ unreachable; | ||
} | ||
} | ||
|
53 changes: 53 additions & 0 deletions
53
tests/mir-opt/uninhabited_enum_branching.otherwise_t3.UninhabitedEnumBranching.diff
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,53 @@ | ||
- // MIR for `otherwise_t3` before UninhabitedEnumBranching | ||
+ // MIR for `otherwise_t3` after UninhabitedEnumBranching | ||
|
||
fn otherwise_t3() -> () { | ||
let mut _0: (); | ||
let _1: &str; | ||
let mut _2: Test3; | ||
let mut _3: isize; | ||
let _4: &str; | ||
let _5: &str; | ||
|
||
bb0: { | ||
StorageLive(_1); | ||
StorageLive(_2); | ||
_2 = Test3::C; | ||
_3 = discriminant(_2); | ||
- switchInt(move _3) -> [0: bb2, 1: bb3, otherwise: bb1]; | ||
+ switchInt(move _3) -> [0: bb5, 1: bb5, otherwise: bb1]; | ||
} | ||
|
||
bb1: { | ||
StorageLive(_5); | ||
_5 = const "C"; | ||
_1 = &(*_5); | ||
StorageDead(_5); | ||
goto -> bb4; | ||
} | ||
|
||
bb2: { | ||
_1 = const "A(Empty)"; | ||
goto -> bb4; | ||
} | ||
|
||
bb3: { | ||
StorageLive(_4); | ||
_4 = const "B(Empty)"; | ||
_1 = &(*_4); | ||
StorageDead(_4); | ||
goto -> bb4; | ||
} | ||
|
||
bb4: { | ||
StorageDead(_2); | ||
StorageDead(_1); | ||
_0 = const (); | ||
return; | ||
+ } | ||
+ | ||
+ bb5: { | ||
+ unreachable; | ||
} | ||
} | ||
|
48 changes: 48 additions & 0 deletions
48
tests/mir-opt/uninhabited_enum_branching.otherwise_t4.UninhabitedEnumBranching.diff
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,48 @@ | ||
- // MIR for `otherwise_t4` before UninhabitedEnumBranching | ||
+ // MIR for `otherwise_t4` after UninhabitedEnumBranching | ||
|
||
fn otherwise_t4() -> () { | ||
let mut _0: (); | ||
let _1: &str; | ||
let mut _2: Test4; | ||
let mut _3: isize; | ||
let _4: &str; | ||
let _5: &str; | ||
|
||
bb0: { | ||
StorageLive(_1); | ||
StorageLive(_2); | ||
_2 = Test4::C; | ||
_3 = discriminant(_2); | ||
switchInt(move _3) -> [0: bb2, 1: bb3, otherwise: bb1]; | ||
} | ||
|
||
bb1: { | ||
StorageLive(_5); | ||
_5 = const "CD"; | ||
_1 = &(*_5); | ||
StorageDead(_5); | ||
goto -> bb4; | ||
} | ||
|
||
bb2: { | ||
_1 = const "A(i32)"; | ||
goto -> bb4; | ||
} | ||
|
||
bb3: { | ||
StorageLive(_4); | ||
_4 = const "B(i32)"; | ||
_1 = &(*_4); | ||
StorageDead(_4); | ||
goto -> bb4; | ||
} | ||
|
||
bb4: { | ||
StorageDead(_2); | ||
StorageDead(_1); | ||
_0 = const (); | ||
return; | ||
} | ||
} | ||
|
Oops, something went wrong.