-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lower assume(false) to an unreachable terminator
- Loading branch information
Showing
3 changed files
with
62 additions
and
3 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,27 @@ | ||
// The lowering of the function below initially reads and writes to the entire pointee, even though | ||
// it only needs to do a store to the discriminant. | ||
// This test ensures that std::hint::unreachable_unchecked does not prevent the desired optimization. | ||
|
||
//@ compile-flags: -O | ||
|
||
#![crate_type = "lib"] | ||
|
||
use std::hint::unreachable_unchecked; | ||
use std::ptr::{read, write}; | ||
|
||
type T = [u8; 753]; | ||
|
||
pub enum State { | ||
A(T), | ||
B(T), | ||
} | ||
|
||
// CHECK-LABEL: @init(ptr {{.*}}s) | ||
// CHECK-NEXT: start | ||
// CHECK-NEXT: store i8 1, ptr %s, align 1 | ||
// CHECK-NEXT: ret void | ||
#[no_mangle] | ||
unsafe fn init(s: *mut State) { | ||
let State::A(v) = read(s) else { unreachable_unchecked() }; | ||
write(s, State::B(v)); | ||
} |