2024-06-11 18:18:27 +00:00
|
|
|
// intrinsics::unreachable tells the compiler that a certain point in the code
|
|
|
|
// is not reachable by any means, which enables some useful optimizations.
|
|
|
|
// In this test, exit-unreachable contains this instruction and exit-ret does not,
|
|
|
|
// which means the emitted artifacts should be shorter in length.
|
|
|
|
// See https://github.com/rust-lang/rust/pull/16970
|
|
|
|
|
|
|
|
//@ needs-asm-support
|
2024-06-12 15:24:21 +00:00
|
|
|
//@ ignore-windows
|
2024-06-11 18:18:27 +00:00
|
|
|
// Reason: Because of Windows exception handling, the code is not necessarily any shorter.
|
|
|
|
|
2024-07-17 13:31:38 +00:00
|
|
|
use run_make_support::{rfs, rustc};
|
2024-06-11 18:18:27 +00:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
rustc().opt().emit("asm").input("exit-ret.rs").run();
|
|
|
|
rustc().opt().emit("asm").input("exit-unreachable.rs").run();
|
2024-06-12 15:24:21 +00:00
|
|
|
assert!(
|
2024-07-17 12:42:06 +00:00
|
|
|
rfs::read_to_string("exit-unreachable.s").lines().count()
|
|
|
|
< rfs::read_to_string("exit-ret.s").lines().count()
|
2024-06-12 15:24:21 +00:00
|
|
|
);
|
2024-06-11 18:18:27 +00:00
|
|
|
}
|