Path: blob/main/cranelift/codegen/meta/src/shared/settings.rs
3069 views
use crate::cdsl::settings::{SettingGroup, SettingGroupBuilder};12pub(crate) fn define() -> SettingGroup {3let mut settings = SettingGroupBuilder::new("shared");45settings.add_bool(6"regalloc_checker",7"Enable the symbolic checker for register allocation.",8r#"9This performs a verification that the register allocator preserves10equivalent dataflow with respect to the original (pre-regalloc)11program. This analysis is somewhat expensive. However, if it succeeds,12it provides independent evidence (by a carefully-reviewed, from-first-principles13analysis) that no regalloc bugs were triggered for the particular compilations14performed. This is a valuable assurance to have as regalloc bugs can be15very dangerous and difficult to debug.16"#,17false,18);1920settings.add_bool(21"regalloc_verbose_logs",22"Enable verbose debug logs for regalloc2.",23r#"24This adds extra logging for regalloc2 output, that is quite valuable to understand25decisions taken by the register allocator as well as debugging it. It is disabled by26default, as it can cause many log calls which can slow down compilation by a large27amount.28"#,29false,30);3132settings.add_enum(33"regalloc_algorithm",34"Algorithm to use in register allocator.",35r#"36Supported options:3738- `backtracking`: A backtracking allocator with range splitting; more expensive39but generates better code.40- `single_pass`: A single-pass algorithm that yields quick compilation but41results in code with more register spills and moves.42"#,43vec!["backtracking", "single_pass"],44);4546settings.add_enum(47"opt_level",48"Optimization level for generated code.",49r#"50Supported levels:5152- `none`: Minimise compile time by disabling most optimizations.53- `speed`: Generate the fastest possible code54- `speed_and_size`: like "speed", but also perform transformations aimed at reducing code size.55"#,56vec!["none", "speed", "speed_and_size"],57);5859settings.add_bool(60"enable_alias_analysis",61"Do redundant-load optimizations with alias analysis.",62r#"63This enables the use of a simple alias analysis to optimize away redundant loads.64Only effective when `opt_level` is `speed` or `speed_and_size`.65"#,66true,67);6869settings.add_bool(70"enable_verifier",71"Run the Cranelift IR verifier at strategic times during compilation.",72r#"73This makes compilation slower but catches many bugs. The verifier is always enabled by74default, which is useful during development.75"#,76true,77);7879settings.add_bool(80"enable_pcc",81"Enable proof-carrying code translation validation.",82r#"83This adds a proof-carrying-code mode. Proof-carrying code (PCC) is a strategy to verify84that the compiler preserves certain properties or invariants in the compiled code.85For example, a frontend that translates WebAssembly to CLIF can embed PCC facts in86the CLIF, and Cranelift will verify that the final machine code satisfies the stated87facts at each intermediate computed value. Loads and stores can be marked as "checked"88and their memory effects can be verified as safe.89"#,90false,91);9293// Note that Cranelift doesn't currently need an is_pie flag, because PIE is94// just PIC where symbols can't be pre-empted, which can be expressed with the95// `colocated` flag on external functions and global values.96settings.add_bool(97"is_pic",98"Enable Position-Independent Code generation.",99"",100false,101);102103settings.add_bool(104"use_colocated_libcalls",105"Use colocated libcalls.",106r#"107Generate code that assumes that libcalls can be declared "colocated",108meaning they will be defined along with the current function, such that109they can use more efficient addressing.110"#,111false,112);113114settings.add_bool(115"enable_nan_canonicalization",116"Enable NaN canonicalization.",117r#"118This replaces NaNs with a single canonical value, for users requiring119entirely deterministic WebAssembly computation. This is not required120by the WebAssembly spec, so it is not enabled by default.121"#,122false,123);124125settings.add_bool(126"enable_pinned_reg",127"Enable the use of the pinned register.",128r#"129This register is excluded from register allocation, and is completely under the control of130the end-user. It is possible to read it via the get_pinned_reg instruction, and to set it131with the set_pinned_reg instruction.132"#,133false,134);135136settings.add_enum(137"tls_model",138"Defines the model used to perform TLS accesses.",139"",140vec!["none", "elf_gd", "macho", "coff"],141);142143settings.add_enum(144"stack_switch_model",145"Defines the model used to performing stack switching.",146r#"147This determines the compilation of `stack_switch` instructions. If148set to `basic`, we simply save all registers, update stack pointer149and frame pointer (if needed), and jump to the target IP.150If set to `update_windows_tib`, we *additionally* update information151about the active stack in Windows' Thread Information Block.152"#,153vec!["none", "basic", "update_windows_tib"],154);155156settings.add_enum(157"libcall_call_conv",158"Defines the calling convention to use for LibCalls call expansion.",159r#"160This may be different from the ISA default calling convention.161162The default value is to use the same calling convention as the ISA163default calling convention.164165This list should be kept in sync with the list of calling166conventions available in isa/call_conv.rs.167"#,168vec![169"isa_default",170"fast",171"system_v",172"windows_fastcall",173"apple_aarch64",174"probestack",175"preserve_all",176],177);178179settings.add_bool(180"enable_llvm_abi_extensions",181"Enable various ABI extensions defined by LLVM's behavior.",182r#"183In some cases, LLVM's implementation of an ABI (calling convention)184goes beyond a standard and supports additional argument types or185behavior. This option instructs Cranelift codegen to follow LLVM's186behavior where applicable.187188Currently, this applies only to Windows Fastcall on x86-64, and189allows an `i128` argument to be spread across two 64-bit integer190registers. The Fastcall implementation otherwise does not support191`i128` arguments, and will panic if they are present and this192option is not set.193"#,194false,195);196197settings.add_bool(198"enable_multi_ret_implicit_sret",199"Enable support for sret arg introduction when there are too many ret vals.",200r#"201When there are more returns than available return registers, the202return value has to be returned through the introduction of a203return area pointer. Normally this return area pointer has to be204introduced as `ArgumentPurpose::StructReturn` parameter, but for205backward compatibility reasons Cranelift also supports implicitly206introducing this parameter and writing the return values through it.207208**This option currently does not conform to platform ABIs and the209used ABI should not be assumed to remain the same between Cranelift210versions.**211212This option is **deprecated** and will be removed in the future.213214Because of the above issues, and complexities of native ABI support215for the concept in general, Cranelift's support for multiple return216values may also be removed in the future (#9510). For the most217robust solution, it is recommended to build a convention on top of218Cranelift's primitives for passing multiple return values, for219example by allocating a stackslot in the caller, passing it as an220explicit StructReturn argument, storing return values in the callee,221and loading results in the caller.222"#,223false,224);225226settings.add_bool(227"unwind_info",228"Generate unwind information.",229r#"230This increases metadata size and compile time, but allows for the231debugger to trace frames, is needed for GC tracing that relies on232libunwind (such as in Wasmtime), and is unconditionally needed on233certain platforms (such as Windows) that must always be able to unwind.234"#,235true,236);237238settings.add_bool(239"preserve_frame_pointers",240"Preserve frame pointers",241r#"242Preserving frame pointers -- even inside leaf functions -- makes it243easy to capture the stack of a running program, without requiring any244side tables or metadata (like `.eh_frame` sections). Many sampling245profilers and similar tools walk frame pointers to capture stacks.246Enabling this option will play nice with those tools.247"#,248false,249);250251settings.add_bool(252"machine_code_cfg_info",253"Generate CFG metadata for machine code.",254r#"255This increases metadata size and compile time, but allows for the256embedder to more easily post-process or analyze the generated257machine code. It provides code offsets for the start of each258basic block in the generated machine code, and a list of CFG259edges (with blocks identified by start offsets) between them.260This is useful for, e.g., machine-code analyses that verify certain261properties of the generated code.262"#,263false,264);265266// Stack probing options.267268settings.add_bool(269"enable_probestack",270"Enable the use of stack probes for supported calling conventions.",271"",272false,273);274275settings.add_num(276"probestack_size_log2",277"The log2 of the size of the stack guard region.",278r#"279Stack frames larger than this size will have stack overflow checked280by calling the probestack function.281282The default is 12, which translates to a size of 4096.283"#,28412,285);286287settings.add_enum(288"probestack_strategy",289"Controls what kinds of stack probes are emitted.",290r#"291Supported strategies:292293- `outline`: Always emits stack probes as calls to a probe stack function.294- `inline`: Always emits inline stack probes.295"#,296vec!["outline", "inline"],297);298299// Spectre options. (Only read by wasmtime-cranelift)300// FIXME move configuration out of Cranelift into Wasmtime301302settings.add_bool(303"enable_heap_access_spectre_mitigation",304"Enable Spectre mitigation on heap bounds checks.",305r#"306This is a no-op for any heap that needs no bounds checks; e.g.,307if the limit is static and the guard region is large enough that308the index cannot reach past it.309310This option is enabled by default because it is highly311recommended for secure sandboxing. The embedder should consider312the security implications carefully before disabling this option.313"#,314true,315);316317settings.add_bool(318"enable_table_access_spectre_mitigation",319"Enable Spectre mitigation on table bounds checks.",320r#"321This option uses a conditional move to ensure that when a table322access index is bounds-checked and a conditional branch is used323for the out-of-bounds case, a misspeculation of that conditional324branch (falsely predicted in-bounds) will select an in-bounds325index to load on the speculative path.326327This option is enabled by default because it is highly328recommended for secure sandboxing. The embedder should consider329the security implications carefully before disabling this option.330"#,331true,332);333334settings.add_bool(335"enable_incremental_compilation_cache_checks",336"Enable additional checks for debugging the incremental compilation cache.",337r#"338Enables additional checks that are useful during development of the incremental339compilation cache. This should be mostly useful for Cranelift hackers, as well as for340helping to debug false incremental cache positives for embedders.341342This option is disabled by default and requires enabling the "incremental-cache" Cargo343feature in cranelift-codegen.344"#,345false,346);347348settings.add_num(349"bb_padding_log2_minus_one",350"The log2 of the size to insert dummy padding between basic blocks",351r#"352This is a debugging option for stressing various cases during code353generation without requiring large functions. This will insert3540-byte padding between basic blocks of the specified size.355356The amount of padding inserted two raised to the power of this value357minus one. If this value is 0 then no padding is inserted.358359The default for this option is 0 to insert no padding as it's only360intended for testing and development.361"#,3620,363);364365settings.add_num(366"log2_min_function_alignment",367"The log2 of the minimum alignment of functions",368"The bigger of this value and the default alignment will be used as actual alignment.",3690,370);371372// When adding new settings please check if they can also be added373// in cranelift/fuzzgen/src/lib.rs for fuzzing.374settings.build()375}376377378