clang 24.0.0git
CodeGenOptions.h
Go to the documentation of this file.
1//===--- CodeGenOptions.h ---------------------------------------*- C++ -*-===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines the CodeGenOptions interface.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CLANG_BASIC_CODEGENOPTIONS_H
14#define LLVM_CLANG_BASIC_CODEGENOPTIONS_H
15
20#include "llvm/ADT/FloatingPointMode.h"
21#include "llvm/Frontend/Debug/Options.h"
22#include "llvm/Frontend/Driver/CodeGenOptions.h"
23#include "llvm/MC/MCTargetOptions.h"
24#include "llvm/Support/CodeGen.h"
25#include "llvm/Support/Regex.h"
26#include "llvm/Target/TargetOptions.h"
27#include "llvm/Transforms/Instrumentation/AddressSanitizerOptions.h"
28#include "llvm/Transforms/Utils/KCFIHash.h"
29#include <map>
30#include <memory>
31#include <string>
32#include <vector>
33
34namespace llvm {
35class PassBuilder;
36}
37namespace clang {
38
39/// A target's ABI policy for whether a class's vtable can be assumed to have
40/// a unique address program-wide. This is the basis for the exact dynamic_cast
41/// optimization (and, where a vtable is not assumed unique, for whether it may
42/// be marked unnamed_addr so the platform can duplicate it).
44 /// Every vtable has a single address program-wide.
46 /// A vtable with strong linkage (e.g., a class with a key function) is
47 /// unique, but a vague-linkage (weak) vtable may be duplicated by the
48 /// platform and so has no unique address.
50};
51
52/// Bitfields of CodeGenOptions, split out from CodeGenOptions to ensure
53/// that this large collection of bitfields is a trivial class type.
55 friend class CompilerInvocation;
57
58public:
59 /// For ASTs produced with different option value, signifies their level of
60 /// compatibility.
61 enum class CompatibilityKind {
62 /// Does affect the construction of the AST in a way that does prevent
63 /// module interoperability.
65 /// Does affect the construction of the AST in a way that doesn't prevent
66 /// interoperability (that is, the value can be different between an
67 /// explicit module and the user of that module).
69 /// Does not affect the construction of the AST in any way (that is, the
70 /// value can be different between an implicit module and the user of that
71 /// module).
73 };
74
76 using ProfileInstrKind = llvm::driver::ProfileInstrKind;
78 llvm::AsanDetectStackUseAfterReturnMode;
79 using AsanDtorKind = llvm::AsanDtorKind;
80 using VectorLibrary = llvm::driver::VectorLibrary;
81 using ZeroCallUsedRegsKind = llvm::ZeroCallUsedRegs::ZeroCallUsedRegsKind;
82 using WinX64EHUnwindMode = llvm::WinX64EHUnwindMode;
83 using ControlFlowGuardMechanism = llvm::ControlFlowGuardMechanism;
84
85 using DebugCompressionType = llvm::DebugCompressionType;
86 using EmitDwarfUnwindType = llvm::EmitDwarfUnwindType;
87 using DebugTemplateNamesKind = llvm::codegenoptions::DebugTemplateNamesKind;
88 using DebugInfoKind = llvm::codegenoptions::DebugInfoKind;
89 using DebuggerKind = llvm::DebuggerKind;
90 using RelocSectionSymType = llvm::RelocSectionSymType;
91
92#define CODEGENOPT(Name, Bits, Default, Compatibility) unsigned Name : Bits;
93#define ENUM_CODEGENOPT(Name, Type, Bits, Default, Compatibility)
94#include "clang/Basic/CodeGenOptions.def"
95
96protected:
97#define CODEGENOPT(Name, Bits, Default, Compatibility)
98#define ENUM_CODEGENOPT(Name, Type, Bits, Default, Compatibility) \
99 unsigned Name : Bits;
100#include "clang/Basic/CodeGenOptions.def"
101};
102
103/// CodeGenOptions - Track various options which control how the code
104/// is optimized and passed to the backend.
106public:
108 NormalInlining, // Use the standard function inlining pass.
109 OnlyHintInlining, // Inline only (implicitly) hinted functions.
110 OnlyAlwaysInlining // Only run the always inlining pass.
111 };
112
118
125
127 SRCK_Default, // No special option was passed.
128 SRCK_OnStack, // Small structs on the stack (-fpcc-struct-return).
129 SRCK_InRegs // Small structs in registers (-freg-struct-return).
130 };
131
133 Embed_Off, // No embedded bitcode.
134 Embed_All, // Embed both bitcode and commandline in the output.
135 Embed_Bitcode, // Embed just the bitcode in the output.
136 Embed_Marker // Embed a marker as a placeholder for bitcode.
137 };
138
144
150
155
162
163 // This field stores one of the allowed values for the option
164 // -fbasic-block-sections=. The allowed values with this option are:
165 // {"all", "list=<file>", "none"}.
166 //
167 // "all" : Generate basic block sections for all basic blocks.
168 // "list=<file>": Generate basic block sections for a subset of basic blocks.
169 // The functions and the machine basic block ids are specified
170 // in the file.
171 // "none": Disable sections for basic blocks.
172 std::string BBSections;
173
174 // If set, override the default value of MCAsmInfo::BinutilsVersion. If
175 // DisableIntegratedAS is specified, the assembly output will consider GNU as
176 // support. "none" means that all ELF features can be used, regardless of
177 // binutils support.
178 std::string BinutilsVersion;
179
180 enum class FramePointerKind {
181 NonLeafNoReserve, // Keep non-leaf frame pointers, allow the FP to be used
182 // as a GPR in leaf functions.
183 None, // Omit all frame pointers.
184 Reserved, // Maintain valid frame pointer chain.
185 NonLeaf, // Keep non-leaf frame pointers, don't allow the FP to be used as a
186 // GPR in leaf functions.
187 All, // Keep all frame pointers.
188 };
189
191 switch (Kind) {
193 return "none";
195 return "reserved";
197 return "non-leaf-no-reserve";
199 return "non-leaf";
201 return "all";
202 }
203
204 llvm_unreachable("invalid FramePointerKind");
205 }
206
207 /// Possible exception handling behavior.
217
218 /// Translate a clang ExceptionHandlingKind into the corresponding LLVM
219 /// ExceptionHandling model.
220 static llvm::ExceptionHandling
222 switch (Kind) {
224 return llvm::ExceptionHandling::Default;
226 return llvm::ExceptionHandling::None;
228 return llvm::ExceptionHandling::SjLj;
230 return llvm::ExceptionHandling::WinEH;
232 return llvm::ExceptionHandling::DwarfCFI;
234 return llvm::ExceptionHandling::Wasm;
236 return llvm::ExceptionHandling::Emscripten;
237 }
238 llvm_unreachable("invalid ExceptionHandlingKind");
239 }
240
242 Auto, // Choose Swift async extended frame info based on deployment target.
243 Always, // Unconditionally emit Swift async extended frame info.
244 Never, // Don't emit Swift async extended frame info.
246 };
247
249 Language, // Not specified, use language standard.
250 Always, // All loops are assumed to be finite.
251 Never, // No loop is assumed to be finite.
252 };
253
259
261 None, ///< Trap Messages are omitted. This offers the smallest debug info
262 ///< size but at the cost of making traps hard to debug.
263 Basic, ///< Trap Message is fixed per SanitizerKind. Produces smaller debug
264 ///< info than `Detailed` but is not as helpful for debugging.
265 Detailed, ///< Trap Message includes more context (e.g. the expression being
266 ///< overflowed). This is more helpful for debugging but produces
267 ///< larger debug info than `Basic`.
268 };
269
270 enum class BoolFromMem {
271 Strict, ///< In-memory bool values are assumed to be 0 or 1, and any other
272 ///< value is UB.
273 Truncate, ///< Convert in-memory bools to i1 by checking if the least
274 ///< significant bit is 1.
275 NonZero, ///< Convert in-memory bools to i1 by checking if any bit is set
276 ///< to 1.
278 };
279
281 Auto, // Use the target dependent default.
282 ForceEnable, // Always enable regardless of the target default.
283 ForceDisable, // Always disable regardless of the target default.
284 };
285
286 /// The code model to use (-mcmodel).
287 std::string CodeModel;
288
289 /// The code model-specific large data threshold to use
290 /// (-mlarge-data-threshold).
292
293 /// The filename with path we use for coverage data files. The runtime
294 /// allows further manipulation with the GCOV_PREFIX and GCOV_PREFIX_STRIP
295 /// environment variables.
296 std::string CoverageDataFile;
297
298 /// The filename with path we use for coverage notes files.
299 std::string CoverageNotesFile;
300
301 /// Whether to force absolute paths in coverage notes files.
303
304 /// Regexes separated by a semi-colon to filter the files to instrument.
306
307 /// Regexes separated by a semi-colon to filter the files to not instrument.
309
310 /// The version string to put into coverage files.
311 char CoverageVersion[4] = {'0', '0', '0', '0'};
312
313 /// Enable additional debugging information.
314 std::string DebugPass;
315
316 /// The string to embed in debug information as the current working directory.
318
319 /// The string to embed in coverage mapping as the current working directory.
321
322 /// The string to embed in the debug information for the compile unit, if
323 /// non-empty.
324 std::string DwarfDebugFlags;
325
326 /// The string containing the commandline for the llvm.commandline metadata,
327 /// if non-empty.
328 std::string RecordCommandLine;
329
330 /// The string containing the commandline for the dx.source.args metadata,
331 /// if non-empty.
333
334 /// The vector contains parsed commandline for the dx.source.args metadata,
335 /// if parsing was successful.
337
339
340 /// Prefix replacement map for source-based code coverage to remap source
341 /// file paths in coverage mapping.
343
344 /// The ABI to use for passing floating point arguments.
345 std::string FloatABI;
346
347 /// The file to use for dumping bug report by `Debugify` for original
348 /// debug info.
350
351 /// The floating-point denormal mode to use.
352 llvm::DenormalMode FPDenormalMode = llvm::DenormalMode::getIEEE();
353
354 /// The floating-point denormal mode to use, for float.
355 llvm::DenormalMode FP32DenormalMode = llvm::DenormalMode::getIEEE();
356
357 /// The float precision limit to use, if non-empty.
359
361 /// The filename of the bitcode file to link in.
362 std::string Filename;
363 /// If true, we set attributes functions in the bitcode library according to
364 /// our CodeGenOptions, much as we set attrs on functions that we generate
365 /// ourselves.
366 bool PropagateAttrs = false;
367 /// If true, we use LLVM module internalizer.
368 bool Internalize = false;
369 /// Bitwise combination of llvm::Linker::Flags, passed to the LLVM linker.
370 unsigned LinkFlags = 0;
371 };
372
373 /// The files specified here are linked in to the module before optimizations.
374 std::vector<BitcodeFileToLink> LinkBitcodeFiles;
375
376 /// The user provided name for the "main file", if non-empty. This is useful
377 /// in situations where the input file name does not match the original input
378 /// file, for example with -save-temps.
379 std::string MainFileName;
380
381 /// The name for the split debug info file used for the DW_AT_[GNU_]dwo_name
382 /// attribute in the skeleton CU.
383 std::string SplitDwarfFile;
384
385 /// Output filename for the split debug info, not used in the skeleton CU.
386 std::string SplitDwarfOutput;
387
388 /// Output filename used in the COFF debug information.
390
391 /// The name of the relocation model to use.
392 llvm::Reloc::Model RelocationModel;
393
394 /// If not an empty string, trap intrinsics are lowered to calls to this
395 /// function instead of to trap instructions.
396 std::string TrapFuncName;
397
398 /// A list of dependent libraries.
399 std::vector<std::string> DependentLibraries;
400
401 /// A list of linker options to embed in the object file.
402 std::vector<std::string> LinkerOptions;
403
404 /// Name of the profile file to use as output for -fprofile-instr-generate,
405 /// -fprofile-generate, and -fcs-profile-generate.
407
408 /// Name of the patchable function entry section with
409 /// -fpatchable-function-entry.
411
412 /// Name of the profile file to use with -fprofile-sample-use.
413 std::string SampleProfileFile;
414
415 /// Name of the profile file to use as output for with -fmemory-profile.
417
418 /// Name of the profile file to use as input for -fmemory-profile-use.
420
421 /// Name of the profile file to use as input for -fprofile-instr-use
423
424 /// Name of the profile remapping file to apply to the profile data supplied
425 /// by -fprofile-sample-use or -fprofile-instr-use.
427
428 /// Name of the function summary index file to use for ThinLTO function
429 /// importing.
430 std::string ThinLTOIndexFile;
431
432 /// Name of a file that can optionally be written with minimized bitcode
433 /// to be used as input for the ThinLTO thin link step, which only needs
434 /// the summary and module symbol table (and not, e.g. any debug metadata).
436
437 /// Prefix to use for -save-temps output.
439
440 /// Prefix to use for -save-dynamic-debugging-temps output.
442
443 /// Name of file passed with -foffload-include-binary option to forward to
444 /// offloading runtime back-end for incorporating them into host-side object
445 /// file.
447
448 /// List of filenames passed in using the -fembed-offload-object option. These
449 /// are offloading binaries containing device images and metadata.
450 std::vector<std::string> OffloadObjects;
451
452 /// The name of the file to which the backend should save YAML optimization
453 /// records.
454 std::string OptRecordFile;
455
456 /// The regex that filters the passes that should be saved to the optimization
457 /// records.
458 std::string OptRecordPasses;
459
460 /// The format used for serializing remarks (default: YAML)
461 std::string OptRecordFormat;
462
463 /// The name of the partition that symbols are assigned to, specified with
464 /// -fsymbol-partition (see https://lld.llvm.org/Partitions.html).
465 std::string SymbolPartition;
466
467 /// If non-empty, allow the compiler to assume that the given source file
468 /// identifier is unique at link time.
470
472 RK_Missing, // Remark argument not present on the command line.
473 RK_Enabled, // Remark enabled via '-Rgroup'.
474 RK_EnabledEverything, // Remark enabled via '-Reverything'.
475 RK_Disabled, // Remark disabled via '-Rno-group'.
476 RK_DisabledEverything, // Remark disabled via '-Rno-everything'.
477 RK_WithPattern, // Remark pattern specified via '-Rgroup=regexp'.
478 };
479
480 /// Optimization remark with an optional regular expression pattern.
481 struct OptRemark {
483 std::string Pattern;
484 std::shared_ptr<llvm::Regex> Regex;
485
486 /// By default, optimization remark is missing.
487 OptRemark() = default;
488
489 /// Returns true iff the optimization remark holds a valid regular
490 /// expression.
491 bool hasValidPattern() const { return Regex != nullptr; }
492
493 /// Matches the given string against the regex, if there is some.
494 bool patternMatches(StringRef String) const {
495 return hasValidPattern() && Regex->match(String);
496 }
497 };
498
499 /// Selected optimizations for which we should enable optimization remarks.
500 /// Transformation passes whose name matches the contained (optional) regular
501 /// expression (and support this feature), will emit a diagnostic whenever
502 /// they perform a transformation.
504
505 /// Selected optimizations for which we should enable missed optimization
506 /// remarks. Transformation passes whose name matches the contained (optional)
507 /// regular expression (and support this feature), will emit a diagnostic
508 /// whenever they tried but failed to perform a transformation.
510
511 /// Selected optimizations for which we should enable optimization analyses.
512 /// Transformation passes whose name matches the contained (optional) regular
513 /// expression (and support this feature), will emit a diagnostic whenever
514 /// they want to explain why they decided to apply or not apply a given
515 /// transformation.
517
518 /// Set of sanitizer checks that are non-fatal (i.e. execution should be
519 /// continued when possible).
521
522 /// Set of sanitizer checks that trap rather than diagnose.
524
525 /// Set of sanitizer checks that can merge handlers (smaller code size at
526 /// the expense of debuggability).
528
529 /// Set of thresholds in a range [0.0, 1.0]: the top hottest code responsible
530 /// for the given fraction of PGO counters will be excluded from sanitization
531 /// (0.0 [default] to skip none, 1.0 to skip all).
533
534 /// Set of sanitizer checks, for which the instrumentation will be annotated
535 /// with extra debug info.
537
538 std::optional<double> AllowRuntimeCheckSkipHotCutoff;
539
540 /// List of backend command-line options for -fembed-bitcode.
541 std::vector<uint8_t> CmdArgs;
542
543 /// A list of all -fno-builtin-* function names (e.g., memset).
544 std::vector<std::string> NoBuiltinFuncs;
545
546 std::vector<std::string> Reciprocals;
547
548 /// Configuration for pointer-signing.
550
551 /// The preferred width for auto-vectorization transforms. This is intended to
552 /// override default transforms based on the width of the architected vector
553 /// registers.
554 std::string PreferVectorWidth;
555
556 /// Set of XRay instrumentation kinds to emit.
558
559 std::vector<std::string> DefaultFunctionAttrs;
560
561 /// List of dynamic shared object files to be loaded as pass plugins.
562 std::vector<std::string> PassPlugins;
563
564 /// List of pass builder callbacks.
565 std::vector<std::function<void(llvm::PassBuilder &)>> PassBuilderCallbacks;
566
567 /// List of global variables explicitly specified by the user as toc-data.
568 std::vector<std::string> TocDataVarsUserSpecified;
569
570 /// List of global variables that over-ride the toc-data default.
571 std::vector<std::string> NoTocDataVars;
572
573 /// Path to allowlist file specifying which objects
574 /// (files, functions) should exclusively be instrumented
575 /// by sanitizer coverage pass.
576 std::vector<std::string> SanitizeCoverageAllowlistFiles;
577
578 /// The guard style used for stack protector to get a initial value, this
579 /// value usually be gotten from TLS or get from __stack_chk_guard, or some
580 /// other styles we may implement in the future.
582
583 /// The TLS base register when StackProtectorGuard is "tls", or register used
584 /// to store the stack canary for "sysreg".
585 /// On x86 this can be "fs" or "gs".
586 /// On AArch64 this can only be "sp_el0".
588
589 /// Specify a symbol to be the guard value.
591
592 /// Path to ignorelist file specifying which objects
593 /// (files, functions) listed for instrumentation by sanitizer
594 /// coverage pass should actually not be instrumented.
595 std::vector<std::string> SanitizeCoverageIgnorelistFiles;
596
597 /// Path to ignorelist file specifying which objects
598 /// (files, functions) listed for instrumentation by sanitizer
599 /// binary metadata pass should not be instrumented.
600 std::vector<std::string> SanitizeMetadataIgnorelistFiles;
601
602 /// Hash algorithm to use for KCFI type IDs.
603 llvm::KCFIHashAlgorithm SanitizeKcfiHash;
604
605 /// Name of the stack usage file (i.e., .su file) if user passes
606 /// -fstack-usage. If empty, it can be implied that -fstack-usage is not
607 /// passed on the command line.
608 std::string StackUsageFile;
609
610 /// Executable and command-line used to create a given CompilerInvocation.
611 /// Most of the time this will be the full -cc1 command.
612 const char *Argv0 = nullptr;
613 std::vector<std::string> CommandLineArgs;
614
615 /// The minimum hotness value a diagnostic needs in order to be included in
616 /// optimization diagnostics.
617 ///
618 /// The threshold is an Optional value, which maps to one of the 3 states:
619 /// 1. 0 => threshold disabled. All remarks will be printed.
620 /// 2. positive int => manual threshold by user. Remarks with hotness exceed
621 /// threshold will be printed.
622 /// 3. None => 'auto' threshold by user. The actual value is not
623 /// available at command line, but will be synced with
624 /// hotness threshold from profile summary during
625 /// compilation.
626 ///
627 /// If threshold option is not specified, it is disabled by default.
628 std::optional<uint64_t> DiagnosticsHotnessThreshold = 0;
629
630 /// The maximum percentage profiling weights can deviate from the expected
631 /// values in order to be included in misexpect diagnostics.
632 std::optional<uint32_t> DiagnosticsMisExpectTolerance = 0;
633
634 /// The name of a file to use with \c .secure_log_unique directives.
635 std::string AsSecureLogFile;
636
637 /// A list of functions that are replacable by the loader.
638 std::vector<std::string> LoaderReplaceableFunctionNames;
639 /// The name of a file that contains functions which will be compiled for
640 /// hotpatching. See -fms-secure-hotpatch-functions-file.
642
643 /// A list of functions which will be compiled for hotpatching.
644 /// See -fms-secure-hotpatch-functions-list.
645 std::vector<std::string> MSSecureHotPatchFunctionsList;
646
647public:
648 // Define accessors/mutators for code generation options of enumeration type.
649#define CODEGENOPT(Name, Bits, Default, Compatibility)
650#define ENUM_CODEGENOPT(Name, Type, Bits, Default, Compatibility) \
651 Type get##Name() const { return static_cast<Type>(Name); } \
652 void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
653#include "clang/Basic/CodeGenOptions.def"
654
656
657 const std::vector<std::string> &getNoBuiltinFuncs() const {
658 return NoBuiltinFuncs;
659 }
660
661 bool hasSjLjExceptions() const {
662 return getExceptionHandling() == ExceptionHandlingKind::SjLj;
663 }
664
665 bool hasSEHExceptions() const {
666 return getExceptionHandling() == ExceptionHandlingKind::WinEH;
667 }
668
669 bool hasDWARFExceptions() const {
670 return getExceptionHandling() == ExceptionHandlingKind::DwarfCFI;
671 }
672
673 bool hasWasmExceptions() const {
674 return getExceptionHandling() == ExceptionHandlingKind::Wasm;
675 }
676
678 return getExceptionHandling() == ExceptionHandlingKind::Emscripten;
679 }
680
681 /// Check if Clang profile instrumenation is on.
682 bool hasProfileClangInstr() const {
683 return getProfileInstr() ==
684 llvm::driver::ProfileInstrKind::ProfileClangInstr;
685 }
686
687 /// Check if IR level profile instrumentation is on.
688 bool hasProfileIRInstr() const {
689 return getProfileInstr() == llvm::driver::ProfileInstrKind::ProfileIRInstr;
690 }
691
692 /// Check if CS IR level profile instrumentation is on.
693 bool hasProfileCSIRInstr() const {
694 return getProfileInstr() ==
695 llvm::driver::ProfileInstrKind::ProfileCSIRInstr;
696 }
697
698 /// Check if any form of instrumentation is on.
699 bool hasProfileInstr() const {
700 return getProfileInstr() != llvm::driver::ProfileInstrKind::ProfileNone;
701 }
702
703 /// Check if Clang profile use is on.
704 bool hasProfileClangUse() const {
705 return getProfileUse() == llvm::driver::ProfileInstrKind::ProfileClangInstr;
706 }
707
708 /// Check if IR level profile use is on.
709 bool hasProfileIRUse() const {
710 return getProfileUse() == llvm::driver::ProfileInstrKind::ProfileIRInstr ||
711 getProfileUse() == llvm::driver::ProfileInstrKind::ProfileCSIRInstr;
712 }
713
714 /// Check if CSIR profile use is on.
715 bool hasProfileCSIRUse() const {
716 return getProfileUse() == llvm::driver::ProfileInstrKind::ProfileCSIRInstr;
717 }
718
719 /// Check if type and variable info should be emitted.
720 bool hasReducedDebugInfo() const {
721 return getDebugInfo() >= llvm::codegenoptions::DebugInfoConstructor;
722 }
723
724 /// Check if maybe unused type info should be emitted.
726 return getDebugInfo() >= llvm::codegenoptions::UnusedTypeInfo;
727 }
728
729 // Check if any one of SanitizeCoverage* is enabled.
730 bool hasSanitizeCoverage() const {
731 return SanitizeCoverageType || SanitizeCoverageIndirectCalls ||
732 SanitizeCoverageTraceCmp || SanitizeCoverageTraceLoads ||
733 SanitizeCoverageTraceStores || SanitizeCoverageControlFlow;
734 }
735
736 // Check if any one of SanitizeBinaryMetadata* is enabled.
738 return SanitizeBinaryMetadataCovered || SanitizeBinaryMetadataAtomics ||
739 SanitizeBinaryMetadataUAR;
740 }
741
742 /// Reset all of the options that are not considered when building a
743 /// module.
744 void resetNonModularOptions(StringRef ModuleFormat);
745
746 // Is the given function name one of the functions that can be replaced by the
747 // loader?
748 bool isLoaderReplaceableFunctionName(StringRef FuncName) const {
749 return llvm::is_contained(LoaderReplaceableFunctionNames, FuncName);
750 }
751
752 /// Are we building at -O1 or higher?
753 bool isOptimizedBuild() const { return OptimizationLevel > 0; }
754
755 /// When loading a bool from a storage unit larger than i1, should it
756 /// be converted to i1 by comparing to 0 or by truncating to i1?
758 switch (getLoadBoolFromMem()) {
760 return !isOptimizedBuild();
761
763 return false;
764
766 return true;
767 }
768 llvm_unreachable("Unknown BoolFromMem enum");
769 }
770
771 /// Remap specified path prefix using provided DebugPrefixMap map.
772 /// Returns updated path or unchanged if no substitution was found.
773 std::string remapDebugPathPrefix(StringRef Path) const;
774};
775
776} // end namespace clang
777
778#endif
Defines the clang::SanitizerKind enum.
Defines the clang::XRayInstrKind enum.
Bitfields of CodeGenOptions, split out from CodeGenOptions to ensure that this large collection of bi...
llvm::driver::ProfileInstrKind ProfileInstrKind
llvm::AsanDtorKind AsanDtorKind
llvm::WinX64EHUnwindMode WinX64EHUnwindMode
llvm::ZeroCallUsedRegs::ZeroCallUsedRegsKind ZeroCallUsedRegsKind
llvm::codegenoptions::DebugInfoKind DebugInfoKind
llvm::DebuggerKind DebuggerKind
llvm::EmitDwarfUnwindType EmitDwarfUnwindType
llvm::AsanDetectStackUseAfterReturnMode AsanDetectStackUseAfterReturnMode
CompatibilityKind
For ASTs produced with different option value, signifies their level of compatibility.
@ NotCompatible
Does affect the construction of the AST in a way that does prevent module interoperability.
@ Compatible
Does affect the construction of the AST in a way that doesn't prevent interoperability (that is,...
@ Benign
Does not affect the construction of the AST in any way (that is, the value can be different between a...
friend class CompilerInvocationBase
llvm::ControlFlowGuardMechanism ControlFlowGuardMechanism
llvm::DebugCompressionType DebugCompressionType
llvm::RelocSectionSymType RelocSectionSymType
llvm::driver::VectorLibrary VectorLibrary
llvm::codegenoptions::DebugTemplateNamesKind DebugTemplateNamesKind
clang::CFBranchLabelSchemeKind CFBranchLabelSchemeKind
llvm::SmallVector< std::pair< std::string, std::string >, 0 > CoveragePrefixMap
Prefix replacement map for source-based code coverage to remap source file paths in coverage mapping.
std::string StackProtectorGuardSymbol
Specify a symbol to be the guard value.
SanitizerSet SanitizeMergeHandlers
Set of sanitizer checks that can merge handlers (smaller code size at the expense of debuggability).
std::string StackUsageFile
Name of the stack usage file (i.e., .su file) if user passes -fstack-usage.
std::string UniqueSourceFileIdentifier
If non-empty, allow the compiler to assume that the given source file identifier is unique at link ti...
std::string MSSecureHotPatchFunctionsFile
The name of a file that contains functions which will be compiled for hotpatching.
const std::vector< std::string > & getNoBuiltinFuncs() const
std::vector< std::string > LoaderReplaceableFunctionNames
A list of functions that are replacable by the loader.
llvm::SmallVector< std::pair< std::string, std::string >, 0 > DebugPrefixMap
@ None
Trap Messages are omitted.
@ Detailed
Trap Message includes more context (e.g.
@ Basic
Trap Message is fixed per SanitizerKind.
std::string OptRecordFile
The name of the file to which the backend should save YAML optimization records.
std::string InstrProfileOutput
Name of the profile file to use as output for -fprofile-instr-generate, -fprofile-generate,...
bool hasEmscriptenExceptions() const
std::string StackProtectorGuard
The guard style used for stack protector to get a initial value, this value usually be gotten from TL...
bool hasDWARFExceptions() const
std::vector< BitcodeFileToLink > LinkBitcodeFiles
The files specified here are linked in to the module before optimizations.
std::string RecordCommandLine
The string containing the commandline for the llvm.commandline metadata, if non-empty.
std::optional< uint64_t > DiagnosticsHotnessThreshold
The minimum hotness value a diagnostic needs in order to be included in optimization diagnostics.
bool hasProfileInstr() const
Check if any form of instrumentation is on.
static llvm::ExceptionHandling toExceptionHandling(ExceptionHandlingKind Kind)
Translate a clang ExceptionHandlingKind into the corresponding LLVM ExceptionHandling model.
bool isConvertingBoolWithCmp0() const
When loading a bool from a storage unit larger than i1, should it be converted to i1 by comparing to ...
bool hasProfileIRUse() const
Check if IR level profile use is on.
char CoverageVersion[4]
The version string to put into coverage files.
std::string FloatABI
The ABI to use for passing floating point arguments.
std::string OffloadBinaryToEmbedFile
Name of file passed with -foffload-include-binary option to forward to offloading runtime back-end fo...
std::string HLSLRecordCommandLine
The string containing the commandline for the dx.source.args metadata, if non-empty.
std::string ThinLinkBitcodeFile
Name of a file that can optionally be written with minimized bitcode to be used as input for the Thin...
bool hasProfileCSIRInstr() const
Check if CS IR level profile instrumentation is on.
std::vector< std::string > DependentLibraries
A list of dependent libraries.
std::string DebugPass
Enable additional debugging information.
llvm::Reloc::Model RelocationModel
The name of the relocation model to use.
llvm::DenormalMode FPDenormalMode
The floating-point denormal mode to use.
std::string CoverageNotesFile
The filename with path we use for coverage notes files.
std::string ProfileInstrumentUsePath
Name of the profile file to use as input for -fprofile-instr-use.
std::string SampleProfileFile
Name of the profile file to use with -fprofile-sample-use.
uint64_t LargeDataThreshold
The code model-specific large data threshold to use (-mlarge-data-threshold).
static StringRef getFramePointerKindName(FramePointerKind Kind)
std::string MemoryProfileOutput
Name of the profile file to use as output for with -fmemory-profile.
std::vector< std::function< void(llvm::PassBuilder &)> > PassBuilderCallbacks
List of pass builder callbacks.
std::string LimitFloatPrecision
The float precision limit to use, if non-empty.
std::string CodeModel
The code model to use (-mcmodel).
std::vector< std::string > TocDataVarsUserSpecified
List of global variables explicitly specified by the user as toc-data.
std::string CoverageDataFile
The filename with path we use for coverage data files.
std::vector< std::string > PassPlugins
List of dynamic shared object files to be loaded as pass plugins.
bool hasProfileClangInstr() const
Check if Clang profile instrumenation is on.
std::string DebugCompilationDir
The string to embed in debug information as the current working directory.
std::optional< uint32_t > DiagnosticsMisExpectTolerance
The maximum percentage profiling weights can deviate from the expected values in order to be included...
std::string OptRecordPasses
The regex that filters the passes that should be saved to the optimization records.
std::vector< std::string > SanitizeCoverageAllowlistFiles
Path to allowlist file specifying which objects (files, functions) should exclusively be instrumented...
std::string SaveTempsFilePrefix
Prefix to use for -save-temps output.
std::string PatchableFunctionEntrySection
Name of the patchable function entry section with -fpatchable-function-entry.
XRayInstrSet XRayInstrumentationBundle
Set of XRay instrumentation kinds to emit.
std::vector< std::string > SanitizeCoverageIgnorelistFiles
Path to ignorelist file specifying which objects (files, functions) listed for instrumentation by san...
bool hasSanitizeCoverage() const
std::vector< std::string > Reciprocals
std::string MainFileName
The user provided name for the "main file", if non-empty.
SanitizerSet SanitizeAnnotateDebugInfo
Set of sanitizer checks, for which the instrumentation will be annotated with extra debug info.
PointerAuthOptions PointerAuth
Configuration for pointer-signing.
llvm::DenormalMode FP32DenormalMode
The floating-point denormal mode to use, for float.
bool hasProfileIRInstr() const
Check if IR level profile instrumentation is on.
bool hasProfileCSIRUse() const
Check if CSIR profile use is on.
std::string CoverageCompilationDir
The string to embed in coverage mapping as the current working directory.
SanitizerSet SanitizeTrap
Set of sanitizer checks that trap rather than diagnose.
std::vector< std::string > SanitizeMetadataIgnorelistFiles
Path to ignorelist file specifying which objects (files, functions) listed for instrumentation by san...
SanitizerSet SanitizeRecover
Set of sanitizer checks that are non-fatal (i.e.
std::string ProfileExcludeFiles
Regexes separated by a semi-colon to filter the files to not instrument.
std::string AsSecureLogFile
The name of a file to use with .secure_log_unique directives.
std::string ProfileRemappingFile
Name of the profile remapping file to apply to the profile data supplied by -fprofile-sample-use or -...
bool hasReducedDebugInfo() const
Check if type and variable info should be emitted.
bool hasSanitizeBinaryMetadata() const
OptRemark OptimizationRemark
Selected optimizations for which we should enable optimization remarks.
llvm::KCFIHashAlgorithm SanitizeKcfiHash
Hash algorithm to use for KCFI type IDs.
std::string ThinLTOIndexFile
Name of the function summary index file to use for ThinLTO function importing.
const char * Argv0
Executable and command-line used to create a given CompilerInvocation.
bool hasWasmExceptions() const
llvm::SmallVector< llvm::SmallString< 8 > > HLSLParsedCommandLine
The vector contains parsed commandline for the dx.source.args metadata, if parsing was successful.
bool hasSjLjExceptions() const
std::string TrapFuncName
If not an empty string, trap intrinsics are lowered to calls to this function instead of to trap inst...
std::string remapDebugPathPrefix(StringRef Path) const
Remap specified path prefix using provided DebugPrefixMap map.
SanitizerMaskCutoffs SanitizeSkipHotCutoffs
Set of thresholds in a range [0.0, 1.0]: the top hottest code responsible for the given fraction of P...
std::string SplitDwarfFile
The name for the split debug info file used for the DW_AT_[GNU_]dwo_name attribute in the skeleton CU...
std::string StackProtectorGuardReg
The TLS base register when StackProtectorGuard is "tls", or register used to store the stack canary f...
std::vector< std::string > DefaultFunctionAttrs
std::vector< std::string > NoBuiltinFuncs
A list of all -fno-builtin-* function names (e.g., memset).
std::vector< uint8_t > CmdArgs
List of backend command-line options for -fembed-bitcode.
OptRemark OptimizationRemarkAnalysis
Selected optimizations for which we should enable optimization analyses.
std::optional< double > AllowRuntimeCheckSkipHotCutoff
std::vector< std::string > CommandLineArgs
std::vector< std::string > LinkerOptions
A list of linker options to embed in the object file.
bool hasSEHExceptions() const
std::string MemoryProfileUsePath
Name of the profile file to use as input for -fmemory-profile-use.
std::vector< std::string > MSSecureHotPatchFunctionsList
A list of functions which will be compiled for hotpatching.
void resetNonModularOptions(StringRef ModuleFormat)
Reset all of the options that are not considered when building a module.
@ Strict
In-memory bool values are assumed to be 0 or 1, and any other value is UB.
@ NonZero
Convert in-memory bools to i1 by checking if any bit is set to 1.
@ Truncate
Convert in-memory bools to i1 by checking if the least significant bit is 1.
ExceptionHandlingKind
Possible exception handling behavior.
std::string OptRecordFormat
The format used for serializing remarks (default: YAML)
bool hasProfileClangUse() const
Check if Clang profile use is on.
bool UseAbsolutePathsInNotesFile
Whether to force absolute paths in coverage notes files.
bool isOptimizedBuild() const
Are we building at -O1 or higher?
std::vector< std::string > OffloadObjects
List of filenames passed in using the -fembed-offload-object option.
std::string SymbolPartition
The name of the partition that symbols are assigned to, specified with -fsymbol-partition (see https:...
std::vector< std::string > NoTocDataVars
List of global variables that over-ride the toc-data default.
std::string ProfileFilterFiles
Regexes separated by a semi-colon to filter the files to instrument.
bool hasMaybeUnusedDebugInfo() const
Check if maybe unused type info should be emitted.
std::string PreferVectorWidth
The preferred width for auto-vectorization transforms.
std::string ObjectFilenameForDebug
Output filename used in the COFF debug information.
std::string SplitDwarfOutput
Output filename for the split debug info, not used in the skeleton CU.
bool isLoaderReplaceableFunctionName(StringRef FuncName) const
std::string DwarfDebugFlags
The string to embed in the debug information for the compile unit, if non-empty.
std::string DIBugsReportFilePath
The file to use for dumping bug report by Debugify for original debug info.
OptRemark OptimizationRemarkMissed
Selected optimizations for which we should enable missed optimization remarks.
std::string SaveDynDbgTempsFilePrefix
Prefix to use for -save-dynamic-debugging-temps output.
Top level wrappers for InstallAPI frontend operations.
VTableUniquenessKind
A target's ABI policy for whether a class's vtable can be assumed to have a unique address program-wi...
@ AlwaysUnique
Every vtable has a single address program-wide.
@ UniqueIfStrongLinkage
A vtable with strong linkage (e.g., a class with a key function) is unique, but a vague-linkage (weak...
Diagnostic wrappers for TextAPI types for error reporting.
Definition Dominators.h:30
int const char * function
Definition c++config.h:31
Optimization remark with an optional regular expression pattern.
std::shared_ptr< llvm::Regex > Regex
bool patternMatches(StringRef String) const
Matches the given string against the regex, if there is some.
OptRemark()=default
By default, optimization remark is missing.
bool hasValidPattern() const
Returns true iff the optimization remark holds a valid regular expression.