Module hint
Hints to compiler that affects how code should be emitted or optimized.
Hints may be compile time or runtime.
Enums
- Locality The expected temporal locality of a memory prefetch operation.
Functions
-
assert_unchecked
Makes a soundness promise to the compiler that
condholds. -
black_box
An identity function that hints to the compiler to be maximally pessimistic about what
black_boxcould do. - cold_path Hints to the compiler that given path is cold, i.e., unlikely to be taken. The compiler may choose to optimize paths that are not cold at the expense of paths that are cold.
- likely Hints to the compiler that a branch condition is likely to be true. Returns the value passed to it.
-
must_use
An identity function that causes an
unused_must_usewarning to be triggered if the given value is not used (returned, stored in a variable, etc) by the caller. -
prefetch_read
Prefetch the cache line containing
ptrfor a future read. -
prefetch_read_instruction
Prefetch the cache line containing
ptrinto the instruction cache for a future read. -
prefetch_read_non_temporal
Prefetch the cache line containing
ptrfor a single future read, but attempt to avoid polluting the cache. -
prefetch_write
Prefetch the cache line containing
ptrfor a future write. -
prefetch_write_non_temporal
Prefetch the cache line containing
ptrfor a single future write, but attempt to avoid polluting the cache. -
select_unpredictable
Returns either
true_valorfalse_valdepending on the value ofcondition, with a hint to the compiler thatconditionis unlikely to be correctly predicted by a CPU’s branch predictor. - spin_loop Emits a machine instruction to signal the processor that it is running in a busy-wait spin-loop ("spin lock").
- unlikely Hints to the compiler that a branch condition is unlikely to be true. Returns the value passed to it.
- unreachable_unchecked Informs the compiler that the site which is calling this function is not reachable, possibly enabling further optimizations.