Author: Jan Svoboda
Date: 2025-07-07T09:02:56-07:00
New Revision: 9f1b9560e7ee542471c89b193c6aea4c674ffe23

URL: 
https://github.com/llvm/llvm-project/commit/9f1b9560e7ee542471c89b193c6aea4c674ffe23
DIFF: 
https://github.com/llvm/llvm-project/commit/9f1b9560e7ee542471c89b193c6aea4c674ffe23.diff

LOG: [clang] Refactor `CodeGenOptions` to specify compatibility as X macro arg 
(#146910)

This is the `CodeGenOptions` counterpart to
https://github.com/llvm/llvm-project/pull/146766.

Added: 
    

Modified: 
    clang/include/clang/Basic/CodeGenOptions.def
    clang/include/clang/Basic/CodeGenOptions.h
    clang/include/clang/Basic/DebugOptions.def
    clang/lib/Basic/CodeGenOptions.cpp
    clang/lib/Frontend/CompilerInvocation.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index e5566a540dc65..41031026c99f6 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -12,481 +12,473 @@
 // that have enumeration type and VALUE_CODEGENOPT is a code
 // generation option that describes a value rather than a flag.
 //
-// AFFECTING_VALUE_CODEGENOPT is used for code generation options that can
-// affect the AST.
-//
 
//===----------------------------------------------------------------------===//
 #ifndef CODEGENOPT
-#  error Define the CODEGENOPT macro to handle language options
+#  error Define the CODEGENOPT macro to handle codegen options
 #endif
 
 #ifndef VALUE_CODEGENOPT
-#  define VALUE_CODEGENOPT(Name, Bits, Default) \
-CODEGENOPT(Name, Bits, Default)
+#  define VALUE_CODEGENOPT(Name, Bits, Default, Compatibility) \
+CODEGENOPT(Name, Bits, Default, Compatibility)
 #endif
 
 #ifndef ENUM_CODEGENOPT
-#  define ENUM_CODEGENOPT(Name, Type, Bits, Default) \
-CODEGENOPT(Name, Bits, Default)
-#endif
-
-#ifndef AFFECTING_VALUE_CODEGENOPT
-#  define AFFECTING_VALUE_CODEGENOPT(Name, Bits, Default) \
-VALUE_CODEGENOPT(Name, Bits, Default)
+#  define ENUM_CODEGENOPT(Name, Type, Bits, Default, Compatibility) \
+CODEGENOPT(Name, Bits, Default, Compatibility)
 #endif
 
-CODEGENOPT(DisableIntegratedAS, 1, 0) ///< -no-integrated-as
-CODEGENOPT(Crel, 1, 0) ///< -Wa,--crel
-CODEGENOPT(ImplicitMapSyms, 1, 0) ///< -Wa,-mmapsyms=implicit
-CODEGENOPT(AsmVerbose        , 1, 0) ///< -dA, -fverbose-asm.
-CODEGENOPT(PreserveAsmComments, 1, 1) ///< -dA, -fno-preserve-as-comments.
-CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit __attribute__((malloc)) 
operator new
-CODEGENOPT(AssumeUniqueVTables , 1, 1) ///< Assume a class has only one vtable.
-CODEGENOPT(Autolink          , 1, 1) ///< -fno-autolink
-CODEGENOPT(AutoImport        , 1, 1) ///< -fno-auto-import
-CODEGENOPT(ObjCAutoRefCountExceptions , 1, 0) ///< Whether ARC should be 
EH-safe.
-CODEGENOPT(Backchain         , 1, 0) ///< -mbackchain
-CODEGENOPT(ControlFlowGuardNoChecks  , 1, 0) ///< -cfguard-no-checks
-CODEGENOPT(ControlFlowGuard  , 1, 0) ///< -cfguard
-CODEGENOPT(EHContGuard       , 1, 0) ///< -ehcontguard
-CODEGENOPT(CXAAtExit         , 1, 1) ///< Use __cxa_atexit for calling 
destructors.
-CODEGENOPT(RegisterGlobalDtorsWithAtExit, 1, 1) ///< Use atexit or 
__cxa_atexit to register global destructors.
-CODEGENOPT(CXXCtorDtorAliases, 1, 0) ///< Emit complete ctors/dtors as linker
+CODEGENOPT(DisableIntegratedAS, 1, 0, Benign) ///< -no-integrated-as
+CODEGENOPT(Crel, 1, 0, Benign) ///< -Wa,--crel
+CODEGENOPT(ImplicitMapSyms, 1, 0, Benign) ///< -Wa,-mmapsyms=implicit
+CODEGENOPT(AsmVerbose        , 1, 0, Benign) ///< -dA, -fverbose-asm.
+CODEGENOPT(PreserveAsmComments, 1, 1, Benign) ///< -dA, 
-fno-preserve-as-comments.
+CODEGENOPT(AssumeSaneOperatorNew , 1, 1, Benign) ///< implicit 
__attribute__((malloc)) operator new
+CODEGENOPT(AssumeUniqueVTables , 1, 1, Benign) ///< Assume a class has only 
one vtable.
+CODEGENOPT(Autolink          , 1, 1, Benign) ///< -fno-autolink
+CODEGENOPT(AutoImport        , 1, 1, Benign) ///< -fno-auto-import
+CODEGENOPT(ObjCAutoRefCountExceptions , 1, 0, Benign) ///< Whether ARC should 
be EH-safe.
+CODEGENOPT(Backchain         , 1, 0, Benign) ///< -mbackchain
+CODEGENOPT(ControlFlowGuardNoChecks  , 1, 0, Benign) ///< -cfguard-no-checks
+CODEGENOPT(ControlFlowGuard  , 1, 0, Benign) ///< -cfguard
+CODEGENOPT(EHContGuard       , 1, 0, Benign) ///< -ehcontguard
+CODEGENOPT(CXAAtExit         , 1, 1, Benign) ///< Use __cxa_atexit for calling 
destructors.
+CODEGENOPT(RegisterGlobalDtorsWithAtExit, 1, 1, Benign) ///< Use atexit or 
__cxa_atexit to register global destructors.
+CODEGENOPT(CXXCtorDtorAliases, 1, 0, Benign) ///< Emit complete ctors/dtors as 
linker
                                      ///< aliases to base ctors when possible.
-CODEGENOPT(DataSections      , 1, 0) ///< Set when -fdata-sections is enabled.
-CODEGENOPT(UniqueSectionNames, 1, 1) ///< Set for -funique-section-names.
-CODEGENOPT(UniqueBasicBlockSectionNames, 1, 1) ///< Set for 
-funique-basic-block-section-names,
+CODEGENOPT(DataSections      , 1, 0, Benign) ///< Set when -fdata-sections is 
enabled.
+CODEGENOPT(UniqueSectionNames, 1, 1, Benign) ///< Set for 
-funique-section-names.
+CODEGENOPT(UniqueBasicBlockSectionNames, 1, 1, Benign) ///< Set for 
-funique-basic-block-section-names,
                                                ///< Produce unique section 
names with
                                                ///< basic block sections.
-CODEGENOPT(SeparateNamedSections, 1, 0) ///< Set for -fseparate-named-sections.
-CODEGENOPT(EnableAIXExtendedAltivecABI, 1, 0) ///< Set for -mabi=vec-extabi. 
Enables the extended Altivec ABI on AIX.
-CODEGENOPT(XCOFFReadOnlyPointers, 1, 0) ///< Set for -mxcoff-roptr.
-CODEGENOPT(AllTocData, 1, 0) ///< AIX -mtocdata
-ENUM_CODEGENOPT(FramePointer, FramePointerKind, 2, FramePointerKind::None) /// 
frame-pointer: all,non-leaf,reserved,none
-
-CODEGENOPT(ClearASTBeforeBackend , 1, 0) ///< Free the AST before running 
backend code generation. Only works with -disable-free.
-CODEGENOPT(DisableFree       , 1, 0) ///< Don't free memory.
-CODEGENOPT(DiscardValueNames , 1, 0) ///< Discard Value Names from the IR 
(LLVMContext flag)
-CODEGENOPT(DisableLLVMPasses , 1, 0) ///< Don't run any LLVM IR passes to get
-                                     ///< the pristine IR generated by the
-                                     ///< frontend.
-CODEGENOPT(DisableLifetimeMarkers, 1, 0) ///< Don't emit any lifetime markers
-CODEGENOPT(DisableO0ImplyOptNone , 1, 0) ///< Don't annonate function with 
optnone at O0
-CODEGENOPT(ExperimentalStrictFloatingPoint, 1, 0) ///< Enables the new, 
experimental
-                                                  ///< strict floating point.
-CODEGENOPT(EnableNoundefAttrs, 1, 0) ///< Enable emitting `noundef` attributes 
on IR call arguments and return values
-CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug information for the new
-                                   ///< pass manager.
-CODEGENOPT(DisableRedZone    , 1, 0) ///< Set when -mno-red-zone is enabled.
-CODEGENOPT(EmitCallSiteInfo, 1, 0) ///< Emit call site info only in the case of
-                                   ///< '-g' + 'O>0' level.
-CODEGENOPT(IndirectTlsSegRefs, 1, 0) ///< Set when -mno-tls-direct-seg-refs
-                                     ///< is specified.
-CODEGENOPT(DisableTailCalls  , 1, 0) ///< Do not emit tail calls.
-CODEGENOPT(NoEscapingBlockTailCalls, 1, 0) ///< Do not emit tail calls from
-                                           ///< escaping blocks.
-CODEGENOPT(EmitDeclMetadata  , 1, 0) ///< Emit special metadata indicating what
-                                     ///< Decl* various IR entities came from.
-                                     ///< Only useful when running CodeGen as a
-                                     ///< subroutine.
-CODEGENOPT(EmitVersionIdentMetadata , 1, 1) ///< Emit compiler version 
metadata.
-CODEGENOPT(EmitOpenCLArgMetadata , 1, 0) ///< Emit OpenCL kernel arg metadata.
-CODEGENOPT(EmulatedTLS       , 1, 0) ///< Set by default or 
-f[no-]emulated-tls.
+CODEGENOPT(SeparateNamedSections, 1, 0, Benign) ///< Set for 
-fseparate-named-sections.
+CODEGENOPT(EnableAIXExtendedAltivecABI, 1, 0, Benign) ///< Set for 
-mabi=vec-extabi. Enables the extended Altivec ABI on AIX.
+CODEGENOPT(XCOFFReadOnlyPointers, 1, 0, Benign) ///< Set for -mxcoff-roptr.
+CODEGENOPT(AllTocData, 1, 0, Benign) ///< AIX -mtocdata
+ENUM_CODEGENOPT(FramePointer, FramePointerKind, 2, FramePointerKind::None, 
Benign) /// frame-pointer: all,non-leaf,reserved,none
+
+CODEGENOPT(ClearASTBeforeBackend , 1, 0, Benign) ///< Free the AST before 
running backend code generation. Only works with -disable-free.
+CODEGENOPT(DisableFree       , 1, 0, Benign) ///< Don't free memory.
+CODEGENOPT(DiscardValueNames , 1, 0, Benign) ///< Discard Value Names from the 
IR (LLVMContext flag)
+CODEGENOPT(DisableLLVMPasses , 1, 0, Benign) ///< Don't run any LLVM IR passes 
to get
+                                             ///< the pristine IR generated by 
the
+                                             ///< frontend.
+CODEGENOPT(DisableLifetimeMarkers, 1, 0, Benign) ///< Don't emit any lifetime 
markers
+CODEGENOPT(DisableO0ImplyOptNone , 1, 0, Benign) ///< Don't annonate function 
with optnone at O0
+CODEGENOPT(ExperimentalStrictFloatingPoint, 1, 0, Benign) ///< Enables the 
new, experimental
+                                                          ///< strict floating 
point.
+CODEGENOPT(EnableNoundefAttrs, 1, 0, Benign) ///< Enable emitting `noundef` 
attributes on IR call arguments and return values
+CODEGENOPT(DebugPassManager, 1, 0, Benign) ///< Prints debug information for 
the new
+                                           ///< pass manager.
+CODEGENOPT(DisableRedZone    , 1, 0, Benign) ///< Set when -mno-red-zone is 
enabled.
+CODEGENOPT(EmitCallSiteInfo, 1, 0, Benign) ///< Emit call site info only in 
the case of
+                                           ///< '-g' + 'O>0' level.
+CODEGENOPT(IndirectTlsSegRefs, 1, 0, Benign) ///< Set when 
-mno-tls-direct-seg-refs
+                                             ///< is specified.
+CODEGENOPT(DisableTailCalls  , 1, 0, Benign) ///< Do not emit tail calls.
+CODEGENOPT(NoEscapingBlockTailCalls, 1, 0, Benign) ///< Do not emit tail calls 
from
+                                                   ///< escaping blocks.
+CODEGENOPT(EmitDeclMetadata  , 1, 0, Benign) ///< Emit special metadata 
indicating what
+                                             ///< Decl* various IR entities 
came from.
+                                             ///< Only useful when running 
CodeGen as a
+                                             ///< subroutine.
+CODEGENOPT(EmitVersionIdentMetadata , 1, 1, Benign) ///< Emit compiler version 
metadata.
+CODEGENOPT(EmitOpenCLArgMetadata , 1, 0, Benign) ///< Emit OpenCL kernel arg 
metadata.
+CODEGENOPT(EmulatedTLS       , 1, 0, Benign) ///< Set by default or 
-f[no-]emulated-tls.
 /// Embed Bitcode mode (off/all/bitcode/marker).
-ENUM_CODEGENOPT(EmbedBitcode, EmbedBitcodeKind, 2, Embed_Off)
+ENUM_CODEGENOPT(EmbedBitcode, EmbedBitcodeKind, 2, Embed_Off, Benign)
 /// Inline asm dialect, -masm=(att|intel)
-ENUM_CODEGENOPT(InlineAsmDialect, InlineAsmDialectKind, 1, IAD_ATT)
-CODEGENOPT(OutputAsmVariant, 2, 3) ///< Set the asm variant for output (3: 
unspecified).
-CODEGENOPT(ForbidGuardVariables , 1, 0) ///< Issue errors if C++ guard 
variables
-                                        ///< are required.
-CODEGENOPT(FunctionSections  , 1, 0) ///< Set when -ffunction-sections is 
enabled.
-CODEGENOPT(BBAddrMap  , 1, 0) ///< Set when -fbasic-block-address-map is 
enabled.
-CODEGENOPT(InstrumentFunctions , 1, 0) ///< Set when -finstrument-functions is
-                                       ///< enabled.
-CODEGENOPT(InstrumentFunctionsAfterInlining , 1, 0) ///< Set when
+ENUM_CODEGENOPT(InlineAsmDialect, InlineAsmDialectKind, 1, IAD_ATT, Benign)
+CODEGENOPT(OutputAsmVariant, 2, 3, Benign) ///< Set the asm variant for output 
(3: unspecified).
+CODEGENOPT(ForbidGuardVariables , 1, 0, Benign) ///< Issue errors if C++ guard 
variables
+                                                ///< are required.
+CODEGENOPT(FunctionSections  , 1, 0, Benign) ///< Set when -ffunction-sections 
is enabled.
+CODEGENOPT(BBAddrMap  , 1, 0, Benign) ///< Set when -fbasic-block-address-map 
is enabled.
+CODEGENOPT(InstrumentFunctions , 1, 0, Benign) ///< Set when 
-finstrument-functions is
+                                               ///< enabled.
+CODEGENOPT(InstrumentFunctionsAfterInlining , 1, 0, Benign) ///< Set when
                           ///< -finstrument-functions-after-inlining is 
enabled.
-CODEGENOPT(InstrumentFunctionEntryBare , 1, 0) ///< Set when
+CODEGENOPT(InstrumentFunctionEntryBare , 1, 0, Benign) ///< Set when
                                ///< -finstrument-function-entry-bare is 
enabled.
-CODEGENOPT(CFProtectionReturn , 1, 0) ///< if -fcf-protection is
+CODEGENOPT(CFProtectionReturn , 1, 0, Benign) ///< if -fcf-protection is
                                       ///< set to full or return.
-CODEGENOPT(CFProtectionBranch , 1, 0) ///< if -fcf-protection is
-                                      ///< set to full or branch.
+CODEGENOPT(CFProtectionBranch , 1, 0, Benign) ///< if -fcf-protection is
+                                              ///< set to full or branch.
 ENUM_CODEGENOPT(CFBranchLabelScheme, CFBranchLabelSchemeKind, 2,
-    CFBranchLabelSchemeKind::Default) ///< if -mcf-branch-label-scheme is set.
-CODEGENOPT(FunctionReturnThunks, 1, 0) ///< 
-mfunction-return={keep|thunk-extern}
-CODEGENOPT(IndirectBranchCSPrefix, 1, 0) ///< if -mindirect-branch-cs-prefix
-                                         ///< is set.
+    CFBranchLabelSchemeKind::Default, Benign) ///< if -mcf-branch-label-scheme 
is set.
+CODEGENOPT(FunctionReturnThunks, 1, 0, Benign) ///< 
-mfunction-return={keep|thunk-extern}
+CODEGENOPT(IndirectBranchCSPrefix, 1, 0, Benign) ///< if 
-mindirect-branch-cs-prefix
+                                                 ///< is set.
 
-CODEGENOPT(XRayInstrumentFunctions , 1, 0) ///< Set when -fxray-instrument is
-                                           ///< enabled.
-CODEGENOPT(StackSizeSection  , 1, 0) ///< Set when -fstack-size-section is 
enabled.
+CODEGENOPT(XRayInstrumentFunctions , 1, 0, Benign) ///< Set when 
-fxray-instrument is
+                                                   ///< enabled.
+CODEGENOPT(StackSizeSection  , 1, 0, Benign) ///< Set when 
-fstack-size-section is enabled.
 
 ///< Set when -femit-compact-unwind-non-canonical is enabled.
-CODEGENOPT(EmitCompactUnwindNonCanonical, 1, 0)
+CODEGENOPT(EmitCompactUnwindNonCanonical, 1, 0, Benign)
 
 ///< Set when -fxray-always-emit-customevents is enabled.
-CODEGENOPT(XRayAlwaysEmitCustomEvents , 1, 0)
+CODEGENOPT(XRayAlwaysEmitCustomEvents , 1, 0, Benign)
 
 ///< Set when -fxray-always-emit-typedevents is enabled.
-CODEGENOPT(XRayAlwaysEmitTypedEvents , 1, 0)
+CODEGENOPT(XRayAlwaysEmitTypedEvents , 1, 0, Benign)
 
 ///< Set when -fxray-ignore-loops is enabled.
-CODEGENOPT(XRayIgnoreLoops , 1, 0)
+CODEGENOPT(XRayIgnoreLoops , 1, 0, Benign)
 
 ///< Emit the XRay function index section.
-CODEGENOPT(XRayFunctionIndex , 1, 1)
+CODEGENOPT(XRayFunctionIndex , 1, 1, Benign)
 
 ///< Set when -fxray-shared is enabled
-CODEGENOPT(XRayShared , 1, 0)
+CODEGENOPT(XRayShared , 1, 0, Benign)
 
 ///< Set the minimum number of instructions in a function to determine 
selective
 ///< XRay instrumentation.
-VALUE_CODEGENOPT(XRayInstructionThreshold , 32, 200)
+VALUE_CODEGENOPT(XRayInstructionThreshold , 32, 200, Benign)
 
 ///< Only instrument 1 in N functions, by dividing functions into N total 
groups and
 ///< instrumenting only the specified group at a time. Group numbers start at 0
 ///< and end at N-1.
-VALUE_CODEGENOPT(XRayTotalFunctionGroups, 32, 1)
-VALUE_CODEGENOPT(XRaySelectedFunctionGroup, 32, 0)
-
-VALUE_CODEGENOPT(PatchableFunctionEntryCount , 32, 0) ///< Number of NOPs at 
function entry
-VALUE_CODEGENOPT(PatchableFunctionEntryOffset , 32, 0)
-
-CODEGENOPT(HotPatch, 1, 0) ///< Supports the Microsoft /HOTPATCH flag and
-                           ///< generates a 'patchable-function' attribute.
-
-CODEGENOPT(TlsGuards , 1, 1) ///< Controls emission of tls guards via 
-fms-tls-guards
-CODEGENOPT(JMCInstrument, 1, 0) ///< Set when -fjmc is enabled.
-CODEGENOPT(InstrumentForProfiling , 1, 0) ///< Set when -pg is enabled.
-CODEGENOPT(CallFEntry , 1, 0) ///< Set when -mfentry is enabled.
-CODEGENOPT(MNopMCount , 1, 0) ///< Set when -mnop-mcount is enabled.
-CODEGENOPT(RecordMCount , 1, 0) ///< Set when -mrecord-mcount is enabled.
-CODEGENOPT(PackedStack , 1, 0) ///< Set when -mpacked-stack is enabled.
-CODEGENOPT(LessPreciseFPMAD  , 1, 0) ///< Enable less precise MAD instructions 
to
-                                     ///< be generated.
-CODEGENOPT(PrepareForLTO     , 1, 0) ///< Set when -flto is enabled on the
-                                     ///< compile step.
-CODEGENOPT(PrepareForThinLTO , 1, 0) ///< Set when -flto=thin is enabled on the
-                                     ///< compile step.
-CODEGENOPT(LTOUnit, 1, 0) ///< Emit IR to support LTO unit features (CFI, whole
-                          ///< program vtable opt).
-CODEGENOPT(FatLTO, 1, 0) ///< Set when -ffat-lto-objects is enabled.
-CODEGENOPT(EnableSplitLTOUnit, 1, 0) ///< Enable LTO unit splitting to support
-                                    /// CFI and traditional whole program
-                                    /// devirtualization that require whole
-                                    /// program IR support.
-CODEGENOPT(UnifiedLTO, 1, 0) ///< Use the unified LTO pipeline.
-CODEGENOPT(IncrementalLinkerCompatible, 1, 0) ///< Emit an object file which 
can
-                                              ///< be used with an incremental
-                                              ///< linker.
-CODEGENOPT(MergeAllConstants , 1, 1) ///< Merge identical constants.
-CODEGENOPT(MergeFunctions    , 1, 0) ///< Set when -fmerge-functions is 
enabled.
-CODEGENOPT(NoCommon          , 1, 0) ///< Set when -fno-common or C++ is 
enabled.
-CODEGENOPT(NoExecStack       , 1, 0) ///< Set when -Wa,--noexecstack is 
enabled.
-CODEGENOPT(MipsMsa           , 1, 0) ///< Set when -Wa,-mmsa is enabled.
-CODEGENOPT(FatalWarnings     , 1, 0) ///< Set when -Wa,--fatal-warnings is
-                                     ///< enabled.
-CODEGENOPT(NoWarn            , 1, 0) ///< Set when -Wa,--no-warn is enabled.
-CODEGENOPT(NoTypeCheck       , 1, 0) ///< Set when -Wa,--no-type-check is 
enabled.
-CODEGENOPT(MisExpect         , 1, 0) ///< Set when -Wmisexpect is enabled
-CODEGENOPT(EnableSegmentedStacks , 1, 0) ///< Set when -fsplit-stack is 
enabled.
-CODEGENOPT(StackClashProtector, 1, 0) ///< Set when -fstack-clash-protection 
is enabled.
-CODEGENOPT(NoImplicitFloat   , 1, 0) ///< Set when -mno-implicit-float is 
enabled.
-CODEGENOPT(NullPointerIsValid , 1, 0) ///< Assume Null pointer deference is 
defined.
-CODEGENOPT(OpenCLCorrectlyRoundedDivSqrt, 1, 0) ///< 
-cl-fp32-correctly-rounded-divide-sqrt
-CODEGENOPT(HIPCorrectlyRoundedDivSqrt, 1, 1) ///< 
-fno-hip-fp32-correctly-rounded-divide-sqrt
-CODEGENOPT(DisableBlockSignatureString, 1, 0) ///< Set when 
-fdisable-block-signature-string is enabled.
-CODEGENOPT(HIPSaveKernelArgName, 1, 0) ///< Set when -fhip-kernel-arg-name is 
enabled.
-CODEGENOPT(UniqueInternalLinkageNames, 1, 0) ///< Internal Linkage symbols get 
unique names.
-CODEGENOPT(SplitMachineFunctions, 1, 0) ///< Split machine functions using 
profile information.
-CODEGENOPT(PPCUseFullRegisterNames, 1, 0) ///< Print full register names in 
assembly
-CODEGENOPT(X86RelaxRelocations, 1, 1) ///< -Wa,-mrelax-relocations={yes,no}
-CODEGENOPT(X86Sse2Avx        , 1, 0)   ///< -Wa,-msse2avx
+VALUE_CODEGENOPT(XRayTotalFunctionGroups, 32, 1, Benign)
+VALUE_CODEGENOPT(XRaySelectedFunctionGroup, 32, 0, Benign)
+
+VALUE_CODEGENOPT(PatchableFunctionEntryCount , 32, 0, Benign) ///< Number of 
NOPs at function entry
+VALUE_CODEGENOPT(PatchableFunctionEntryOffset , 32, 0, Benign)
+
+CODEGENOPT(HotPatch, 1, 0, Benign) ///< Supports the Microsoft /HOTPATCH flag 
and
+                                   ///< generates a 'patchable-function' 
attribute.
+
+CODEGENOPT(TlsGuards , 1, 1, Benign) ///< Controls emission of tls guards via 
-fms-tls-guards
+CODEGENOPT(JMCInstrument, 1, 0, Benign) ///< Set when -fjmc is enabled.
+CODEGENOPT(InstrumentForProfiling , 1, 0, Benign) ///< Set when -pg is enabled.
+CODEGENOPT(CallFEntry , 1, 0, Benign) ///< Set when -mfentry is enabled.
+CODEGENOPT(MNopMCount , 1, 0, Benign) ///< Set when -mnop-mcount is enabled.
+CODEGENOPT(RecordMCount , 1, 0, Benign) ///< Set when -mrecord-mcount is 
enabled.
+CODEGENOPT(PackedStack , 1, 0, Benign) ///< Set when -mpacked-stack is enabled.
+CODEGENOPT(LessPreciseFPMAD  , 1, 0, Benign) ///< Enable less precise MAD 
instructions to
+                                             ///< be generated.
+CODEGENOPT(PrepareForLTO     , 1, 0, Benign) ///< Set when -flto is enabled on 
the
+                                             ///< compile step.
+CODEGENOPT(PrepareForThinLTO , 1, 0, Benign) ///< Set when -flto=thin is 
enabled on the
+                                             ///< compile step.
+CODEGENOPT(LTOUnit, 1, 0, Benign) ///< Emit IR to support LTO unit features 
(CFI, whole
+                                 ///< program vtable opt).
+CODEGENOPT(FatLTO, 1, 0, Benign) ///< Set when -ffat-lto-objects is enabled.
+CODEGENOPT(EnableSplitLTOUnit, 1, 0, Benign) ///< Enable LTO unit splitting to 
support
+                                             /// CFI and traditional whole 
program
+                                             /// devirtualization that require 
whole
+                                             /// program IR support.
+CODEGENOPT(UnifiedLTO, 1, 0, Benign) ///< Use the unified LTO pipeline.
+CODEGENOPT(IncrementalLinkerCompatible, 1, 0, Benign) ///< Emit an object file 
which can
+                                                      ///< be used with an 
incremental
+                                                      ///< linker.
+CODEGENOPT(MergeAllConstants , 1, 1, Benign) ///< Merge identical constants.
+CODEGENOPT(MergeFunctions    , 1, 0, Benign) ///< Set when -fmerge-functions 
is enabled.
+CODEGENOPT(NoCommon          , 1, 0, Benign) ///< Set when -fno-common or C++ 
is enabled.
+CODEGENOPT(NoExecStack       , 1, 0, Benign) ///< Set when -Wa,--noexecstack 
is enabled.
+CODEGENOPT(MipsMsa           , 1, 0, Benign) ///< Set when -Wa,-mmsa is 
enabled.
+CODEGENOPT(FatalWarnings     , 1, 0, Benign) ///< Set when 
-Wa,--fatal-warnings is
+                                             ///< enabled.
+CODEGENOPT(NoWarn            , 1, 0, Benign) ///< Set when -Wa,--no-warn is 
enabled.
+CODEGENOPT(NoTypeCheck       , 1, 0, Benign) ///< Set when -Wa,--no-type-check 
is enabled.
+CODEGENOPT(MisExpect         , 1, 0, Benign) ///< Set when -Wmisexpect is 
enabled
+CODEGENOPT(EnableSegmentedStacks , 1, 0, Benign) ///< Set when -fsplit-stack 
is enabled.
+CODEGENOPT(StackClashProtector, 1, 0, Benign) ///< Set when 
-fstack-clash-protection is enabled.
+CODEGENOPT(NoImplicitFloat   , 1, 0, Benign) ///< Set when -mno-implicit-float 
is enabled.
+CODEGENOPT(NullPointerIsValid , 1, 0, Benign) ///< Assume Null pointer 
deference is defined.
+CODEGENOPT(OpenCLCorrectlyRoundedDivSqrt, 1, 0, Benign) ///< 
-cl-fp32-correctly-rounded-divide-sqrt
+CODEGENOPT(HIPCorrectlyRoundedDivSqrt, 1, 1, Benign) ///< 
-fno-hip-fp32-correctly-rounded-divide-sqrt
+CODEGENOPT(DisableBlockSignatureString, 1, 0, Benign) ///< Set when 
-fdisable-block-signature-string is enabled.
+CODEGENOPT(HIPSaveKernelArgName, 1, 0, Benign) ///< Set when 
-fhip-kernel-arg-name is enabled.
+CODEGENOPT(UniqueInternalLinkageNames, 1, 0, Benign) ///< Internal Linkage 
symbols get unique names.
+CODEGENOPT(SplitMachineFunctions, 1, 0, Benign) ///< Split machine functions 
using profile information.
+CODEGENOPT(PPCUseFullRegisterNames, 1, 0, Benign) ///< Print full register 
names in assembly
+CODEGENOPT(X86RelaxRelocations, 1, 1, Benign) ///< 
-Wa,-mrelax-relocations={yes,no}
+CODEGENOPT(X86Sse2Avx        , 1, 0, Benign)   ///< -Wa,-msse2avx
 
 /// When false, this attempts to generate code as if the result of an
 /// overflowing conversion matches the overflowing behavior of a target's 
native
 /// float-to-int conversion instructions.
-CODEGENOPT(StrictFloatCastOverflow, 1, 1)
+CODEGENOPT(StrictFloatCastOverflow, 1, 1, Benign)
 
-CODEGENOPT(NoZeroInitializedInBSS , 1, 0) ///< -fno-zero-initialized-in-bss.
+CODEGENOPT(NoZeroInitializedInBSS , 1, 0, Benign) ///< 
-fno-zero-initialized-in-bss.
 /// Method of Objective-C dispatch to use.
-ENUM_CODEGENOPT(ObjCDispatchMethod, ObjCDispatchMethodKind, 2, Legacy)
+ENUM_CODEGENOPT(ObjCDispatchMethod, ObjCDispatchMethodKind, 2, Legacy, Benign)
 /// Replace certain message sends with calls to ObjC runtime entrypoints
-CODEGENOPT(ObjCConvertMessagesToRuntimeCalls , 1, 1)
-CODEGENOPT(ObjCAvoidHeapifyLocalBlocks, 1, 0)
+CODEGENOPT(ObjCConvertMessagesToRuntimeCalls , 1, 1, Benign)
+CODEGENOPT(ObjCAvoidHeapifyLocalBlocks, 1, 0, Benign)
 
 
-// The optimization options affect frontend options, whicn in turn do affect 
the AST.
-AFFECTING_VALUE_CODEGENOPT(OptimizationLevel, 2, 0) ///< The -O[0-3] option 
specified.
-AFFECTING_VALUE_CODEGENOPT(OptimizeSize, 2, 0) ///< If -Os (==1) or -Oz (==2) 
is specified.
+// The optimization options affect frontend options, which in turn do affect 
the AST.
+VALUE_CODEGENOPT(OptimizationLevel, 2, 0, Affecting) ///< The -O[0-3] option 
specified.
+VALUE_CODEGENOPT(OptimizeSize, 2, 0, Affecting) ///< If -Os (==1, Benign) or 
-Oz (==2, Benign) is specified.
 
-CODEGENOPT(AtomicProfileUpdate , 1, 0) ///< Set -fprofile-update=atomic
-CODEGENOPT(ContinuousProfileSync, 1, 0) ///< Enable continuous instrumentation 
profiling
+CODEGENOPT(AtomicProfileUpdate , 1, 0, Benign) ///< Set -fprofile-update=atomic
+CODEGENOPT(ContinuousProfileSync, 1, 0, Benign) ///< Enable continuous 
instrumentation profiling
 /// Choose profile instrumenation kind or no instrumentation.
 
-ENUM_CODEGENOPT(ProfileInstr, llvm::driver::ProfileInstrKind, 4, 
llvm::driver::ProfileInstrKind::ProfileNone)
+ENUM_CODEGENOPT(ProfileInstr, llvm::driver::ProfileInstrKind, 4, 
llvm::driver::ProfileInstrKind::ProfileNone, Benign)
 
 /// Choose profile kind for PGO use compilation.
-ENUM_CODEGENOPT(ProfileUse, llvm::driver::ProfileInstrKind, 2, 
llvm::driver::ProfileInstrKind::ProfileNone)
+ENUM_CODEGENOPT(ProfileUse, llvm::driver::ProfileInstrKind, 2, 
llvm::driver::ProfileInstrKind::ProfileNone, Benign)
 /// Partition functions into N groups and select only functions in group i to 
be
 /// instrumented. Selected group numbers can be 0 to N-1 inclusive.
-VALUE_CODEGENOPT(ProfileTotalFunctionGroups, 32, 1)
-VALUE_CODEGENOPT(ProfileSelectedFunctionGroup, 32, 0)
-CODEGENOPT(CoverageMapping , 1, 0) ///< Generate coverage mapping regions to
-                                   ///< enable code coverage analysis.
-CODEGENOPT(DumpCoverageMapping , 1, 0) ///< Dump the generated coverage mapping
-                                       ///< regions.
-CODEGENOPT(MCDCCoverage , 1, 0) ///< Enable MC/DC code coverage criteria.
-VALUE_CODEGENOPT(MCDCMaxConds, 16, 32767) ///< MC/DC Maximum conditions.
-VALUE_CODEGENOPT(MCDCMaxTVs, 32, 0x7FFFFFFE) ///< MC/DC Maximum test vectors.
+VALUE_CODEGENOPT(ProfileTotalFunctionGroups, 32, 1, Benign)
+VALUE_CODEGENOPT(ProfileSelectedFunctionGroup, 32, 0, Benign)
+CODEGENOPT(CoverageMapping , 1, 0, Benign) ///< Generate coverage mapping 
regions to
+                                           ///< enable code coverage analysis.
+CODEGENOPT(DumpCoverageMapping , 1, 0, Benign) ///< Dump the generated 
coverage mapping
+                                               ///< regions.
+CODEGENOPT(MCDCCoverage , 1, 0, Benign) ///< Enable MC/DC code coverage 
criteria.
+VALUE_CODEGENOPT(MCDCMaxConds, 16, 32767, Benign) ///< MC/DC Maximum 
conditions.
+VALUE_CODEGENOPT(MCDCMaxTVs, 32, 0x7FFFFFFE, Benign) ///< MC/DC Maximum test 
vectors.
 
   /// If -fpcc-struct-return or -freg-struct-return is specified.
-ENUM_CODEGENOPT(StructReturnConvention, StructReturnConventionKind, 2, 
SRCK_Default)
-
-CODEGENOPT(RelaxAll          , 1, 0) ///< Relax all machine code instructions.
-CODEGENOPT(RelaxedAliasing   , 1, 0) ///< Set when -fno-strict-aliasing is 
enabled.
-CODEGENOPT(PointerTBAA       , 1, 1) ///< Whether or not to use distinct TBAA 
tags for pointers.
-CODEGENOPT(StructPathTBAA    , 1, 0) ///< Whether or not to use struct-path 
TBAA.
-CODEGENOPT(NewStructPathTBAA , 1, 0) ///< Whether or not to use enhanced 
struct-path TBAA.
-CODEGENOPT(SaveTempLabels    , 1, 0) ///< Save temporary labels.
-CODEGENOPT(SanitizeAddressUseAfterScope , 1, 0) ///< Enable use-after-scope 
detection
-                                                ///< in AddressSanitizer
+ENUM_CODEGENOPT(StructReturnConvention, StructReturnConventionKind, 2, 
SRCK_Default, Benign)
+
+CODEGENOPT(RelaxAll          , 1, 0, Benign) ///< Relax all machine code 
instructions.
+CODEGENOPT(RelaxedAliasing   , 1, 0, Benign) ///< Set when 
-fno-strict-aliasing is enabled.
+CODEGENOPT(PointerTBAA       , 1, 1, Benign) ///< Whether or not to use 
distinct TBAA tags for pointers.
+CODEGENOPT(StructPathTBAA    , 1, 0, Benign) ///< Whether or not to use 
struct-path TBAA.
+CODEGENOPT(NewStructPathTBAA , 1, 0, Benign) ///< Whether or not to use 
enhanced struct-path TBAA.
+CODEGENOPT(SaveTempLabels    , 1, 0, Benign) ///< Save temporary labels.
+CODEGENOPT(SanitizeAddressUseAfterScope , 1, 0, Benign) ///< Enable 
use-after-scope detection
+                                                        ///< in 
AddressSanitizer
 ENUM_CODEGENOPT(SanitizeAddressUseAfterReturn,
                 llvm::AsanDetectStackUseAfterReturnMode, 2,
-                llvm::AsanDetectStackUseAfterReturnMode::Runtime
+                llvm::AsanDetectStackUseAfterReturnMode::Runtime,
+                Benign
                 ) ///< Set detection mode for stack-use-after-return.
-CODEGENOPT(SanitizeAddressPoisonCustomArrayCookie, 1,
-           0) ///< Enable poisoning operator new[] which is not a replaceable
-              ///< global allocation function in AddressSanitizer
-CODEGENOPT(SanitizeAddressGlobalsDeadStripping, 1, 0) ///< Enable linker dead 
stripping
-                                                      ///< of globals in 
AddressSanitizer
-CODEGENOPT(SanitizeAddressUseOdrIndicator, 1, 0) ///< Enable ODR indicator 
globals
-CODEGENOPT(SanitizeMemoryTrackOrigins, 2, 0) ///< Enable tracking origins in
-                                             ///< MemorySanitizer
+CODEGENOPT(SanitizeAddressPoisonCustomArrayCookie, 1, 0, Benign) ///< Enable 
poisoning operator new[] which is not a replaceable
+                                                                 ///< global 
allocation function in AddressSanitizer
+CODEGENOPT(SanitizeAddressGlobalsDeadStripping, 1, 0, Benign) ///< Enable 
linker dead stripping
+                                                              ///< of globals 
in AddressSanitizer
+CODEGENOPT(SanitizeAddressUseOdrIndicator, 1, 0, Benign) ///< Enable ODR 
indicator globals
+CODEGENOPT(SanitizeMemoryTrackOrigins, 2, 0, Benign) ///< Enable tracking 
origins in
+                                                     ///< MemorySanitizer
 ENUM_CODEGENOPT(SanitizeAddressDtor, llvm::AsanDtorKind, 2,
-                llvm::AsanDtorKind::Global)  ///< Set how ASan global
-                                             ///< destructors are emitted.
-CODEGENOPT(SanitizeMemoryParamRetval, 1, 0) ///< Enable detection of 
uninitialized
-                                            ///< parameters and return values
-                                            ///< in MemorySanitizer
-CODEGENOPT(SanitizeMemoryUseAfterDtor, 1, 0) ///< Enable use-after-delete 
detection
-                                             ///< in MemorySanitizer
-CODEGENOPT(SanitizeCfiCrossDso, 1, 0) ///< Enable cross-dso support in CFI.
-CODEGENOPT(SanitizeMinimalRuntime, 1, 0) ///< Use "_minimal" sanitizer runtime 
for
-                                         ///< diagnostics.
-CODEGENOPT(SanitizeCfiICallGeneralizePointers, 1, 0) ///< Generalize pointer 
types in
-                                                     ///< CFI icall function 
signatures
-CODEGENOPT(SanitizeCfiICallNormalizeIntegers, 1, 0) ///< Normalize integer 
types in
-                                                    ///< CFI icall function 
signatures
-CODEGENOPT(SanitizeCfiCanonicalJumpTables, 1, 0) ///< Make jump table symbols 
canonical
-                                                 ///< instead of creating a 
local jump table.
-CODEGENOPT(SanitizeKcfiArity, 1, 0) ///< Embed arity in KCFI patchable 
function prefix
-CODEGENOPT(SanitizeCoverageType, 2, 0) ///< Type of sanitizer coverage
-                                       ///< instrumentation.
-CODEGENOPT(SanitizeCoverageIndirectCalls, 1, 0) ///< Enable sanitizer coverage
-                                                ///< for indirect calls.
-CODEGENOPT(SanitizeCoverageTraceBB, 1, 0) ///< Enable basic block tracing in
-                                          ///< in sanitizer coverage.
-CODEGENOPT(SanitizeCoverageTraceCmp, 1, 0) ///< Enable cmp instruction tracing
-                                           ///< in sanitizer coverage.
-CODEGENOPT(SanitizeCoverageTraceDiv, 1, 0) ///< Enable div instruction tracing
-                                           ///< in sanitizer coverage.
-CODEGENOPT(SanitizeCoverageTraceGep, 1, 0) ///< Enable GEP instruction tracing
-                                           ///< in sanitizer coverage.
-CODEGENOPT(SanitizeCoverage8bitCounters, 1, 0) ///< Use 8-bit frequency 
counters
-                                               ///< in sanitizer coverage.
-CODEGENOPT(SanitizeCoverageTracePC, 1, 0) ///< Enable PC tracing
-                                          ///< in sanitizer coverage.
-CODEGENOPT(SanitizeCoverageTracePCGuard, 1, 0) ///< Enable PC tracing with 
guard
-                                               ///< in sanitizer coverage.
-CODEGENOPT(SanitizeCoverageInline8bitCounters, 1, 0) ///< Use inline 8bit 
counters.
-CODEGENOPT(SanitizeCoverageInlineBoolFlag, 1, 0) ///< Use inline bool flag.
-CODEGENOPT(SanitizeCoveragePCTable, 1, 0) ///< Create a PC Table.
-CODEGENOPT(SanitizeCoverageControlFlow, 1, 0) ///< Collect control flow
-CODEGENOPT(SanitizeCoverageNoPrune, 1, 0) ///< Disable coverage pruning.
-CODEGENOPT(SanitizeCoverageStackDepth, 1, 0) ///< Enable max stack depth 
tracing
-VALUE_CODEGENOPT(SanitizeCoverageStackDepthCallbackMin , 32, 0) ///< Enable 
stack depth tracing callbacks.
-CODEGENOPT(SanitizeCoverageTraceLoads, 1, 0) ///< Enable tracing of loads.
-CODEGENOPT(SanitizeCoverageTraceStores, 1, 0) ///< Enable tracing of stores.
-CODEGENOPT(SanitizeBinaryMetadataCovered, 1, 0) ///< Emit PCs for covered 
functions.
-CODEGENOPT(SanitizeBinaryMetadataAtomics, 1, 0) ///< Emit PCs for atomic 
operations.
-CODEGENOPT(SanitizeBinaryMetadataUAR, 1, 0) ///< Emit PCs for start of 
functions
-                                            ///< that are subject for 
use-after-return checking.
-CODEGENOPT(SanitizeStats     , 1, 0) ///< Collect statistics for sanitizers.
-CODEGENOPT(SimplifyLibCalls  , 1, 1) ///< Set when -fbuiltin is enabled.
-CODEGENOPT(SoftFloat         , 1, 0) ///< -soft-float.
-CODEGENOPT(SpeculativeLoadHardening, 1, 0) ///< Enable speculative load 
hardening.
-CODEGENOPT(FineGrainedBitfieldAccesses, 1, 0) ///< Enable fine-grained 
bitfield accesses.
-CODEGENOPT(StrictEnums       , 1, 0) ///< Optimize based on strict enum 
definition.
-CODEGENOPT(StrictVTablePointers, 1, 0) ///< Optimize based on the strict 
vtable pointers
-CODEGENOPT(TimePasses        , 1, 0) ///< Set when -ftime-report or 
-ftime-report= or -ftime-report-json is enabled.
-CODEGENOPT(TimePassesPerRun  , 1, 0) ///< Set when -ftime-report=per-pass-run 
is enabled.
-CODEGENOPT(TimePassesJson    , 1, 0) ///< Set when -ftime-report-json is 
enabled.
-CODEGENOPT(TimeTrace         , 1, 0) ///< Set when -ftime-trace is enabled.
-VALUE_CODEGENOPT(TimeTraceGranularity, 32, 500) ///< Minimum time granularity 
(in microseconds),
-                                               ///< traced by time profiler
-CODEGENOPT(InterchangeLoops  , 1, 0) ///< Run loop-interchange.
-CODEGENOPT(UnrollLoops       , 1, 0) ///< Control whether loops are unrolled.
-CODEGENOPT(RerollLoops       , 1, 0) ///< Control whether loops are rerolled.
-CODEGENOPT(NoUseJumpTables   , 1, 0) ///< Set when -fno-jump-tables is enabled.
-VALUE_CODEGENOPT(UnwindTables, 2, 0) ///< Unwind tables (1) or asynchronous 
unwind tables (2)
-CODEGENOPT(LinkBitcodePostopt, 1, 0) ///< Link builtin bitcodes after 
optimization pipeline.
-CODEGENOPT(VectorizeLoop     , 1, 0) ///< Run loop vectorizer.
-CODEGENOPT(VectorizeSLP      , 1, 0) ///< Run SLP vectorizer.
-CODEGENOPT(ProfileSampleAccurate, 1, 0) ///< Sample profile is accurate.
+                llvm::AsanDtorKind::Global, Benign)  ///< Set how ASan global
+                                                     ///< destructors are 
emitted.
+CODEGENOPT(SanitizeMemoryParamRetval, 1, 0, Benign) ///< Enable detection of 
uninitialized
+                                                    ///< parameters and return 
values
+                                                    ///< in MemorySanitizer
+CODEGENOPT(SanitizeMemoryUseAfterDtor, 1, 0, Benign) ///< Enable 
use-after-delete detection
+                                                     ///< in MemorySanitizer
+CODEGENOPT(SanitizeCfiCrossDso, 1, 0, Benign) ///< Enable cross-dso support in 
CFI.
+CODEGENOPT(SanitizeMinimalRuntime, 1, 0, Benign) ///< Use "_minimal" sanitizer 
runtime for
+                                                 ///< diagnostics.
+CODEGENOPT(SanitizeCfiICallGeneralizePointers, 1, 0, Benign) ///< Generalize 
pointer types in
+                                                             ///< CFI icall 
function signatures
+CODEGENOPT(SanitizeCfiICallNormalizeIntegers, 1, 0, Benign) ///< Normalize 
integer types in
+                                                            ///< CFI icall 
function signatures
+CODEGENOPT(SanitizeCfiCanonicalJumpTables, 1, 0, Benign) ///< Make jump table 
symbols canonical
+                                                         ///< instead of 
creating a local jump table.
+CODEGENOPT(SanitizeKcfiArity, 1, 0, Benign) ///< Embed arity in KCFI patchable 
function prefix
+CODEGENOPT(SanitizeCoverageType, 2, 0, Benign) ///< Type of sanitizer coverage
+                                               ///< instrumentation.
+CODEGENOPT(SanitizeCoverageIndirectCalls, 1, 0, Benign) ///< Enable sanitizer 
coverage
+                                                        ///< for indirect 
calls.
+CODEGENOPT(SanitizeCoverageTraceBB, 1, 0, Benign) ///< Enable basic block 
tracing in
+                                                  ///< in sanitizer coverage.
+CODEGENOPT(SanitizeCoverageTraceCmp, 1, 0, Benign) ///< Enable cmp instruction 
tracing
+                                                   ///< in sanitizer coverage.
+CODEGENOPT(SanitizeCoverageTraceDiv, 1, 0, Benign) ///< Enable div instruction 
tracing
+                                                   ///< in sanitizer coverage.
+CODEGENOPT(SanitizeCoverageTraceGep, 1, 0, Benign) ///< Enable GEP instruction 
tracing
+                                                   ///< in sanitizer coverage.
+CODEGENOPT(SanitizeCoverage8bitCounters, 1, 0, Benign) ///< Use 8-bit 
frequency counters
+                                                       ///< in sanitizer 
coverage.
+CODEGENOPT(SanitizeCoverageTracePC, 1, 0, Benign) ///< Enable PC tracing
+                                                  ///< in sanitizer coverage.
+CODEGENOPT(SanitizeCoverageTracePCGuard, 1, 0, Benign) ///< Enable PC tracing 
with guard
+                                                       ///< in sanitizer 
coverage.
+CODEGENOPT(SanitizeCoverageInline8bitCounters, 1, 0, Benign) ///< Use inline 
8bit counters.
+CODEGENOPT(SanitizeCoverageInlineBoolFlag, 1, 0, Benign) ///< Use inline bool 
flag.
+CODEGENOPT(SanitizeCoveragePCTable, 1, 0, Benign) ///< Create a PC Table.
+CODEGENOPT(SanitizeCoverageControlFlow, 1, 0, Benign) ///< Collect control flow
+CODEGENOPT(SanitizeCoverageNoPrune, 1, 0, Benign) ///< Disable coverage 
pruning.
+CODEGENOPT(SanitizeCoverageStackDepth, 1, 0, Benign) ///< Enable max stack 
depth tracing
+VALUE_CODEGENOPT(SanitizeCoverageStackDepthCallbackMin , 32, 0, Benign) ///< 
Enable stack depth tracing callbacks.
+CODEGENOPT(SanitizeCoverageTraceLoads, 1, 0, Benign) ///< Enable tracing of 
loads.
+CODEGENOPT(SanitizeCoverageTraceStores, 1, 0, Benign) ///< Enable tracing of 
stores.
+CODEGENOPT(SanitizeBinaryMetadataCovered, 1, 0, Benign) ///< Emit PCs for 
covered functions.
+CODEGENOPT(SanitizeBinaryMetadataAtomics, 1, 0, Benign) ///< Emit PCs for 
atomic operations.
+CODEGENOPT(SanitizeBinaryMetadataUAR, 1, 0, Benign) ///< Emit PCs for start of 
functions
+                                                    ///< that are subject for 
use-after-return checking.
+CODEGENOPT(SanitizeStats     , 1, 0, Benign) ///< Collect statistics for 
sanitizers.
+CODEGENOPT(SimplifyLibCalls  , 1, 1, Benign) ///< Set when -fbuiltin is 
enabled.
+CODEGENOPT(SoftFloat         , 1, 0, Benign) ///< -soft-float.
+CODEGENOPT(SpeculativeLoadHardening, 1, 0, Benign) ///< Enable speculative 
load hardening.
+CODEGENOPT(FineGrainedBitfieldAccesses, 1, 0, Benign) ///< Enable fine-grained 
bitfield accesses.
+CODEGENOPT(StrictEnums       , 1, 0, Benign) ///< Optimize based on strict 
enum definition.
+CODEGENOPT(StrictVTablePointers, 1, 0, Benign) ///< Optimize based on the 
strict vtable pointers
+CODEGENOPT(TimePasses        , 1, 0, Benign) ///< Set when -ftime-report or 
-ftime-report= or -ftime-report-json is enabled.
+CODEGENOPT(TimePassesPerRun  , 1, 0, Benign) ///< Set when 
-ftime-report=per-pass-run is enabled.
+CODEGENOPT(TimePassesJson    , 1, 0, Benign) ///< Set when -ftime-report-json 
is enabled.
+CODEGENOPT(TimeTrace         , 1, 0, Benign) ///< Set when -ftime-trace is 
enabled.
+VALUE_CODEGENOPT(TimeTraceGranularity, 32, 500, Benign) ///< Minimum time 
granularity (in microseconds),
+                                                        ///< traced by time 
profiler
+CODEGENOPT(InterchangeLoops  , 1, 0, Benign) ///< Run loop-interchange.
+CODEGENOPT(UnrollLoops       , 1, 0, Benign) ///< Control whether loops are 
unrolled.
+CODEGENOPT(RerollLoops       , 1, 0, Benign) ///< Control whether loops are 
rerolled.
+CODEGENOPT(NoUseJumpTables   , 1, 0, Benign) ///< Set when -fno-jump-tables is 
enabled.
+VALUE_CODEGENOPT(UnwindTables, 2, 0, Benign) ///< Unwind tables (1, Benign) or 
asynchronous unwind tables (2, Benign)
+CODEGENOPT(LinkBitcodePostopt, 1, 0, Benign) ///< Link builtin bitcodes after 
optimization pipeline.
+CODEGENOPT(VectorizeLoop     , 1, 0, Benign) ///< Run loop vectorizer.
+CODEGENOPT(VectorizeSLP      , 1, 0, Benign) ///< Run SLP vectorizer.
+CODEGENOPT(ProfileSampleAccurate, 1, 0, Benign) ///< Sample profile is 
accurate.
 
 /// Treat loops as finite: language, always, never.
-ENUM_CODEGENOPT(FiniteLoops, FiniteLoopsKind, 2, FiniteLoopsKind::Language)
+ENUM_CODEGENOPT(FiniteLoops, FiniteLoopsKind, 2, FiniteLoopsKind::Language, 
Benign)
 
   /// Attempt to use register sized accesses to bit-fields in structures, when
   /// possible.
-CODEGENOPT(UseRegisterSizedBitfieldAccess , 1, 0)
-
-CODEGENOPT(VerifyModule      , 1, 1) ///< Control whether the module should be 
run
-                                     ///< through the LLVM Verifier.
-CODEGENOPT(VerifyEach        , 1, 1) ///< Control whether the LLVM verifier
-                                     ///< should run after every pass.
-
-CODEGENOPT(StackRealignment  , 1, 0) ///< Control whether to force stack
-                                     ///< realignment.
-CODEGENOPT(UseInitArray      , 1, 0) ///< Control whether to use .init_array or
-                                     ///< .ctors.
-VALUE_CODEGENOPT(LoopAlignment     , 32, 0) ///< Overrides default loop
-                                            ///< alignment, if not 0.
-VALUE_CODEGENOPT(StackAlignment    , 32, 0) ///< Overrides default stack
-                                            ///< alignment, if not 0.
-VALUE_CODEGENOPT(StackProbeSize    , 32, 4096) ///< Overrides default stack
-                                               ///< probe size, even if 0.
-VALUE_CODEGENOPT(WarnStackSize     , 32, UINT_MAX) ///< Set via 
-fwarn-stack-size.
-CODEGENOPT(NoStackArgProbe, 1, 0) ///< Set when -mno-stack-arg-probe is used
-CODEGENOPT(EmitLLVMUseLists, 1, 0) ///< Control whether to serialize use-lists.
-
-CODEGENOPT(WholeProgramVTables, 1, 0) ///< Whether to apply whole-program
-                                      ///  vtable optimization.
-
-CODEGENOPT(VirtualFunctionElimination, 1, 0) ///< Whether to apply the dead
-                                             /// virtual function elimination
-                                             /// optimization.
+CODEGENOPT(UseRegisterSizedBitfieldAccess , 1, 0, Benign)
+
+CODEGENOPT(VerifyModule      , 1, 1, Benign) ///< Control whether the module 
should be run
+                                             ///< through the LLVM Verifier.
+CODEGENOPT(VerifyEach        , 1, 1, Benign) ///< Control whether the LLVM 
verifier
+                                             ///< should run after every pass.
+
+CODEGENOPT(StackRealignment  , 1, 0, Benign) ///< Control whether to force 
stack
+                                             ///< realignment.
+CODEGENOPT(UseInitArray      , 1, 0, Benign) ///< Control whether to use 
.init_array or
+                                             ///< .ctors.
+VALUE_CODEGENOPT(LoopAlignment     , 32, 0, Benign) ///< Overrides default loop
+                                                    ///< alignment, if not 0.
+VALUE_CODEGENOPT(StackAlignment    , 32, 0, Benign) ///< Overrides default 
stack
+                                                    ///< alignment, if not 0.
+VALUE_CODEGENOPT(StackProbeSize    , 32, 4096, Benign) ///< Overrides default 
stack
+                                                       ///< probe size, even 
if 0.
+VALUE_CODEGENOPT(WarnStackSize     , 32, UINT_MAX, Benign) ///< Set via 
-fwarn-stack-size.
+CODEGENOPT(NoStackArgProbe, 1, 0, Benign) ///< Set when -mno-stack-arg-probe 
is used
+CODEGENOPT(EmitLLVMUseLists, 1, 0, Benign) ///< Control whether to serialize 
use-lists.
+
+CODEGENOPT(WholeProgramVTables, 1, 0, Benign) ///< Whether to apply 
whole-program
+                                              ///  vtable optimization.
+
+CODEGENOPT(VirtualFunctionElimination, 1, 0, Benign) ///< Whether to apply the 
dead
+                                                     /// virtual function 
elimination
+                                                     /// optimization.
 
 /// Whether to use public LTO visibility for entities in std and stdext
 /// namespaces. This is enabled by clang-cl's /MT and /MTd flags.
-CODEGENOPT(LTOVisibilityPublicStd, 1, 0)
+CODEGENOPT(LTOVisibilityPublicStd, 1, 0, Benign)
 
 /// The user specified number of registers to be used for integral arguments,
 /// or 0 if unspecified.
-VALUE_CODEGENOPT(NumRegisterParameters, 32, 0)
+VALUE_CODEGENOPT(NumRegisterParameters, 32, 0, Benign)
 
 /// The threshold to put data into small data section.
-VALUE_CODEGENOPT(SmallDataLimit, 32, 0)
+VALUE_CODEGENOPT(SmallDataLimit, 32, 0, Benign)
 
 /// The lower bound for a buffer to be considered for stack protection.
-VALUE_CODEGENOPT(SSPBufferSize, 32, 0)
+VALUE_CODEGENOPT(SSPBufferSize, 32, 0, Benign)
 
 /// The kind of inlining to perform.
-ENUM_CODEGENOPT(Inlining, InliningMethod, 2, NormalInlining)
+ENUM_CODEGENOPT(Inlining, InliningMethod, 2, NormalInlining, Benign)
 
 /// The maximum stack size a function can have to be considered for inlining.
-VALUE_CODEGENOPT(InlineMaxStackSize, 32, UINT_MAX)
+VALUE_CODEGENOPT(InlineMaxStackSize, 32, UINT_MAX, Benign)
 
 // Vector functions library to use.
-ENUM_CODEGENOPT(VecLib, llvm::driver::VectorLibrary, 4, 
llvm::driver::VectorLibrary::NoLibrary)
+ENUM_CODEGENOPT(VecLib, llvm::driver::VectorLibrary, 4, 
llvm::driver::VectorLibrary::NoLibrary, Benign)
 
 /// The default TLS model to use.
-ENUM_CODEGENOPT(DefaultTLSModel, TLSModel, 2, GeneralDynamicTLSModel)
+ENUM_CODEGENOPT(DefaultTLSModel, TLSModel, 2, GeneralDynamicTLSModel, Benign)
 
 /// Whether to enable TLSDESC. AArch64 enables TLSDESC regardless of this 
value.
-CODEGENOPT(EnableTLSDESC, 1, 0)
+CODEGENOPT(EnableTLSDESC, 1, 0, Benign)
 
 /// Bit size of immediate TLS offsets (0 == use the default).
-VALUE_CODEGENOPT(TLSSize, 8, 0)
+VALUE_CODEGENOPT(TLSSize, 8, 0, Benign)
 
 /// The types of variables that we will extend the live ranges of.
-ENUM_CODEGENOPT(ExtendVariableLiveness, ExtendVariableLivenessKind, 2, 
ExtendVariableLivenessKind::None)
+ENUM_CODEGENOPT(ExtendVariableLiveness, ExtendVariableLivenessKind, 2, 
ExtendVariableLivenessKind::None, Benign)
 
 /// The default stack protector guard offset to use.
-VALUE_CODEGENOPT(StackProtectorGuardOffset, 32, INT_MAX)
+VALUE_CODEGENOPT(StackProtectorGuardOffset, 32, INT_MAX, Benign)
 
 /// Number of path components to strip when emitting checks. (0 == full
 /// filename)
-VALUE_CODEGENOPT(EmitCheckPathComponentsToStrip, 32, 0)
+VALUE_CODEGENOPT(EmitCheckPathComponentsToStrip, 32, 0, Benign)
 
 /// Whether to report the hotness of the code region for optimization remarks.
-CODEGENOPT(DiagnosticsWithHotness, 1, 0)
+CODEGENOPT(DiagnosticsWithHotness, 1, 0, Benign)
 
 /// Whether to use direct access relocations (instead of GOT) to reference 
external data symbols.
-CODEGENOPT(DirectAccessExternalData, 1, 0)
+CODEGENOPT(DirectAccessExternalData, 1, 0, Benign)
 
 /// Whether we should use the undefined behaviour optimization for control flow
 /// paths that reach the end of a function without executing a required return.
-CODEGENOPT(StrictReturn, 1, 1)
+CODEGENOPT(StrictReturn, 1, 1, Benign)
 
 /// Whether emit pseudo probes for sample pgo profile collection.
-CODEGENOPT(PseudoProbeForProfiling, 1, 0)
+CODEGENOPT(PseudoProbeForProfiling, 1, 0, Benign)
 
-CODEGENOPT(NoPLT, 1, 0)
+CODEGENOPT(NoPLT, 1, 0, Benign)
 
 /// Whether to emit all vtables
-CODEGENOPT(ForceEmitVTables, 1, 0)
+CODEGENOPT(ForceEmitVTables, 1, 0, Benign)
 
 /// Whether to emit an address-significance table into the object file.
-CODEGENOPT(Addrsig, 1, 0)
+CODEGENOPT(Addrsig, 1, 0, Benign)
 
 /// Whether to emit unused static constants.
-CODEGENOPT(KeepStaticConsts, 1, 0)
+CODEGENOPT(KeepStaticConsts, 1, 0, Benign)
 
 /// Whether to emit all variables that have a persistent storage duration,
 /// including global, static and thread local variables.
-CODEGENOPT(KeepPersistentStorageVariables, 1, 0)
+CODEGENOPT(KeepPersistentStorageVariables, 1, 0, Benign)
 
 /// Whether to follow the AAPCS enforcing at least one read before storing to 
a volatile bitfield
-CODEGENOPT(ForceAAPCSBitfieldLoad, 1, 0)
+CODEGENOPT(ForceAAPCSBitfieldLoad, 1, 0, Benign)
 
 /// Assume that by-value parameters do not alias any other values.
-CODEGENOPT(PassByValueIsNoAlias, 1, 0)
+CODEGENOPT(PassByValueIsNoAlias, 1, 0, Benign)
 
 /// Whether to store register parameters to stack.
-CODEGENOPT(SaveRegParams, 1, 0)
+CODEGENOPT(SaveRegParams, 1, 0, Benign)
 
 /// Whether to not follow the AAPCS that enforces volatile bit-field access 
width to be
 /// according to the field declaring type width.
-CODEGENOPT(AAPCSBitfieldWidth, 1, 1)
+CODEGENOPT(AAPCSBitfieldWidth, 1, 1, Benign)
 
 /// Sets the IEEE bit in the expected default floating point mode register.
 /// Floating point opcodes that support exception flag gathering quiet and
 /// propagate signaling NaN inputs per IEEE 754-2008 (AMDGPU Only)
-CODEGENOPT(EmitIEEENaNCompliantInsts, 1, 1)
+CODEGENOPT(EmitIEEENaNCompliantInsts, 1, 1, Benign)
 
 // Whether to emit Swift Async function extended frame information: auto,
 // never, always.
 ENUM_CODEGENOPT(SwiftAsyncFramePointer, SwiftAsyncFramePointerKind, 2,
-                SwiftAsyncFramePointerKind::Always)
+                SwiftAsyncFramePointerKind::Always, Benign)
 
 /// Whether to skip RAX setup when passing variable arguments (x86 only).
-CODEGENOPT(SkipRaxSetup, 1, 0)
+CODEGENOPT(SkipRaxSetup, 1, 0, Benign)
 
 /// Whether to zero out caller-used registers before returning.
 ENUM_CODEGENOPT(ZeroCallUsedRegs, llvm::ZeroCallUsedRegs::ZeroCallUsedRegsKind,
-                5, llvm::ZeroCallUsedRegs::ZeroCallUsedRegsKind::Skip)
+                5, llvm::ZeroCallUsedRegs::ZeroCallUsedRegsKind::Skip, Benign)
 
 /// Modify C++ ABI to returning `this` pointer from constructors and
 /// non-deleting destructors. (No effect on Microsoft ABI.)
-CODEGENOPT(CtorDtorReturnThis, 1, 0)
+CODEGENOPT(CtorDtorReturnThis, 1, 0, Benign)
 
 /// Enables emitting Import Call sections on supported targets that can be used
 /// by the Windows kernel to enable import call optimization.
-CODEGENOPT(ImportCallOptimization, 1, 0)
+CODEGENOPT(ImportCallOptimization, 1, 0, Benign)
 
 /// Controls whether we generate code for static linking of libclosure
 /// (BlocksRuntime) on Windows.
-CODEGENOPT(StaticClosure, 1, 0)
+CODEGENOPT(StaticClosure, 1, 0, Benign)
 
 /// Assume that UAVs/SRVs may alias
-CODEGENOPT(ResMayAlias, 1, 0)
+CODEGENOPT(ResMayAlias, 1, 0, Benign)
 
 /// Controls how unwind v2 (epilog) information should be generated for x64
 /// Windows.
 ENUM_CODEGENOPT(WinX64EHUnwindV2, llvm::WinX64EHUnwindV2Mode,
-                2, llvm::WinX64EHUnwindV2Mode::Disabled)
+                2, llvm::WinX64EHUnwindV2Mode::Disabled, Benign)
 
 /// FIXME: Make DebugOptions its own top-level .def file.
 #include "DebugOptions.def"
@@ -494,4 +486,3 @@ ENUM_CODEGENOPT(WinX64EHUnwindV2, 
llvm::WinX64EHUnwindV2Mode,
 #undef CODEGENOPT
 #undef ENUM_CODEGENOPT
 #undef VALUE_CODEGENOPT
-#undef AFFECTING_VALUE_CODEGENOPT

diff  --git a/clang/include/clang/Basic/CodeGenOptions.h 
b/clang/include/clang/Basic/CodeGenOptions.h
index 1b99d56fc68e1..fe634d221b424 100644
--- a/clang/include/clang/Basic/CodeGenOptions.h
+++ b/clang/include/clang/Basic/CodeGenOptions.h
@@ -41,13 +41,26 @@ class CodeGenOptionsBase {
   friend class CompilerInvocationBase;
 
 public:
-#define CODEGENOPT(Name, Bits, Default) unsigned Name : Bits;
-#define ENUM_CODEGENOPT(Name, Type, Bits, Default)
+  /// For ASTs produced with 
diff erent option value, signifies their level of
+  /// compatibility.
+  enum class CompatibilityKind {
+    /// Does affect the construction of the AST in a way that does prevent
+    /// module interoperability.
+    Affecting,
+    /// Does not affect the construction of the AST in any way (that is, the
+    /// value can be 
diff erent between an implicit module and the user of that
+    /// module).
+    Benign,
+  };
+
+#define CODEGENOPT(Name, Bits, Default, Compatibility) unsigned Name : Bits;
+#define ENUM_CODEGENOPT(Name, Type, Bits, Default, Compatibility)
 #include "clang/Basic/CodeGenOptions.def"
 
 protected:
-#define CODEGENOPT(Name, Bits, Default)
-#define ENUM_CODEGENOPT(Name, Type, Bits, Default) unsigned Name : Bits;
+#define CODEGENOPT(Name, Bits, Default, Compatibility)
+#define ENUM_CODEGENOPT(Name, Type, Bits, Default, Compatibility)              
\
+  unsigned Name : Bits;
 #include "clang/Basic/CodeGenOptions.def"
 };
 
@@ -507,9 +520,9 @@ class CodeGenOptions : public CodeGenOptionsBase {
 
 public:
   // Define accessors/mutators for code generation options of enumeration type.
-#define CODEGENOPT(Name, Bits, Default)
-#define ENUM_CODEGENOPT(Name, Type, Bits, Default) \
-  Type get##Name() const { return static_cast<Type>(Name); } \
+#define CODEGENOPT(Name, Bits, Default, Compatibility)
+#define ENUM_CODEGENOPT(Name, Type, Bits, Default, Compatibility)              
\
+  Type get##Name() const { return static_cast<Type>(Name); }                   
\
   void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
 #include "clang/Basic/CodeGenOptions.def"
 

diff  --git a/clang/include/clang/Basic/DebugOptions.def 
b/clang/include/clang/Basic/DebugOptions.def
index 7a9d2e838c1ca..e2ab06184b96a 100644
--- a/clang/include/clang/Basic/DebugOptions.def
+++ b/clang/include/clang/Basic/DebugOptions.def
@@ -12,143 +12,122 @@
 // options that have enumeration type), and VALUE_DEBUGOPT (is a debug option
 // that describes a value rather than a flag).
 //
-// BENIGN_ variants of the macros are used to describe options that do not
-// affect the generated PCM.
-//
 
//===----------------------------------------------------------------------===//
 #ifndef DEBUGOPT
-#define DEBUGOPT(Name, Bits, Default) \
-CODEGENOPT(Name, Bits, Default)
+#define DEBUGOPT(Name, Bits, Default, Compatibility) \
+CODEGENOPT(Name, Bits, Default, Compatibility)
 #endif
 
 #ifndef VALUE_DEBUGOPT
-#  define VALUE_DEBUGOPT(Name, Bits, Default) \
-VALUE_CODEGENOPT(Name, Bits, Default)
+#  define VALUE_DEBUGOPT(Name, Bits, Default, Compatibility) \
+VALUE_CODEGENOPT(Name, Bits, Default, Compatibility)
 #endif
 
 #ifndef ENUM_DEBUGOPT
-#  define ENUM_DEBUGOPT(Name, Type, Bits, Default) \
-ENUM_CODEGENOPT(Name, Type, Bits, Default)
-#endif
-
-#ifndef BENIGN_DEBUGOPT
-#define BENIGN_DEBUGOPT(Name, Bits, Default) \
-DEBUGOPT(Name, Bits, Default)
-#endif
-
-#ifndef BENIGN_VALUE_DEBUGOPT
-#  define BENIGN_VALUE_DEBUGOPT(Name, Bits, Default) \
-VALUE_DEBUGOPT(Name, Bits, Default)
-#endif
-
-#ifndef BENIGN_ENUM_DEBUGOPT
-#  define BENIGN_ENUM_DEBUGOPT(Name, Type, Bits, Default) \
-ENUM_DEBUGOPT(Name, Type, Bits, Default)
+#  define ENUM_DEBUGOPT(Name, Type, Bits, Default, Compatibility) \
+ENUM_CODEGENOPT(Name, Type, Bits, Default, Compatibility)
 #endif
 
-BENIGN_ENUM_DEBUGOPT(CompressDebugSections, llvm::DebugCompressionType, 2,
-                     llvm::DebugCompressionType::None)
-DEBUGOPT(Dwarf64, 1, 0) ///< -gdwarf64.
-BENIGN_DEBUGOPT(EnableDIPreservationVerify, 1, 0) ///< Enable di preservation
-                                                  ///< verify each (it means
-                                                  ///< check the original debug
-                                                  ///< info metadata
-                                                  ///< preservation).
-BENIGN_DEBUGOPT(ForceDwarfFrameSection , 1, 0) ///< Set when 
-fforce-dwarf-frame
-                                               ///< is enabled.
+ENUM_DEBUGOPT(CompressDebugSections, llvm::DebugCompressionType, 2,
+                     llvm::DebugCompressionType::None, Benign)
+DEBUGOPT(Dwarf64, 1, 0, Affecting) ///< -gdwarf64.
+DEBUGOPT(EnableDIPreservationVerify, 1, 0, Benign) ///< Enable di preservation
+                                                   ///< verify each (it means
+                                                   ///< check the original 
debug
+                                                   ///< info metadata
+                                                   ///< preservation).
+DEBUGOPT(ForceDwarfFrameSection , 1, 0, Benign) ///< Set when 
-fforce-dwarf-frame
+                                                ///< is enabled.
 
 ///< Set when -femit-dwarf-unwind is passed.
-BENIGN_ENUM_DEBUGOPT(EmitDwarfUnwind, llvm::EmitDwarfUnwindType, 2,
-                     llvm::EmitDwarfUnwindType::Default)
+ENUM_DEBUGOPT(EmitDwarfUnwind, llvm::EmitDwarfUnwindType, 2,
+              llvm::EmitDwarfUnwindType::Default, Benign)
 
-BENIGN_DEBUGOPT(NoDwarfDirectoryAsm , 1, 0) ///< Set when 
-fno-dwarf-directory-asm
-                                            ///< is enabled.
+DEBUGOPT(NoDwarfDirectoryAsm , 1, 0, Benign) ///< Set when 
-fno-dwarf-directory-asm
+                                             ///< is enabled.
 
-BENIGN_DEBUGOPT(NoInlineLineTables, 1, 0) ///< Whether debug info should 
contain
-                                          ///< inline line tables.
+DEBUGOPT(NoInlineLineTables, 1, 0, Benign) ///< Whether debug info should 
contain
+                                           ///< inline line tables.
 
-DEBUGOPT(DebugStrictDwarf, 1, 1) ///< Whether or not to use strict DWARF info.
-DEBUGOPT(DebugOmitUnreferencedMethods, 1, 0) ///< Omit unreferenced member
-                                            ///< functions in type debug info.
+DEBUGOPT(DebugStrictDwarf, 1, 1, Affecting) ///< Whether or not to use strict 
DWARF info.
+DEBUGOPT(DebugOmitUnreferencedMethods, 1, 0, Affecting) ///< Omit unreferenced 
member
+                                                        ///< functions in type 
debug info.
 
 /// Control the Assignment Tracking debug info feature.
-BENIGN_ENUM_DEBUGOPT(AssignmentTrackingMode, AssignmentTrackingOpts, 2,
-                     AssignmentTrackingOpts::Disabled)
+ENUM_DEBUGOPT(AssignmentTrackingMode, AssignmentTrackingOpts, 2,
+              AssignmentTrackingOpts::Disabled, Benign)
 
 /// Whether or not to use Key Instructions to determine breakpoint locations.
-BENIGN_DEBUGOPT(DebugKeyInstructions, 1, 0)
+DEBUGOPT(DebugKeyInstructions, 1, 0, Benign)
 
-DEBUGOPT(DebugColumnInfo, 1, 0) ///< Whether or not to use column information
-                                ///< in debug info.
+DEBUGOPT(DebugColumnInfo, 1, 0, Affecting) ///< Whether or not to use column 
information
+                                           ///< in debug info.
 
-DEBUGOPT(DebugTypeExtRefs, 1, 0) ///< Whether or not debug info should contain
-                                 ///< external references to a PCH or module.
+DEBUGOPT(DebugTypeExtRefs, 1, 0, Affecting) ///< Whether or not debug info 
should contain
+                                            ///< external references to a PCH 
or module.
 
-DEBUGOPT(DebugExplicitImport, 1, 0)  ///< Whether or not debug info should
-                                     ///< contain explicit imports for
-                                     ///< anonymous namespaces
+DEBUGOPT(DebugExplicitImport, 1, 0, Affecting)  ///< Whether or not debug info 
should
+                                                ///< contain explicit imports 
for
+                                                ///< anonymous namespaces
 
 /// Set debug info source file hashing algorithm.
-ENUM_DEBUGOPT(DebugSrcHash, DebugSrcHashKind, 2, DSH_MD5)
-
-DEBUGOPT(SplitDwarfInlining, 1, 1) ///< Whether to include inlining info in the
-                                   ///< skeleton CU to allow for symbolication
-                                   ///< of inline stack frames without .dwo 
files.
-DEBUGOPT(DebugFwdTemplateParams, 1, 0) ///< Whether to emit complete
-                                       ///< template parameter descriptions in
-                                       ///< forward declarations (versus just
-                                       ///< including them in the name).
+ENUM_DEBUGOPT(DebugSrcHash, DebugSrcHashKind, 2, DSH_MD5, Affecting)
+
+DEBUGOPT(SplitDwarfInlining, 1, 1, Affecting) ///< Whether to include inlining 
info in the
+                                              ///< skeleton CU to allow for 
symbolication
+                                              ///< of inline stack frames 
without .dwo files.
+DEBUGOPT(DebugFwdTemplateParams, 1, 0, Affecting) ///< Whether to emit complete
+                                                  ///< template parameter 
descriptions in
+                                                  ///< forward declarations 
(versus just
+                                                  ///< including them in the 
name).
 ENUM_DEBUGOPT(DebugSimpleTemplateNames,
               llvm::codegenoptions::DebugTemplateNamesKind, 2,
-              llvm::codegenoptions::DebugTemplateNamesKind::Full)
+              llvm::codegenoptions::DebugTemplateNamesKind::Full, Affecting)
               ///< Whether to emit template parameters in the textual names of
               ///< template specializations.
-                         ///< Implies DebugFwdTemplateNames to allow decorated 
names to be
-                         ///< reconstructed when needed.
+              ///< Implies DebugFwdTemplateNames to allow decorated names to be
+              ///< reconstructed when needed.
 
 /// The kind of generated debug info.
 ENUM_DEBUGOPT(DebugInfo, llvm::codegenoptions::DebugInfoKind, 4,
-              llvm::codegenoptions::NoDebugInfo)
+              llvm::codegenoptions::NoDebugInfo, Affecting)
 
 /// Whether to generate macro debug info.
-DEBUGOPT(MacroDebugInfo, 1, 0)
+DEBUGOPT(MacroDebugInfo, 1, 0, Affecting)
 
 /// Tune the debug info for this debugger.
 ENUM_DEBUGOPT(DebuggerTuning, llvm::DebuggerKind, 3,
-                llvm::DebuggerKind::Default)
+              llvm::DebuggerKind::Default, Affecting)
 
 /// Dwarf version. Version zero indicates to LLVM that no DWARF should be
 /// emitted.
-VALUE_DEBUGOPT(DwarfVersion, 3, 0)
+VALUE_DEBUGOPT(DwarfVersion, 3, 0, Affecting)
 
 /// Whether we should emit CodeView debug information. It's possible to emit
 /// CodeView and DWARF into the same object.
-DEBUGOPT(EmitCodeView, 1, 0)
+DEBUGOPT(EmitCodeView, 1, 0, Affecting)
 
 /// Whether to emit the .debug$H section containing hashes of CodeView types.
-DEBUGOPT(CodeViewGHash, 1, 0)
+DEBUGOPT(CodeViewGHash, 1, 0, Affecting)
 
 /// Whether to emit the compiler path and command line into the CodeView debug 
information.
-DEBUGOPT(CodeViewCommandLine, 1, 0)
+DEBUGOPT(CodeViewCommandLine, 1, 0, Affecting)
 
 /// Whether emit extra debug info for sample pgo profile collection.
-DEBUGOPT(DebugInfoForProfiling, 1, 0)
+DEBUGOPT(DebugInfoForProfiling, 1, 0, Affecting)
 
 /// Whether to emit DW_TAG_template_alias for template aliases.
-DEBUGOPT(DebugTemplateAlias, 1, 0)
+DEBUGOPT(DebugTemplateAlias, 1, 0, Affecting)
 
 /// Whether to emit .debug_gnu_pubnames section instead of .debug_pubnames.
-DEBUGOPT(DebugNameTable, 2, 0)
+DEBUGOPT(DebugNameTable, 2, 0, Affecting)
 
 /// Whether to use DWARF base address specifiers in .debug_ranges.
-DEBUGOPT(DebugRangesBaseAddress, 1, 0)
+DEBUGOPT(DebugRangesBaseAddress, 1, 0, Affecting)
 
 /// Whether to embed source in DWARF debug line section.
-DEBUGOPT(EmbedSource, 1, 0)
+DEBUGOPT(EmbedSource, 1, 0, Affecting)
 
 #undef DEBUGOPT
 #undef ENUM_DEBUGOPT
 #undef VALUE_DEBUGOPT
-#undef BENIGN_DEBUGOPT
-#undef BENIGN_ENUM_DEBUGOPT
-#undef BENIGN_VALUE_DEBUGOPT

diff  --git a/clang/lib/Basic/CodeGenOptions.cpp 
b/clang/lib/Basic/CodeGenOptions.cpp
index 1f899dee48dbd..9a2aa9beb9e0d 100644
--- a/clang/lib/Basic/CodeGenOptions.cpp
+++ b/clang/lib/Basic/CodeGenOptions.cpp
@@ -11,43 +11,39 @@
 namespace clang {
 
 CodeGenOptions::CodeGenOptions() {
-#define CODEGENOPT(Name, Bits, Default) Name = Default;
-#define ENUM_CODEGENOPT(Name, Type, Bits, Default) set##Name(Default);
+#define CODEGENOPT(Name, Bits, Default, Compatibility) Name = Default;
+#define ENUM_CODEGENOPT(Name, Type, Bits, Default, Compatibility)              
\
+  set##Name(Default);
 #include "clang/Basic/CodeGenOptions.def"
 
   RelocationModel = llvm::Reloc::PIC_;
 }
 
 void CodeGenOptions::resetNonModularOptions(StringRef ModuleFormat) {
-  // First reset all CodeGen options only. The Debug options are handled later.
-#define DEBUGOPT(Name, Bits, Default)
-#define VALUE_DEBUGOPT(Name, Bits, Default)
-#define ENUM_DEBUGOPT(Name, Type, Bits, Default)
-#define CODEGENOPT(Name, Bits, Default) Name = Default;
-#define ENUM_CODEGENOPT(Name, Type, Bits, Default) set##Name(Default);
-// Do not reset AST affecting code generation options.
-#define AFFECTING_VALUE_CODEGENOPT(Name, Bits, Default)
+  // FIXME: Replace with C++20 `using enum CodeGenOptions::CompatibilityKind`.
+  using CK = CompatibilityKind;
+
+  // First reset benign codegen and debug options.
+#define CODEGENOPT(Name, Bits, Default, Compatibility)                         
\
+  if constexpr (CK::Compatibility == CK::Benign)                               
\
+    Name = Default;
+#define ENUM_CODEGENOPT(Name, Type, Bits, Default, Compatibility)              
\
+  if constexpr (CK::Compatibility == CK::Benign)                               
\
+    set##Name(Default);
 #include "clang/Basic/CodeGenOptions.def"
 
-  // Next reset all debug options that can always be reset, because they never
-  // affect the PCM.
-#define DEBUGOPT(Name, Bits, Default)
-#define VALUE_DEBUGOPT(Name, Bits, Default)
-#define ENUM_DEBUGOPT(Name, Type, Bits, Default)
-#define BENIGN_DEBUGOPT(Name, Bits, Default) Name = Default;
-#define BENIGN_VALUE_DEBUGOPT(Name, Bits, Default) Name = Default;
-#define BENIGN_ENUM_DEBUGOPT(Name, Type, Bits, Default) set##Name(Default);
-#include "clang/Basic/DebugOptions.def"
-
   // Conditionally reset debug options that only matter when the debug info is
   // emitted into the PCM (-gmodules).
   if (ModuleFormat == "raw" && !DebugTypeExtRefs) {
-#define DEBUGOPT(Name, Bits, Default) Name = Default;
-#define VALUE_DEBUGOPT(Name, Bits, Default) Name = Default;
-#define ENUM_DEBUGOPT(Name, Type, Bits, Default) set##Name(Default);
-#define BENIGN_DEBUGOPT(Name, Bits, Default)
-#define BENIGN_VALUE_DEBUGOPT(Name, Bits, Default)
-#define BENIGN_ENUM_DEBUGOPT(Name, Type, Bits, Default)
+#define DEBUGOPT(Name, Bits, Default, Compatibility)                           
\
+  if constexpr (CK::Compatibility == CK::Affecting)                            
\
+    Name = Default;
+#define VALUE_DEBUGOPT(Name, Bits, Default, Compatibility)                     
\
+  if constexpr (CK::Compatibility == CK::Affecting)                            
\
+    Name = Default;
+#define ENUM_DEBUGOPT(Name, Type, Bits, Default, Compatibility)                
\
+  if constexpr (CK::Compatibility == CK::Affecting)                            
\
+    set##Name(Default);
 #include "clang/Basic/DebugOptions.def"
   }
 

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index e233821fa5d2a..b9f75796ecc16 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -5308,13 +5308,17 @@ std::string CompilerInvocation::getModuleHash() const {
 
   // Extend the signature with the affecting debug options.
   if (getHeaderSearchOpts().ModuleFormat == "obj") {
-#define DEBUGOPT(Name, Bits, Default) HBuilder.add(CodeGenOpts->Name);
-#define VALUE_DEBUGOPT(Name, Bits, Default) HBuilder.add(CodeGenOpts->Name);
-#define ENUM_DEBUGOPT(Name, Type, Bits, Default)                               
\
-  HBuilder.add(static_cast<unsigned>(CodeGenOpts->get##Name()));
-#define BENIGN_DEBUGOPT(Name, Bits, Default)
-#define BENIGN_VALUE_DEBUGOPT(Name, Bits, Default)
-#define BENIGN_ENUM_DEBUGOPT(Name, Type, Bits, Default)
+    // FIXME: Replace with C++20 `using enum 
CodeGenOptions::CompatibilityKind`.
+    using CK = CodeGenOptions::CompatibilityKind;
+#define DEBUGOPT(Name, Bits, Default, Compatibility)                           
\
+  if constexpr (CK::Compatibility == CK::Affecting)                            
\
+    HBuilder.add(CodeGenOpts->Name);
+#define VALUE_DEBUGOPT(Name, Bits, Default, Compatibility)                     
\
+  if constexpr (CK::Compatibility == CK::Affecting)                            
\
+    HBuilder.add(CodeGenOpts->Name);
+#define ENUM_DEBUGOPT(Name, Type, Bits, Default, Compatibility)                
\
+  if constexpr (CK::Compatibility == CK::Affecting)                            
\
+    HBuilder.add(static_cast<unsigned>(CodeGenOpts->get##Name()));
 #include "clang/Basic/DebugOptions.def"
   }
 


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to