-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
llvm.expect intrinsic from likely/unlikely is not emitted in release mode #96276
Copy link
Copy link
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Fields
Give feedbackNo fields configured for issues without a type.