Path: blob/main/cranelift/codegen/meta/src/shared/settings.rs
1693 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_float",116"Enable the use of floating-point instructions.",117r#"118Disabling use of floating-point instructions is not yet implemented.119"#,120true,121);122123settings.add_bool(124"enable_nan_canonicalization",125"Enable NaN canonicalization.",126r#"127This replaces NaNs with a single canonical value, for users requiring128entirely deterministic WebAssembly computation. This is not required129by the WebAssembly spec, so it is not enabled by default.130"#,131false,132);133134settings.add_bool(135"enable_pinned_reg",136"Enable the use of the pinned register.",137r#"138This register is excluded from register allocation, and is completely under the control of139the end-user. It is possible to read it via the get_pinned_reg instruction, and to set it140with the set_pinned_reg instruction.141"#,142false,143);144145settings.add_bool(146"enable_atomics",147"Enable the use of atomic instructions",148"",149true,150);151152settings.add_bool(153"enable_safepoints",154"Enable safepoint instruction insertions.",155r#"156This will allow the emit_stack_maps() function to insert the safepoint157instruction on top of calls and interrupt traps in order to display the158live reference values at that point in the program.159"#,160false,161);162163settings.add_enum(164"tls_model",165"Defines the model used to perform TLS accesses.",166"",167vec!["none", "elf_gd", "macho", "coff"],168);169170settings.add_enum(171"stack_switch_model",172"Defines the model used to performing stack switching.",173r#"174This determines the compilation of `stack_switch` instructions. If175set to `basic`, we simply save all registers, update stack pointer176and frame pointer (if needed), and jump to the target IP.177If set to `update_windows_tib`, we *additionally* update information178about the active stack in Windows' Thread Information Block.179"#,180vec!["none", "basic", "update_windows_tib"],181);182183settings.add_enum(184"libcall_call_conv",185"Defines the calling convention to use for LibCalls call expansion.",186r#"187This may be different from the ISA default calling convention.188189The default value is to use the same calling convention as the ISA190default calling convention.191192This list should be kept in sync with the list of calling193conventions available in isa/call_conv.rs.194"#,195vec![196"isa_default",197"fast",198"cold",199"system_v",200"windows_fastcall",201"apple_aarch64",202"probestack",203],204);205206settings.add_bool(207"enable_llvm_abi_extensions",208"Enable various ABI extensions defined by LLVM's behavior.",209r#"210In some cases, LLVM's implementation of an ABI (calling convention)211goes beyond a standard and supports additional argument types or212behavior. This option instructs Cranelift codegen to follow LLVM's213behavior where applicable.214215Currently, this applies only to Windows Fastcall on x86-64, and216allows an `i128` argument to be spread across two 64-bit integer217registers. The Fastcall implementation otherwise does not support218`i128` arguments, and will panic if they are present and this219option is not set.220"#,221false,222);223224settings.add_bool(225"enable_multi_ret_implicit_sret",226"Enable support for sret arg introduction when there are too many ret vals.",227r#"228When there are more returns than available return registers, the229return value has to be returned through the introduction of a230return area pointer. Normally this return area pointer has to be231introduced as `ArgumentPurpose::StructReturn` parameter, but for232backward compatibility reasons Cranelift also supports implicitly233introducing this parameter and writing the return values through it.234235**This option currently does not conform to platform ABIs and the236used ABI should not be assumed to remain the same between Cranelift237versions.**238239This option is **deprecated** and will be removed in the future.240241Because of the above issues, and complexities of native ABI support242for the concept in general, Cranelift's support for multiple return243values may also be removed in the future (#9510). For the most244robust solution, it is recommended to build a convention on top of245Cranelift's primitives for passing multiple return values, for246example by allocating a stackslot in the caller, passing it as an247explicit StructReturn argument, storing return values in the callee,248and loading results in the caller.249"#,250false,251);252253settings.add_bool(254"unwind_info",255"Generate unwind information.",256r#"257This increases metadata size and compile time, but allows for the258debugger to trace frames, is needed for GC tracing that relies on259libunwind (such as in Wasmtime), and is unconditionally needed on260certain platforms (such as Windows) that must always be able to unwind.261"#,262true,263);264265settings.add_bool(266"preserve_frame_pointers",267"Preserve frame pointers",268r#"269Preserving frame pointers -- even inside leaf functions -- makes it270easy to capture the stack of a running program, without requiring any271side tables or metadata (like `.eh_frame` sections). Many sampling272profilers and similar tools walk frame pointers to capture stacks.273Enabling this option will play nice with those tools.274"#,275false,276);277278settings.add_bool(279"machine_code_cfg_info",280"Generate CFG metadata for machine code.",281r#"282This increases metadata size and compile time, but allows for the283embedder to more easily post-process or analyze the generated284machine code. It provides code offsets for the start of each285basic block in the generated machine code, and a list of CFG286edges (with blocks identified by start offsets) between them.287This is useful for, e.g., machine-code analyses that verify certain288properties of the generated code.289"#,290false,291);292293// Stack probing options.294295settings.add_bool(296"enable_probestack",297"Enable the use of stack probes for supported calling conventions.",298"",299false,300);301302settings.add_num(303"probestack_size_log2",304"The log2 of the size of the stack guard region.",305r#"306Stack frames larger than this size will have stack overflow checked307by calling the probestack function.308309The default is 12, which translates to a size of 4096.310"#,31112,312);313314settings.add_enum(315"probestack_strategy",316"Controls what kinds of stack probes are emitted.",317r#"318Supported strategies:319320- `outline`: Always emits stack probes as calls to a probe stack function.321- `inline`: Always emits inline stack probes.322"#,323vec!["outline", "inline"],324);325326// Jump table options.327328settings.add_bool(329"enable_jump_tables",330"Enable the use of jump tables in generated machine code.",331"",332true,333);334335// Spectre options.336337settings.add_bool(338"enable_heap_access_spectre_mitigation",339"Enable Spectre mitigation on heap bounds checks.",340r#"341This is a no-op for any heap that needs no bounds checks; e.g.,342if the limit is static and the guard region is large enough that343the index cannot reach past it.344345This option is enabled by default because it is highly346recommended for secure sandboxing. The embedder should consider347the security implications carefully before disabling this option.348"#,349true,350);351352settings.add_bool(353"enable_table_access_spectre_mitigation",354"Enable Spectre mitigation on table bounds checks.",355r#"356This option uses a conditional move to ensure that when a table357access index is bounds-checked and a conditional branch is used358for the out-of-bounds case, a misspeculation of that conditional359branch (falsely predicted in-bounds) will select an in-bounds360index to load on the speculative path.361362This option is enabled by default because it is highly363recommended for secure sandboxing. The embedder should consider364the security implications carefully before disabling this option.365"#,366true,367);368369settings.add_bool(370"enable_incremental_compilation_cache_checks",371"Enable additional checks for debugging the incremental compilation cache.",372r#"373Enables additional checks that are useful during development of the incremental374compilation cache. This should be mostly useful for Cranelift hackers, as well as for375helping to debug false incremental cache positives for embedders.376377This option is disabled by default and requires enabling the "incremental-cache" Cargo378feature in cranelift-codegen.379"#,380false,381);382383settings.add_num(384"bb_padding_log2_minus_one",385"The log2 of the size to insert dummy padding between basic blocks",386r#"387This is a debugging option for stressing various cases during code388generation without requiring large functions. This will insert3890-byte padding between basic blocks of the specified size.390391The amount of padding inserted two raised to the power of this value392minus one. If this value is 0 then no padding is inserted.393394The default for this option is 0 to insert no padding as it's only395intended for testing and development.396"#,3970,398);399400settings.add_num(401"log2_min_function_alignment",402"The log2 of the minimum alignment of functions",403"The bigger of this value and the default alignment will be used as actual alignment.",4040,405);406407// When adding new settings please check if they can also be added408// in cranelift/fuzzgen/src/lib.rs for fuzzing.409settings.build()410}411412413