cranelift_codegen::settings

Struct Flags

Source
pub struct Flags { /* private fields */ }
Expand description

Flags group shared.

Implementations§

Source§

impl Flags

Source

pub fn new(builder: Builder) -> Self

Create flags shared settings group.

Source§

impl Flags

Source

pub fn iter(&self) -> impl Iterator<Item = Value>

Iterates the setting values.

Source§

impl Flags

User-defined settings.

Source

pub fn predicate_view(&self) -> PredicateView<'_>

Get a view of the boolean predicates.

Source

pub fn opt_level(&self) -> OptLevel

Optimization level for generated code.

Supported levels:

  • none: Minimise compile time by disabling most optimizations.
  • speed: Generate the fastest possible code
  • speed_and_size: like “speed”, but also perform transformations aimed at reducing code size.
Source

pub fn tls_model(&self) -> TlsModel

Defines the model used to perform TLS accesses.

Source

pub fn libcall_call_conv(&self) -> LibcallCallConv

Defines the calling convention to use for LibCalls call expansion.

This may be different from the ISA default calling convention.

The default value is to use the same calling convention as the ISA default calling convention.

This list should be kept in sync with the list of calling conventions available in isa/call_conv.rs.

Source

pub fn probestack_size_log2(&self) -> u8

The log2 of the size of the stack guard region.

Stack frames larger than this size will have stack overflow checked by calling the probestack function.

The default is 12, which translates to a size of 4096.

Source

pub fn probestack_strategy(&self) -> ProbestackStrategy

Controls what kinds of stack probes are emitted.

Supported strategies:

  • outline: Always emits stack probes as calls to a probe stack function.
  • inline: Always emits inline stack probes.
Source

pub fn bb_padding_log2_minus_one(&self) -> u8

The log2 of the size to insert dummy padding between basic blocks

This is a debugging option for stressing various cases during code generation without requiring large functions. This will insert 0-byte padding between basic blocks of the specified size.

The amount of padding inserted two raised to the power of this value minus one. If this value is 0 then no padding is inserted.

The default for this option is 0 to insert no padding as it’s only intended for testing and development.

Source

pub fn regalloc_checker(&self) -> bool

Enable the symbolic checker for register allocation.

This performs a verification that the register allocator preserves equivalent dataflow with respect to the original (pre-regalloc) program. This analysis is somewhat expensive. However, if it succeeds, it provides independent evidence (by a carefully-reviewed, from-first-principles analysis) that no regalloc bugs were triggered for the particular compilations performed. This is a valuable assurance to have as regalloc bugs can be very dangerous and difficult to debug.

Source

pub fn regalloc_verbose_logs(&self) -> bool

Enable verbose debug logs for regalloc2.

This adds extra logging for regalloc2 output, that is quite valuable to understand decisions taken by the register allocator as well as debugging it. It is disabled by default, as it can cause many log calls which can slow down compilation by a large amount.

Source

pub fn enable_alias_analysis(&self) -> bool

Do redundant-load optimizations with alias analysis.

This enables the use of a simple alias analysis to optimize away redundant loads. Only effective when opt_level is speed or speed_and_size.

Source

pub fn enable_verifier(&self) -> bool

Run the Cranelift IR verifier at strategic times during compilation.

This makes compilation slower but catches many bugs. The verifier is always enabled by default, which is useful during development.

Source

pub fn enable_pcc(&self) -> bool

Enable proof-carrying code translation validation.

This adds a proof-carrying-code mode. Proof-carrying code (PCC) is a strategy to verify that the compiler preserves certain properties or invariants in the compiled code. For example, a frontend that translates WebAssembly to CLIF can embed PCC facts in the CLIF, and Cranelift will verify that the final machine code satisfies the stated facts at each intermediate computed value. Loads and stores can be marked as “checked” and their memory effects can be verified as safe.

Source

pub fn is_pic(&self) -> bool

Enable Position-Independent Code generation.

Source

pub fn use_colocated_libcalls(&self) -> bool

Use colocated libcalls.

Generate code that assumes that libcalls can be declared “colocated”, meaning they will be defined along with the current function, such that they can use more efficient addressing.

Source

pub fn enable_float(&self) -> bool

Enable the use of floating-point instructions.

Disabling use of floating-point instructions is not yet implemented.

Source

pub fn enable_nan_canonicalization(&self) -> bool

Enable NaN canonicalization.

This replaces NaNs with a single canonical value, for users requiring entirely deterministic WebAssembly computation. This is not required by the WebAssembly spec, so it is not enabled by default.

Source

pub fn enable_pinned_reg(&self) -> bool

Enable the use of the pinned register.

This register is excluded from register allocation, and is completely under the control of the end-user. It is possible to read it via the get_pinned_reg instruction, and to set it with the set_pinned_reg instruction.

Source

pub fn enable_atomics(&self) -> bool

Enable the use of atomic instructions

Source

pub fn enable_safepoints(&self) -> bool

Enable safepoint instruction insertions.

This will allow the emit_stack_maps() function to insert the safepoint instruction on top of calls and interrupt traps in order to display the live reference values at that point in the program.

Source

pub fn enable_llvm_abi_extensions(&self) -> bool

Enable various ABI extensions defined by LLVM’s behavior.

In some cases, LLVM’s implementation of an ABI (calling convention) goes beyond a standard and supports additional argument types or behavior. This option instructs Cranelift codegen to follow LLVM’s behavior where applicable.

Currently, this applies only to Windows Fastcall on x86-64, and allows an i128 argument to be spread across two 64-bit integer registers. The Fastcall implementation otherwise does not support i128 arguments, and will panic if they are present and this option is not set.

Source

pub fn unwind_info(&self) -> bool

Generate unwind information.

This increases metadata size and compile time, but allows for the debugger to trace frames, is needed for GC tracing that relies on libunwind (such as in Wasmtime), and is unconditionally needed on certain platforms (such as Windows) that must always be able to unwind.

Source

pub fn preserve_frame_pointers(&self) -> bool

Preserve frame pointers

Preserving frame pointers – even inside leaf functions – makes it easy to capture the stack of a running program, without requiring any side tables or metadata (like .eh_frame sections). Many sampling profilers and similar tools walk frame pointers to capture stacks. Enabling this option will play nice with those tools.

Source

pub fn machine_code_cfg_info(&self) -> bool

Generate CFG metadata for machine code.

This increases metadata size and compile time, but allows for the embedder to more easily post-process or analyze the generated machine code. It provides code offsets for the start of each basic block in the generated machine code, and a list of CFG edges (with blocks identified by start offsets) between them. This is useful for, e.g., machine-code analyses that verify certain properties of the generated code.

Source

pub fn enable_probestack(&self) -> bool

Enable the use of stack probes for supported calling conventions.

Source

pub fn enable_jump_tables(&self) -> bool

Enable the use of jump tables in generated machine code.

Source

pub fn enable_heap_access_spectre_mitigation(&self) -> bool

Enable Spectre mitigation on heap bounds checks.

This is a no-op for any heap that needs no bounds checks; e.g., if the limit is static and the guard region is large enough that the index cannot reach past it.

This option is enabled by default because it is highly recommended for secure sandboxing. The embedder should consider the security implications carefully before disabling this option.

Source

pub fn enable_table_access_spectre_mitigation(&self) -> bool

Enable Spectre mitigation on table bounds checks.

This option uses a conditional move to ensure that when a table access index is bounds-checked and a conditional branch is used for the out-of-bounds case, a misspeculation of that conditional branch (falsely predicted in-bounds) will select an in-bounds index to load on the speculative path.

This option is enabled by default because it is highly recommended for secure sandboxing. The embedder should consider the security implications carefully before disabling this option.

Source

pub fn enable_incremental_compilation_cache_checks(&self) -> bool

Enable additional checks for debugging the incremental compilation cache.

Enables additional checks that are useful during development of the incremental compilation cache. This should be mostly useful for Cranelift hackers, as well as for helping to debug false incremental cache positives for embedders.

This option is disabled by default and requires enabling the “incremental-cache” Cargo feature in cranelift-codegen.

Trait Implementations§

Source§

impl Clone for Flags

Source§

fn clone(&self) -> Flags

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Display for Flags

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> From<&'a Flags> for FlagsOrIsa<'a>

Source§

fn from(flags: &'a Flags) -> FlagsOrIsa<'_>

Converts to this type from the input type.
Source§

impl Hash for Flags

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more

Auto Trait Implementations§

§

impl Freeze for Flags

§

impl RefUnwindSafe for Flags

§

impl Send for Flags

§

impl Sync for Flags

§

impl Unpin for Flags

§

impl UnwindSafe for Flags

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.