Closed
Description
When the std::intrinsics::unlikely/likely
function is used, the codegen doesn't emit llvm.expect
annotation in release mode. Curiously enough, in debug mode it does emit it.
A minimal example:
#![feature(core_intrinsics)]
use std::intrinsics::unlikely;
pub fn foo(x: bool) {
if unlikely(x) {
println!("foo: {x}");
}
println!("bar");
}
Playground link here. In debug mode, LLVM IR contains llvm.expect
. In release mode, it doesn't.
This has been previously noted here (maybe it indeed started with LLVM 13?) and more recently here.
I can take a look into this, if you can point me into the right direction. There is a codegen test for likely/unlikely
, but it uses -C no-prepopulate-passes
, which does not correspond to what release (-O
) does.
Metadata
Metadata
Assignees
Labels
No labels