Skip to content

Full Compile-Time Processor Feature Detection #160

@Sewer56

Description

@Sewer56

Currently memchr does run-time feature detection for x86, storing 'preferred' functions inside a field that is later referenced in subsequent calls

// Inside `unsafe_ifunc!`

// store
FN.store(fun as Fn, Ordering::Relaxed);

// use
let fun = FN.load(Ordering::Relaxed);

This manifests itself as a mov and call in x86; and one or two other misc instructions along the way.

In order to avoid unnecessary code bloat and improve performance, it should be possible to bypass this mechanism if we know what is available at build time.
This would allow for inlining, and slightly lesser call overhead.

That is of course, when the Rust compiler is invoked with the correct flags to ship a binary targeting a specific processor.

Note

This isn't a formal feature request, it's more so a reminder for myself.
I want to reference this issue in my own codebase, and possibly PR this sometime in the future.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions