1 //===--- CodeGenOptions.def - Code generation option database ----- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file defines the code generation options. Users of this file
10 // must define the CODEGENOPT macro to make use of this information.
11 // Optionally, the user may also define ENUM_CODEGENOPT (for options
12 // that have enumeration type and VALUE_CODEGENOPT is a code
13 // generation option that describes a value rather than a flag.
15 //===----------------------------------------------------------------------===//
17 # error Define the CODEGENOPT macro to handle language options
20 #ifndef VALUE_CODEGENOPT
21 # define VALUE_CODEGENOPT(Name, Bits, Default) \
22 CODEGENOPT(Name, Bits, Default)
25 #ifndef ENUM_CODEGENOPT
26 # define ENUM_CODEGENOPT(Name, Type, Bits, Default) \
27 CODEGENOPT(Name, Bits, Default)
30 CODEGENOPT(DisableIntegratedAS, 1, 0) ///< -no-integrated-as
31 ENUM_CODEGENOPT(CompressDebugSections, llvm::DebugCompressionType, 2,
32 llvm::DebugCompressionType::None)
33 CODEGENOPT(RelaxELFRelocations, 1, 0) ///< -Wa,--mrelax-relocations
34 CODEGENOPT(AsmVerbose , 1, 0) ///< -dA, -fverbose-asm.
35 CODEGENOPT(PreserveAsmComments, 1, 1) ///< -dA, -fno-preserve-as-comments.
36 CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit __attribute__((malloc)) operator new
37 CODEGENOPT(Autolink , 1, 1) ///< -fno-autolink
38 CODEGENOPT(ObjCAutoRefCountExceptions , 1, 0) ///< Whether ARC should be EH-safe.
39 CODEGENOPT(Backchain , 1, 0) ///< -mbackchain
40 CODEGENOPT(ControlFlowGuard , 1, 0) ///< -cfguard
41 CODEGENOPT(CoverageExtraChecksum, 1, 0) ///< Whether we need a second checksum for functions in GCNO files.
42 CODEGENOPT(CoverageNoFunctionNamesInData, 1, 0) ///< Do not include function names in GCDA files.
43 CODEGENOPT(CoverageExitBlockBeforeBody, 1, 0) ///< Whether to emit the exit block before the body blocks in GCNO files.
44 CODEGENOPT(CXAAtExit , 1, 1) ///< Use __cxa_atexit for calling destructors.
45 CODEGENOPT(RegisterGlobalDtorsWithAtExit, 1, 1) ///< Use atexit or __cxa_atexit to register global destructors.
46 CODEGENOPT(CXXCtorDtorAliases, 1, 0) ///< Emit complete ctors/dtors as linker
47 ///< aliases to base ctors when possible.
48 CODEGENOPT(DataSections , 1, 0) ///< Set when -fdata-sections is enabled.
49 CODEGENOPT(UniqueSectionNames, 1, 1) ///< Set for -funique-section-names.
50 CODEGENOPT(DisableFPElim , 1, 0) ///< Set when -fomit-frame-pointer is enabled.
51 CODEGENOPT(DisableFree , 1, 0) ///< Don't free memory.
52 CODEGENOPT(DiscardValueNames , 1, 0) ///< Discard Value Names from the IR (LLVMContext flag)
53 CODEGENOPT(DisableGCov , 1, 0) ///< Don't run the GCov pass, for testing.
54 CODEGENOPT(DisableLLVMPasses , 1, 0) ///< Don't run any LLVM IR passes to get
55 ///< the pristine IR generated by the
57 CODEGENOPT(DisableLifetimeMarkers, 1, 0) ///< Don't emit any lifetime markers
58 CODEGENOPT(DisableO0ImplyOptNone , 1, 0) ///< Don't annonate function with optnone at O0
59 CODEGENOPT(ExperimentalNewPassManager, 1, 0) ///< Enables the new, experimental
61 CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug information for the new
63 CODEGENOPT(DisableRedZone , 1, 0) ///< Set when -mno-red-zone is enabled.
64 CODEGENOPT(EnableDebugEntryValues, 1, 0) ///< Emit call site parameter dbg info
65 CODEGENOPT(IndirectTlsSegRefs, 1, 0) ///< Set when -mno-tls-direct-seg-refs
67 CODEGENOPT(DisableTailCalls , 1, 0) ///< Do not emit tail calls.
68 CODEGENOPT(NoEscapingBlockTailCalls, 1, 0) ///< Do not emit tail calls from
70 CODEGENOPT(EmitDeclMetadata , 1, 0) ///< Emit special metadata indicating what
71 ///< Decl* various IR entities came from.
72 ///< Only useful when running CodeGen as a
74 CODEGENOPT(EmitVersionIdentMetadata , 1, 1) ///< Emit compiler version metadata.
75 CODEGENOPT(EmitGcovArcs , 1, 0) ///< Emit coverage data files, aka. GCDA.
76 CODEGENOPT(EmitGcovNotes , 1, 0) ///< Emit coverage "notes" files, aka GCNO.
77 CODEGENOPT(EmitOpenCLArgMetadata , 1, 0) ///< Emit OpenCL kernel arg metadata.
78 CODEGENOPT(EmulatedTLS , 1, 0) ///< Set by default or -f[no-]emulated-tls.
79 CODEGENOPT(ExplicitEmulatedTLS , 1, 0) ///< Set if -f[no-]emulated-tls is used.
80 /// Embed Bitcode mode (off/all/bitcode/marker).
81 ENUM_CODEGENOPT(EmbedBitcode, EmbedBitcodeKind, 2, Embed_Off)
82 CODEGENOPT(ForbidGuardVariables , 1, 0) ///< Issue errors if C++ guard variables
84 CODEGENOPT(FunctionSections , 1, 0) ///< Set when -ffunction-sections is enabled.
85 CODEGENOPT(InstrumentFunctions , 1, 0) ///< Set when -finstrument-functions is
87 CODEGENOPT(InstrumentFunctionsAfterInlining , 1, 0) ///< Set when
88 ///< -finstrument-functions-after-inlining is enabled.
89 CODEGENOPT(InstrumentFunctionEntryBare , 1, 0) ///< Set when
90 ///< -finstrument-function-entry-bare is enabled.
91 CODEGENOPT(CFProtectionReturn , 1, 0) ///< if -fcf-protection is
92 ///< set to full or return.
93 CODEGENOPT(CFProtectionBranch , 1, 0) ///< if -fcf-protection is
94 ///< set to full or branch.
95 CODEGENOPT(XRayInstrumentFunctions , 1, 0) ///< Set when -fxray-instrument is
97 CODEGENOPT(StackSizeSection , 1, 0) ///< Set when -fstack-size-section is enabled.
99 ///< Set when -fxray-always-emit-customevents is enabled.
100 CODEGENOPT(XRayAlwaysEmitCustomEvents , 1, 0)
102 ///< Set when -fxray-always-emit-typedevents is enabled.
103 CODEGENOPT(XRayAlwaysEmitTypedEvents , 1, 0)
105 ///< Set the minimum number of instructions in a function to determine selective
106 ///< XRay instrumentation.
107 VALUE_CODEGENOPT(XRayInstructionThreshold , 32, 200)
109 CODEGENOPT(InstrumentForProfiling , 1, 0) ///< Set when -pg is enabled.
110 CODEGENOPT(CallFEntry , 1, 0) ///< Set when -mfentry is enabled.
111 CODEGENOPT(LessPreciseFPMAD , 1, 0) ///< Enable less precise MAD instructions to
113 CODEGENOPT(PrepareForLTO , 1, 0) ///< Set when -flto is enabled on the
115 CODEGENOPT(PrepareForThinLTO , 1, 0) ///< Set when -flto=thin is enabled on the
117 CODEGENOPT(LTOUnit, 1, 0) ///< Emit IR to support LTO unit features (CFI, whole
118 ///< program vtable opt).
119 CODEGENOPT(EnableSplitLTOUnit, 1, 0) ///< Enable LTO unit splitting to support
120 /// CFI and traditional whole program
121 /// devirtualization that require whole
122 /// program IR support.
123 CODEGENOPT(IncrementalLinkerCompatible, 1, 0) ///< Emit an object file which can
124 ///< be used with an incremental
126 CODEGENOPT(MergeAllConstants , 1, 1) ///< Merge identical constants.
127 CODEGENOPT(MergeFunctions , 1, 0) ///< Set when -fmerge-functions is enabled.
128 CODEGENOPT(MSVolatile , 1, 0) ///< Set when /volatile:ms is enabled.
129 CODEGENOPT(NoCommon , 1, 0) ///< Set when -fno-common or C++ is enabled.
130 CODEGENOPT(NoDwarfDirectoryAsm , 1, 0) ///< Set when -fno-dwarf-directory-asm is
132 CODEGENOPT(NoExecStack , 1, 0) ///< Set when -Wa,--noexecstack is enabled.
133 CODEGENOPT(FatalWarnings , 1, 0) ///< Set when -Wa,--fatal-warnings is
135 CODEGENOPT(EnableSegmentedStacks , 1, 0) ///< Set when -fsplit-stack is enabled.
136 CODEGENOPT(NoImplicitFloat , 1, 0) ///< Set when -mno-implicit-float is enabled.
137 CODEGENOPT(NoInfsFPMath , 1, 0) ///< Assume FP arguments, results not +-Inf.
138 CODEGENOPT(NoSignedZeros , 1, 0) ///< Allow ignoring the signedness of FP zero
139 CODEGENOPT(NullPointerIsValid , 1, 0) ///< Assume Null pointer deference is defined.
140 CODEGENOPT(Reassociate , 1, 0) ///< Allow reassociation of FP math ops
141 CODEGENOPT(ReciprocalMath , 1, 0) ///< Allow FP divisions to be reassociated.
142 CODEGENOPT(NoTrappingMath , 1, 0) ///< Set when -fno-trapping-math is enabled.
143 CODEGENOPT(NoNaNsFPMath , 1, 0) ///< Assume FP arguments, results not NaN.
144 CODEGENOPT(FlushDenorm , 1, 0) ///< Allow FP denorm numbers to be flushed to zero
145 CODEGENOPT(CorrectlyRoundedDivSqrt, 1, 0) ///< -cl-fp32-correctly-rounded-divide-sqrt
147 /// When false, this attempts to generate code as if the result of an
148 /// overflowing conversion matches the overflowing behavior of a target's native
149 /// float-to-int conversion instructions.
150 CODEGENOPT(StrictFloatCastOverflow, 1, 1)
152 CODEGENOPT(UniformWGSize , 1, 0) ///< -cl-uniform-work-group-size
153 CODEGENOPT(NoZeroInitializedInBSS , 1, 0) ///< -fno-zero-initialized-in-bss.
154 /// Method of Objective-C dispatch to use.
155 ENUM_CODEGENOPT(ObjCDispatchMethod, ObjCDispatchMethodKind, 2, Legacy)
156 /// Replace certain message sends with calls to ObjC runtime entrypoints
157 CODEGENOPT(ObjCConvertMessagesToRuntimeCalls , 1, 1)
158 CODEGENOPT(OmitLeafFramePointer , 1, 0) ///< Set when -momit-leaf-frame-pointer is
161 VALUE_CODEGENOPT(OptimizationLevel, 2, 0) ///< The -O[0-3] option specified.
162 VALUE_CODEGENOPT(OptimizeSize, 2, 0) ///< If -Os (==1) or -Oz (==2) is specified.
164 /// Choose profile instrumenation kind or no instrumentation.
165 ENUM_CODEGENOPT(ProfileInstr, ProfileInstrKind, 2, ProfileNone)
166 /// Choose profile kind for PGO use compilation.
167 ENUM_CODEGENOPT(ProfileUse, ProfileInstrKind, 2, ProfileNone)
168 CODEGENOPT(CoverageMapping , 1, 0) ///< Generate coverage mapping regions to
169 ///< enable code coverage analysis.
170 CODEGENOPT(DumpCoverageMapping , 1, 0) ///< Dump the generated coverage mapping
173 /// If -fpcc-struct-return or -freg-struct-return is specified.
174 ENUM_CODEGENOPT(StructReturnConvention, StructReturnConventionKind, 2, SRCK_Default)
176 CODEGENOPT(RelaxAll , 1, 0) ///< Relax all machine code instructions.
177 CODEGENOPT(RelaxedAliasing , 1, 0) ///< Set when -fno-strict-aliasing is enabled.
178 CODEGENOPT(StructPathTBAA , 1, 0) ///< Whether or not to use struct-path TBAA.
179 CODEGENOPT(NewStructPathTBAA , 1, 0) ///< Whether or not to use enhanced struct-path TBAA.
180 CODEGENOPT(SaveTempLabels , 1, 0) ///< Save temporary labels.
181 CODEGENOPT(SanitizeAddressUseAfterScope , 1, 0) ///< Enable use-after-scope detection
182 ///< in AddressSanitizer
183 CODEGENOPT(SanitizeAddressPoisonCustomArrayCookie, 1,
184 0) ///< Enable poisoning operator new[] which is not a replaceable
185 ///< global allocation function in AddressSanitizer
186 CODEGENOPT(SanitizeAddressGlobalsDeadStripping, 1, 0) ///< Enable linker dead stripping
187 ///< of globals in AddressSanitizer
188 CODEGENOPT(SanitizeAddressUseOdrIndicator, 1, 0) ///< Enable ODR indicator globals
189 CODEGENOPT(SanitizeMemoryTrackOrigins, 2, 0) ///< Enable tracking origins in
191 CODEGENOPT(SanitizeMemoryUseAfterDtor, 1, 0) ///< Enable use-after-delete detection
192 ///< in MemorySanitizer
193 CODEGENOPT(SanitizeCfiCrossDso, 1, 0) ///< Enable cross-dso support in CFI.
194 CODEGENOPT(SanitizeMinimalRuntime, 1, 0) ///< Use "_minimal" sanitizer runtime for
196 CODEGENOPT(SanitizeCfiICallGeneralizePointers, 1, 0) ///< Generalize pointer types in
197 ///< CFI icall function signatures
198 CODEGENOPT(SanitizeCoverageType, 2, 0) ///< Type of sanitizer coverage
199 ///< instrumentation.
200 CODEGENOPT(SanitizeCoverageIndirectCalls, 1, 0) ///< Enable sanitizer coverage
201 ///< for indirect calls.
202 CODEGENOPT(SanitizeCoverageTraceBB, 1, 0) ///< Enable basic block tracing in
203 ///< in sanitizer coverage.
204 CODEGENOPT(SanitizeCoverageTraceCmp, 1, 0) ///< Enable cmp instruction tracing
205 ///< in sanitizer coverage.
206 CODEGENOPT(SanitizeCoverageTraceDiv, 1, 0) ///< Enable div instruction tracing
207 ///< in sanitizer coverage.
208 CODEGENOPT(SanitizeCoverageTraceGep, 1, 0) ///< Enable GEP instruction tracing
209 ///< in sanitizer coverage.
210 CODEGENOPT(SanitizeCoverage8bitCounters, 1, 0) ///< Use 8-bit frequency counters
211 ///< in sanitizer coverage.
212 CODEGENOPT(SanitizeCoverageTracePC, 1, 0) ///< Enable PC tracing
213 ///< in sanitizer coverage.
214 CODEGENOPT(SanitizeCoverageTracePCGuard, 1, 0) ///< Enable PC tracing with guard
215 ///< in sanitizer coverage.
216 CODEGENOPT(SanitizeCoverageInline8bitCounters, 1, 0) ///< Use inline 8bit counters.
217 CODEGENOPT(SanitizeCoveragePCTable, 1, 0) ///< Create a PC Table.
218 CODEGENOPT(SanitizeCoverageNoPrune, 1, 0) ///< Disable coverage pruning.
219 CODEGENOPT(SanitizeCoverageStackDepth, 1, 0) ///< Enable max stack depth tracing
220 CODEGENOPT(SanitizeStats , 1, 0) ///< Collect statistics for sanitizers.
221 CODEGENOPT(SimplifyLibCalls , 1, 1) ///< Set when -fbuiltin is enabled.
222 CODEGENOPT(SoftFloat , 1, 0) ///< -soft-float.
223 CODEGENOPT(SpeculativeLoadHardening, 1, 0) ///< Enable speculative load hardening.
224 CODEGENOPT(FineGrainedBitfieldAccesses, 1, 0) ///< Enable fine-grained bitfield accesses.
225 CODEGENOPT(StrictEnums , 1, 0) ///< Optimize based on strict enum definition.
226 CODEGENOPT(StrictVTablePointers, 1, 0) ///< Optimize based on the strict vtable pointers
227 CODEGENOPT(TimePasses , 1, 0) ///< Set when -ftime-report is enabled.
228 CODEGENOPT(TimeTrace , 1, 0) ///< Set when -ftime-trace is enabled.
229 CODEGENOPT(UnrollLoops , 1, 0) ///< Control whether loops are unrolled.
230 CODEGENOPT(RerollLoops , 1, 0) ///< Control whether loops are rerolled.
231 CODEGENOPT(NoUseJumpTables , 1, 0) ///< Set when -fno-jump-tables is enabled.
232 CODEGENOPT(UnsafeFPMath , 1, 0) ///< Allow unsafe floating point optzns.
233 CODEGENOPT(UnwindTables , 1, 0) ///< Emit unwind tables.
234 CODEGENOPT(VectorizeLoop , 1, 0) ///< Run loop vectorizer.
235 CODEGENOPT(VectorizeSLP , 1, 0) ///< Run SLP vectorizer.
236 CODEGENOPT(ProfileSampleAccurate, 1, 0) ///< Sample profile is accurate.
238 /// Attempt to use register sized accesses to bit-fields in structures, when
240 CODEGENOPT(UseRegisterSizedBitfieldAccess , 1, 0)
242 CODEGENOPT(VerifyModule , 1, 1) ///< Control whether the module should be run
243 ///< through the LLVM Verifier.
245 CODEGENOPT(StackRealignment , 1, 0) ///< Control whether to force stack
247 CODEGENOPT(UseInitArray , 1, 0) ///< Control whether to use .init_array or
249 VALUE_CODEGENOPT(StackAlignment , 32, 0) ///< Overrides default stack
250 ///< alignment, if not 0.
251 VALUE_CODEGENOPT(StackProbeSize , 32, 4096) ///< Overrides default stack
252 ///< probe size, even if 0.
253 CODEGENOPT(NoStackArgProbe, 1, 0) ///< Set when -mno-stack-arg-probe is used
254 CODEGENOPT(DebugColumnInfo, 1, 0) ///< Whether or not to use column information
257 CODEGENOPT(DebugTypeExtRefs, 1, 0) ///< Whether or not debug info should contain
258 ///< external references to a PCH or module.
260 CODEGENOPT(DebugExplicitImport, 1, 0) ///< Whether or not debug info should
261 ///< contain explicit imports for
262 ///< anonymous namespaces
264 CODEGENOPT(SplitDwarfInlining, 1, 1) ///< Whether to include inlining info in the
265 ///< skeleton CU to allow for symbolication
266 ///< of inline stack frames without .dwo files.
267 CODEGENOPT(DebugFwdTemplateParams, 1, 0) ///< Whether to emit complete
268 ///< template parameter descriptions in
269 ///< forward declarations (versus just
270 ///< including them in the name).
272 CODEGENOPT(EmitLLVMUseLists, 1, 0) ///< Control whether to serialize use-lists.
274 CODEGENOPT(WholeProgramVTables, 1, 0) ///< Whether to apply whole-program
275 /// vtable optimization.
277 /// Whether to use public LTO visibility for entities in std and stdext
278 /// namespaces. This is enabled by clang-cl's /MT and /MTd flags.
279 CODEGENOPT(LTOVisibilityPublicStd, 1, 0)
281 /// The user specified number of registers to be used for integral arguments,
282 /// or 0 if unspecified.
283 VALUE_CODEGENOPT(NumRegisterParameters, 32, 0)
285 /// The lower bound for a buffer to be considered for stack protection.
286 VALUE_CODEGENOPT(SSPBufferSize, 32, 0)
288 /// The kind of generated debug info.
289 ENUM_CODEGENOPT(DebugInfo, codegenoptions::DebugInfoKind, 3, codegenoptions::NoDebugInfo)
291 /// Whether to generate macro debug info.
292 CODEGENOPT(MacroDebugInfo, 1, 0)
294 /// Tune the debug info for this debugger.
295 ENUM_CODEGENOPT(DebuggerTuning, llvm::DebuggerKind, 2,
296 llvm::DebuggerKind::Default)
298 /// Dwarf version. Version zero indicates to LLVM that no DWARF should be
300 VALUE_CODEGENOPT(DwarfVersion, 3, 0)
302 /// Whether we should emit CodeView debug information. It's possible to emit
303 /// CodeView and DWARF into the same object.
304 CODEGENOPT(EmitCodeView, 1, 0)
306 /// Whether to emit the .debug$H section containing hashes of CodeView types.
307 CODEGENOPT(CodeViewGHash, 1, 0)
309 /// The kind of inlining to perform.
310 ENUM_CODEGENOPT(Inlining, InliningMethod, 2, NormalInlining)
312 // Vector functions library to use.
313 ENUM_CODEGENOPT(VecLib, VectorLibrary, 2, NoLibrary)
315 /// The default TLS model to use.
316 ENUM_CODEGENOPT(DefaultTLSModel, TLSModel, 2, GeneralDynamicTLSModel)
318 /// Number of path components to strip when emitting checks. (0 == full
320 VALUE_CODEGENOPT(EmitCheckPathComponentsToStrip, 32, 0)
322 /// Whether to report the hotness of the code region for optimization remarks.
323 CODEGENOPT(DiagnosticsWithHotness, 1, 0)
325 /// The minimum hotness value a diagnostic needs in order to be included in
326 /// optimization diagnostics.
327 VALUE_CODEGENOPT(DiagnosticsHotnessThreshold, 32, 0)
329 /// Whether copy relocations support is available when building as PIE.
330 CODEGENOPT(PIECopyRelocations, 1, 0)
332 /// Whether we should use the undefined behaviour optimization for control flow
333 /// paths that reach the end of a function without executing a required return.
334 CODEGENOPT(StrictReturn, 1, 1)
336 /// Whether emit extra debug info for sample pgo profile collection.
337 CODEGENOPT(DebugInfoForProfiling, 1, 0)
339 /// Whether 3-component vector type is preserved.
340 CODEGENOPT(PreserveVec3Type, 1, 0)
342 /// Whether to emit .debug_gnu_pubnames section instead of .debug_pubnames.
343 CODEGENOPT(DebugNameTable, 2, 0)
345 /// Whether to use DWARF base address specifiers in .debug_ranges.
346 CODEGENOPT(DebugRangesBaseAddress, 1, 0)
348 CODEGENOPT(NoPLT, 1, 0)
350 /// Whether to embed source in DWARF debug line section.
351 CODEGENOPT(EmbedSource, 1, 0)
353 /// Whether to emit all vtables
354 CODEGENOPT(ForceEmitVTables, 1, 0)
356 /// Whether to emit an address-significance table into the object file.
357 CODEGENOPT(Addrsig, 1, 0)
359 ENUM_CODEGENOPT(SignReturnAddress, SignReturnAddressScope, 2, None)
360 ENUM_CODEGENOPT(SignReturnAddressKey, SignReturnAddressKeyValue, 1, AKey)
361 CODEGENOPT(BranchTargetEnforcement, 1, 0)
363 /// Whether to emit unused static constants.
364 CODEGENOPT(KeepStaticConsts, 1, 0)
367 #undef ENUM_CODEGENOPT
368 #undef VALUE_CODEGENOPT