the.bay.news

Why the `unreachable!()` can't be optimized away?

The Rust Programming Language Forum
Why the `unreachable!()` can't be optimized away?
type Arg = Vec<u8>; #[unsafe(no_mangle)] fn test(this: &mut Option<Arg>, arg: Arg) { *this = Some(arg); let Some(arg) = this else { unreachable!() }; black_box(arg); } With rust v1.98.0, its assembly: test: pushq %r14 pushq %rbx pushq %rax movq %rsi, %r14 movq %rdi, %rbx movq (%rdi), %rsi testq %rsi, %rsi jle .LBB5_2 movq 8(%rbx), %rdi movl $1, %edx callq *__rustc::__rust_dealloc@GOTPCREL(%rip) .LBB5_2: movups (%r14), %xmm0 movups %xmm0, (%rbx) movq 16(%r1...

0 comments

Sign in to join the discussion — your thebay.events account works here.

No comments yet.