1 use crate::cdsl::settings::{SettingGroup, SettingGroupBuilder}; 2 3 pub(crate) fn define() -> SettingGroup { 4 let mut settings = SettingGroupBuilder::new("shared"); 5 6 settings.add_bool( 7 "regalloc_checker", 8 "Enable the symbolic checker for register allocation.", 9 r#" 10 This performs a verification that the register allocator preserves 11 equivalent dataflow with respect to the original (pre-regalloc) 12 program. This analysis is somewhat expensive. However, if it succeeds, 13 it provides independent evidence (by a carefully-reviewed, from-first-principles 14 analysis) that no regalloc bugs were triggered for the particular compilations 15 performed. This is a valuable assurance to have as regalloc bugs can be 16 very dangerous and difficult to debug. 17 "#, 18 false, 19 ); 20 21 settings.add_bool( 22 "regalloc_verbose_logs", 23 "Enable verbose debug logs for regalloc2.", 24 r#" 25 This adds extra logging for regalloc2 output, that is quite valuable to understand 26 decisions taken by the register allocator as well as debugging it. It is disabled by 27 default, as it can cause many log calls which can slow down compilation by a large 28 amount. 29 "#, 30 false, 31 ); 32 33 settings.add_enum( 34 "opt_level", 35 "Optimization level for generated code.", 36 r#" 37 Supported levels: 38 39 - `none`: Minimise compile time by disabling most optimizations. 40 - `speed`: Generate the fastest possible code 41 - `speed_and_size`: like "speed", but also perform transformations aimed at reducing code size. 42 "#, 43 vec!["none", "speed", "speed_and_size"], 44 ); 45 46 settings.add_bool( 47 "enable_alias_analysis", 48 "Do redundant-load optimizations with alias analysis.", 49 r#" 50 This enables the use of a simple alias analysis to optimize away redundant loads. 51 Only effective when `opt_level` is `speed` or `speed_and_size`. 52 "#, 53 true, 54 ); 55 56 settings.add_bool( 57 "enable_verifier", 58 "Run the Cranelift IR verifier at strategic times during compilation.", 59 r#" 60 This makes compilation slower but catches many bugs. The verifier is always enabled by 61 default, which is useful during development. 62 "#, 63 true, 64 ); 65 66 // Note that Cranelift doesn't currently need an is_pie flag, because PIE is 67 // just PIC where symbols can't be pre-empted, which can be expressed with the 68 // `colocated` flag on external functions and global values. 69 settings.add_bool( 70 "is_pic", 71 "Enable Position-Independent Code generation.", 72 "", 73 false, 74 ); 75 76 settings.add_bool( 77 "use_colocated_libcalls", 78 "Use colocated libcalls.", 79 r#" 80 Generate code that assumes that libcalls can be declared "colocated", 81 meaning they will be defined along with the current function, such that 82 they can use more efficient addressing. 83 "#, 84 false, 85 ); 86 87 settings.add_bool( 88 "enable_float", 89 "Enable the use of floating-point instructions.", 90 r#" 91 Disabling use of floating-point instructions is not yet implemented. 92 "#, 93 true, 94 ); 95 96 settings.add_bool( 97 "enable_nan_canonicalization", 98 "Enable NaN canonicalization.", 99 r#" 100 This replaces NaNs with a single canonical value, for users requiring 101 entirely deterministic WebAssembly computation. This is not required 102 by the WebAssembly spec, so it is not enabled by default. 103 "#, 104 false, 105 ); 106 107 settings.add_bool( 108 "enable_pinned_reg", 109 "Enable the use of the pinned register.", 110 r#" 111 This register is excluded from register allocation, and is completely under the control of 112 the end-user. It is possible to read it via the get_pinned_reg instruction, and to set it 113 with the set_pinned_reg instruction. 114 "#, 115 false, 116 ); 117 118 settings.add_bool( 119 "enable_simd", 120 "Enable the use of SIMD instructions.", 121 "", 122 false, 123 ); 124 125 settings.add_bool( 126 "enable_atomics", 127 "Enable the use of atomic instructions", 128 "", 129 true, 130 ); 131 132 settings.add_bool( 133 "enable_safepoints", 134 "Enable safepoint instruction insertions.", 135 r#" 136 This will allow the emit_stack_maps() function to insert the safepoint 137 instruction on top of calls and interrupt traps in order to display the 138 live reference values at that point in the program. 139 "#, 140 false, 141 ); 142 143 settings.add_enum( 144 "tls_model", 145 "Defines the model used to perform TLS accesses.", 146 "", 147 vec!["none", "elf_gd", "macho", "coff"], 148 ); 149 150 settings.add_enum( 151 "libcall_call_conv", 152 "Defines the calling convention to use for LibCalls call expansion.", 153 r#" 154 This may be different from the ISA default calling convention. 155 156 The default value is to use the same calling convention as the ISA 157 default calling convention. 158 159 This list should be kept in sync with the list of calling 160 conventions available in isa/call_conv.rs. 161 "#, 162 vec![ 163 "isa_default", 164 "fast", 165 "cold", 166 "system_v", 167 "windows_fastcall", 168 "apple_aarch64", 169 "probestack", 170 ], 171 ); 172 173 settings.add_bool( 174 "enable_llvm_abi_extensions", 175 "Enable various ABI extensions defined by LLVM's behavior.", 176 r#" 177 In some cases, LLVM's implementation of an ABI (calling convention) 178 goes beyond a standard and supports additional argument types or 179 behavior. This option instructs Cranelift codegen to follow LLVM's 180 behavior where applicable. 181 182 Currently, this applies only to Windows Fastcall on x86-64, and 183 allows an `i128` argument to be spread across two 64-bit integer 184 registers. The Fastcall implementation otherwise does not support 185 `i128` arguments, and will panic if they are present and this 186 option is not set. 187 "#, 188 false, 189 ); 190 191 settings.add_bool( 192 "unwind_info", 193 "Generate unwind information.", 194 r#" 195 This increases metadata size and compile time, but allows for the 196 debugger to trace frames, is needed for GC tracing that relies on 197 libunwind (such as in Wasmtime), and is unconditionally needed on 198 certain platforms (such as Windows) that must always be able to unwind. 199 "#, 200 true, 201 ); 202 203 settings.add_bool( 204 "preserve_frame_pointers", 205 "Preserve frame pointers", 206 r#" 207 Preserving frame pointers -- even inside leaf functions -- makes it 208 easy to capture the stack of a running program, without requiring any 209 side tables or metadata (like `.eh_frame` sections). Many sampling 210 profilers and similar tools walk frame pointers to capture stacks. 211 Enabling this option will play nice with those tools. 212 "#, 213 false, 214 ); 215 216 settings.add_bool( 217 "machine_code_cfg_info", 218 "Generate CFG metadata for machine code.", 219 r#" 220 This increases metadata size and compile time, but allows for the 221 embedder to more easily post-process or analyze the generated 222 machine code. It provides code offsets for the start of each 223 basic block in the generated machine code, and a list of CFG 224 edges (with blocks identified by start offsets) between them. 225 This is useful for, e.g., machine-code analyses that verify certain 226 properties of the generated code. 227 "#, 228 false, 229 ); 230 231 // Stack probing options. 232 233 settings.add_bool( 234 "enable_probestack", 235 "Enable the use of stack probes for supported calling conventions.", 236 "", 237 false, 238 ); 239 240 settings.add_bool( 241 "probestack_func_adjusts_sp", 242 "Enable if the stack probe adjusts the stack pointer.", 243 "", 244 false, 245 ); 246 247 settings.add_num( 248 "probestack_size_log2", 249 "The log2 of the size of the stack guard region.", 250 r#" 251 Stack frames larger than this size will have stack overflow checked 252 by calling the probestack function. 253 254 The default is 12, which translates to a size of 4096. 255 "#, 256 12, 257 ); 258 259 settings.add_enum( 260 "probestack_strategy", 261 "Controls what kinds of stack probes are emitted.", 262 r#" 263 Supported strategies: 264 265 - `outline`: Always emits stack probes as calls to a probe stack function. 266 - `inline`: Always emits inline stack probes. 267 "#, 268 vec!["outline", "inline"], 269 ); 270 271 // Jump table options. 272 273 settings.add_bool( 274 "enable_jump_tables", 275 "Enable the use of jump tables in generated machine code.", 276 "", 277 true, 278 ); 279 280 // Spectre options. 281 282 settings.add_bool( 283 "enable_heap_access_spectre_mitigation", 284 "Enable Spectre mitigation on heap bounds checks.", 285 r#" 286 This is a no-op for any heap that needs no bounds checks; e.g., 287 if the limit is static and the guard region is large enough that 288 the index cannot reach past it. 289 290 This option is enabled by default because it is highly 291 recommended for secure sandboxing. The embedder should consider 292 the security implications carefully before disabling this option. 293 "#, 294 true, 295 ); 296 297 settings.add_bool( 298 "enable_table_access_spectre_mitigation", 299 "Enable Spectre mitigation on table bounds checks.", 300 r#" 301 This option uses a conditional move to ensure that when a table 302 access index is bounds-checked and a conditional branch is used 303 for the out-of-bounds case, a misspeculation of that conditional 304 branch (falsely predicted in-bounds) will select an in-bounds 305 index to load on the speculative path. 306 307 This option is enabled by default because it is highly 308 recommended for secure sandboxing. The embedder should consider 309 the security implications carefully before disabling this option. 310 "#, 311 true, 312 ); 313 314 settings.add_bool( 315 "enable_incremental_compilation_cache_checks", 316 "Enable additional checks for debugging the incremental compilation cache.", 317 r#" 318 Enables additional checks that are useful during development of the incremental 319 compilation cache. This should be mostly useful for Cranelift hackers, as well as for 320 helping to debug false incremental cache positives for embedders. 321 322 This option is disabled by default and requires enabling the "incremental-cache" Cargo 323 feature in cranelift-codegen. 324 "#, 325 false, 326 ); 327 328 settings.add_num( 329 "bb_padding_log2_minus_one", 330 "The log2 of the size to insert dummy padding between basic blocks", 331 r#" 332 This is a debugging option for stressing various cases during code 333 generation without requiring large functions. This will insert 334 0-byte padding between basic blocks of the specified size. 335 336 The amount of padding inserted two raised to the power of this value 337 minus one. If this value is 0 then no padding is inserted. 338 339 The default for this option is 0 to insert no padding as it's only 340 intended for testing and development. 341 "#, 342 0, 343 ); 344 345 // When adding new settings please check if they can also be added 346 // in cranelift/fuzzgen/src/lib.rs for fuzzing. 347 settings.build() 348 } 349