mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-31 05:26:23 +03:00
7e5c7cf8e3
When the niche maximum is zero, emit a "== zero" check instead of a "<= zero" check. In particular, this avoid the awkward case of "<= null". While LLVM does canonicalize this to "!= null", this appently doesn't happen for constant expressions, leading to the issue in #74425. While that can be addressed on the LLVM side, it still seems prudent to emit sensible IR here, because this will allow null checks to be optimized earlier in the pipeline. Fixes #74425.
26 lines
361 B
Rust
26 lines
361 B
Rust
// compile-flags: -O
|
|
|
|
#![crate_type = "lib"]
|
|
|
|
// CHECK-LABEL: @test
|
|
// CHECK-NEXT: start:
|
|
// CHECK-NEXT: tail call void @ext_fn0()
|
|
#[no_mangle]
|
|
pub fn test() {
|
|
test_inner(Some(inner0));
|
|
}
|
|
|
|
fn test_inner(f_maybe: Option<fn()>) {
|
|
if let Some(f) = f_maybe {
|
|
f();
|
|
}
|
|
}
|
|
|
|
fn inner0() {
|
|
unsafe { ext_fn0() };
|
|
}
|
|
|
|
extern "C" {
|
|
fn ext_fn0();
|
|
}
|