Skip to content

Commit

Permalink
Revert "[clang][modules] Reset codegen options. (#74006)"
Browse files Browse the repository at this point in the history
This reverts commit fef1854.
  • Loading branch information
ributzka committed Dec 4, 2023
1 parent d9570ba commit 1157bee
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 260 deletions.
88 changes: 85 additions & 3 deletions clang/include/clang/Basic/CodeGenOptions.def
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ CODEGENOPT(Name, Bits, Default)
#endif

CODEGENOPT(DisableIntegratedAS, 1, 0) ///< -no-integrated-as
ENUM_CODEGENOPT(CompressDebugSections, llvm::DebugCompressionType, 2,
llvm::DebugCompressionType::None)
CODEGENOPT(RelaxELFRelocations, 1, 1) ///< -Wa,-mrelax-relocations={yes,no}
CODEGENOPT(AsmVerbose , 1, 0) ///< -dA, -fverbose-asm.
CODEGENOPT(Dwarf64 , 1, 0) ///< -gdwarf64.
CODEGENOPT(Dwarf32 , 1, 1) ///< -gdwarf32.
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.
Expand Down Expand Up @@ -69,6 +73,10 @@ CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug information for the new
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(EnableDIPreservationVerify, 1, 0) ///< Enable di preservation verify
///< each (it means check
///< the original debug info
///< metadata preservation).
CODEGENOPT(IndirectTlsSegRefs, 1, 0) ///< Set when -mno-tls-direct-seg-refs
///< is specified.
CODEGENOPT(DisableTailCalls , 1, 0) ///< Do not emit tail calls.
Expand Down Expand Up @@ -105,10 +113,16 @@ CODEGENOPT(IndirectBranchCSPrefix, 1, 0) ///< if -mindirect-branch-cs-prefix
CODEGENOPT(XRayInstrumentFunctions , 1, 0) ///< Set when -fxray-instrument is
///< enabled.
CODEGENOPT(StackSizeSection , 1, 0) ///< Set when -fstack-size-section is enabled.
CODEGENOPT(ForceDwarfFrameSection , 1, 0) ///< Set when -fforce-dwarf-frame is
///< enabled.

///< Set when -femit-compact-unwind-non-canonical is enabled.
CODEGENOPT(EmitCompactUnwindNonCanonical, 1, 0)

///< Set when -femit-dwarf-unwind is passed.
ENUM_CODEGENOPT(EmitDwarfUnwind, llvm::EmitDwarfUnwindType, 2,
llvm::EmitDwarfUnwindType::Default)

///< Set when -fxray-always-emit-customevents is enabled.
CODEGENOPT(XRayAlwaysEmitCustomEvents , 1, 0)

Expand Down Expand Up @@ -164,13 +178,17 @@ CODEGENOPT(IncrementalLinkerCompatible, 1, 0) ///< Emit an object file which can
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(NoDwarfDirectoryAsm , 1, 0) ///< Set when -fno-dwarf-directory-asm is
///< enabled.
CODEGENOPT(NoExecStack , 1, 0) ///< Set when -Wa,--noexecstack 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(NoInlineLineTables, 1, 0) ///< Whether debug info should contain
///< inline line tables.
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.
Expand Down Expand Up @@ -323,6 +341,37 @@ 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(DebugStrictDwarf, 1, 1) ///< Whether or not to use strict DWARF info.

/// Control the Assignment Tracking debug info feature.
ENUM_CODEGENOPT(AssignmentTrackingMode, AssignmentTrackingOpts, 2, AssignmentTrackingOpts::Disabled)

CODEGENOPT(DebugColumnInfo, 1, 0) ///< Whether or not to use column information
///< in debug info.

CODEGENOPT(DebugTypeExtRefs, 1, 0) ///< Whether or not debug info should contain
///< external references to a PCH or module.

CODEGENOPT(DebugExplicitImport, 1, 0) ///< Whether or not debug info should
///< contain explicit imports for
///< anonymous namespaces

/// Set debug info source file hashing algorithm.
ENUM_CODEGENOPT(DebugSrcHash, DebugSrcHashKind, 2, DSH_MD5)

CODEGENOPT(SplitDwarfInlining, 1, 1) ///< Whether to include inlining info in the
///< skeleton CU to allow for symbolication
///< of inline stack frames without .dwo files.
CODEGENOPT(DebugFwdTemplateParams, 1, 0) ///< Whether to emit complete
///< template parameter descriptions in
///< forward declarations (versus just
///< including them in the name).
ENUM_CODEGENOPT(DebugSimpleTemplateNames, llvm::codegenoptions::DebugTemplateNamesKind, 2, llvm::codegenoptions::DebugTemplateNamesKind::Full) ///< Whether to emit template parameters
///< in the textual names of template
///< specializations.
///< Implies DebugFwdTemplateNames to
///< allow decorated names to be
///< reconstructed when needed.
CODEGENOPT(EmitLLVMUseLists, 1, 0) ///< Control whether to serialize use-lists.

CODEGENOPT(WholeProgramVTables, 1, 0) ///< Whether to apply whole-program
Expand All @@ -346,6 +395,30 @@ VALUE_CODEGENOPT(SmallDataLimit, 32, 0)
/// The lower bound for a buffer to be considered for stack protection.
VALUE_CODEGENOPT(SSPBufferSize, 32, 0)

/// The kind of generated debug info.
ENUM_CODEGENOPT(DebugInfo, llvm::codegenoptions::DebugInfoKind, 4, llvm::codegenoptions::NoDebugInfo)

/// Whether to generate macro debug info.
CODEGENOPT(MacroDebugInfo, 1, 0)

/// Tune the debug info for this debugger.
ENUM_CODEGENOPT(DebuggerTuning, llvm::DebuggerKind, 3,
llvm::DebuggerKind::Default)

/// Dwarf version. Version zero indicates to LLVM that no DWARF should be
/// emitted.
VALUE_CODEGENOPT(DwarfVersion, 3, 0)

/// Whether we should emit CodeView debug information. It's possible to emit
/// CodeView and DWARF into the same object.
CODEGENOPT(EmitCodeView, 1, 0)

/// Whether to emit the .debug$H section containing hashes of CodeView types.
CODEGENOPT(CodeViewGHash, 1, 0)

/// Whether to emit the compiler path and command line into the CodeView debug information.
CODEGENOPT(CodeViewCommandLine, 1, 0)

/// The kind of inlining to perform.
ENUM_CODEGENOPT(Inlining, InliningMethod, 2, NormalInlining)

Expand Down Expand Up @@ -378,14 +451,26 @@ CODEGENOPT(DirectAccessExternalData, 1, 0)
/// paths that reach the end of a function without executing a required return.
CODEGENOPT(StrictReturn, 1, 1)

/// Whether emit extra debug info for sample pgo profile collection.
CODEGENOPT(DebugInfoForProfiling, 1, 0)

/// Whether emit pseudo probes for sample pgo profile collection.
CODEGENOPT(PseudoProbeForProfiling, 1, 0)

/// Whether 3-component vector type is preserved.
CODEGENOPT(PreserveVec3Type, 1, 0)

/// Whether to emit .debug_gnu_pubnames section instead of .debug_pubnames.
CODEGENOPT(DebugNameTable, 2, 0)

/// Whether to use DWARF base address specifiers in .debug_ranges.
CODEGENOPT(DebugRangesBaseAddress, 1, 0)

CODEGENOPT(NoPLT, 1, 0)

/// Whether to embed source in DWARF debug line section.
CODEGENOPT(EmbedSource, 1, 0)

/// Whether to emit all vtables
CODEGENOPT(ForceEmitVTables, 1, 0)

Expand Down Expand Up @@ -430,9 +515,6 @@ ENUM_CODEGENOPT(ZeroCallUsedRegs, llvm::ZeroCallUsedRegs::ZeroCallUsedRegsKind,
/// non-deleting destructors. (No effect on Microsoft ABI.)
CODEGENOPT(CtorDtorReturnThis, 1, 0)

/// FIXME: Make DebugOptions its own top-level .def file.
#include "DebugOptions.def"

#undef CODEGENOPT
#undef ENUM_CODEGENOPT
#undef VALUE_CODEGENOPT
4 changes: 0 additions & 4 deletions clang/include/clang/Basic/CodeGenOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -530,10 +530,6 @@ class CodeGenOptions : public CodeGenOptionsBase {
return SanitizeBinaryMetadataCovered || SanitizeBinaryMetadataAtomics ||
SanitizeBinaryMetadataUAR;
}

/// Reset all of the options that are not considered when building a
/// module.
void resetNonModularOptions(StringRef ModuleFormat);
};

} // end namespace clang
Expand Down
146 changes: 0 additions & 146 deletions clang/include/clang/Basic/DebugOptions.def

This file was deleted.

1 change: 0 additions & 1 deletion clang/include/module.modulemap
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ module Clang_Basic {
textual header "clang/Basic/BuiltinsX86_64.def"
textual header "clang/Basic/BuiltinsXCore.def"
textual header "clang/Basic/CodeGenOptions.def"
textual header "clang/Basic/DebugOptions.def"
textual header "clang/Basic/DiagnosticOptions.def"
textual header "clang/Basic/Features.def"
textual header "clang/Basic/FPOptions.def"
Expand Down
35 changes: 0 additions & 35 deletions clang/lib/Basic/CodeGenOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,39 +20,4 @@ CodeGenOptions::CodeGenOptions() {
memcpy(CoverageVersion, "408*", 4);
}

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);
#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") {
#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)
#include "clang/Basic/DebugOptions.def"
}

RelocationModel = llvm::Reloc::PIC_;
memcpy(CoverageVersion, "408*", 4);
}

} // end namespace clang
13 changes: 0 additions & 13 deletions clang/lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4787,18 +4787,6 @@ std::string CompilerInvocation::getModuleHash() const {
if (getCodeGenOpts().DebugTypeExtRefs)
HBuilder.addRange(getCodeGenOpts().DebugPrefixMap);

// 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)
#include "clang/Basic/DebugOptions.def"
}

// Extend the signature with the enabled sanitizers, if at least one is
// enabled. Sanitizers which cannot affect AST generation aren't hashed.
SanitizerSet SanHash = getLangOpts().Sanitize;
Expand Down Expand Up @@ -4845,7 +4833,6 @@ std::vector<std::string> CompilerInvocationBase::getCC1CommandLine() const {
void CompilerInvocation::resetNonModularOptions() {
getLangOpts().resetNonModularOptions();
getPreprocessorOpts().resetNonModularOptions();
getCodeGenOpts().resetNonModularOptions(getHeaderSearchOpts().ModuleFormat);
}

void CompilerInvocation::clearImplicitModuleBuildOptions() {
Expand Down
Loading

0 comments on commit 1157bee

Please sign in to comment.