Skip to content

likely/unlikely hints dropped in release mode #96275

Closed
@SUPERCILEX

Description

@SUPERCILEX

I tried this code:

#![feature(core_intrinsics)]
#![feature(bench_black_box)]

use std::intrinsics::unlikely;

pub fn foo(a: bool) {
    if unlikely(a) {
        std::hint::black_box(42);
    }

    std::hint::black_box(0xDEAD);
    std::hint::black_box(0xBEEF);
}

I expected to see this happen: llvm.expect should be present in the IR
Instead, this happened: it's in debug mode, but gets dropped in release mode

Discovered here: #93668 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.I-slowIssue: Problems and improvements with respect to performance of generated code.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions