UNW_Libgcc
};
+ enum class UnwindTableLevel {
+ None,
+ Synchronous,
+ Asynchronous,
+ };
+
enum RTTIMode {
RM_Enabled,
RM_Disabled,
/// Returns true if gcov instrumentation (-fprofile-arcs or --coverage) is on.
static bool needsGCovInstrumentation(const llvm::opt::ArgList &Args);
- /// IsUnwindTablesDefault - Does this tool chain use -funwind-tables
- /// by default.
- virtual bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const;
+ /// How detailed should the unwind tables be by default.
+ virtual UnwindTableLevel
+ getDefaultUnwindTableLevel(const llvm::opt::ArgList &Args) const;
/// Test whether this toolchain supports outline atomics by default.
virtual bool
return Input.getFilename();
}
-bool ToolChain::IsUnwindTablesDefault(const ArgList &Args) const {
- return false;
+ToolChain::UnwindTableLevel
+ToolChain::getDefaultUnwindTableLevel(const ArgList &Args) const {
+ return UnwindTableLevel::None;
}
Tool *ToolChain::getClang() const {
// -fasynchronous-unwind-tables and -fnon-call-exceptions interact in more
// complicated ways.
auto SanitizeArgs = TC.getSanitizerArgs(Args);
- bool AsyncUnwindTables = Args.hasFlag(
- options::OPT_fasynchronous_unwind_tables,
- options::OPT_fno_asynchronous_unwind_tables,
- (TC.IsUnwindTablesDefault(Args) || SanitizeArgs.needsUnwindTables()) &&
- !Freestanding);
- bool UnwindTables = Args.hasFlag(options::OPT_funwind_tables,
- options::OPT_fno_unwind_tables, false);
- if (AsyncUnwindTables)
- CmdArgs.push_back("-funwind-tables=2");
- else if (UnwindTables)
+ auto UnwindTables = TC.getDefaultUnwindTableLevel(Args);
+
+ if (Args.hasFlag(options::OPT_fasynchronous_unwind_tables,
+ options::OPT_fno_asynchronous_unwind_tables,
+ SanitizeArgs.needsUnwindTables()) &&
+ !Freestanding)
+ UnwindTables = ToolChain::UnwindTableLevel::Asynchronous;
+ else if (Args.hasFlag(options::OPT_funwind_tables,
+ options::OPT_fno_unwind_tables, false))
+ UnwindTables = ToolChain::UnwindTableLevel::Synchronous;
+ else if (Args.hasFlag(options::OPT_fno_unwind_tables,
+ options::OPT_fno_asynchronous_unwind_tables,
+ options::OPT_funwind_tables, false) || Freestanding)
+ UnwindTables = ToolChain::UnwindTableLevel::None;
+
+
+ if (UnwindTables == ToolChain::UnwindTableLevel::Synchronous)
CmdArgs.push_back("-funwind-tables=1");
+ else if (UnwindTables == ToolChain::UnwindTableLevel::Asynchronous)
+ CmdArgs.push_back("-funwind-tables=2");
// Prepare `-aux-target-cpu` and `-aux-target-feature` unless
// `--gpu-use-aux-triple-only` is specified.
CmdArgs.push_back("-faddrsig");
if ((Triple.isOSBinFormatELF() || Triple.isOSBinFormatMachO()) &&
- (EH || AsyncUnwindTables || UnwindTables ||
+ (EH || UnwindTables != ToolChain::UnwindTableLevel::None ||
DebugInfoKind != codegenoptions::NoDebugInfo))
CmdArgs.push_back("-D__GCC_HAVE_DWARF2_CFI_ASM=1");
const llvm::opt::ArgList &Args)
: Generic_GCC(D, T, Args) {}
-bool CrossWindowsToolChain::IsUnwindTablesDefault(const ArgList &Args) const {
+ToolChain::UnwindTableLevel
+CrossWindowsToolChain::getDefaultUnwindTableLevel(const ArgList &Args) const {
// FIXME: all non-x86 targets need unwind tables, however, LLVM currently does
// not know how to emit them.
- return getArch() == llvm::Triple::x86_64;
+ return getArch() == llvm::Triple::x86_64 ? UnwindTableLevel::Asynchronous : UnwindTableLevel::None;
}
bool CrossWindowsToolChain::isPICDefault() const {
const llvm::opt::ArgList &Args);
bool IsIntegratedAssemblerDefault() const override { return true; }
- bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override;
+ UnwindTableLevel
+ getDefaultUnwindTableLevel(const llvm::opt::ArgList &Args) const override;
bool isPICDefault() const override;
bool isPIEDefault(const llvm::opt::ArgList &Args) const override;
bool isPICDefaultForced() const override;
return DAL;
}
-bool MachO::IsUnwindTablesDefault(const ArgList &Args) const {
+ToolChain::UnwindTableLevel MachO::getDefaultUnwindTableLevel(const ArgList &Args) const {
// Unwind tables are not emitted if -fno-exceptions is supplied (except when
// targeting x86_64).
- return getArch() == llvm::Triple::x86_64 ||
- (GetExceptionModel(Args) != llvm::ExceptionHandling::SjLj &&
- Args.hasFlag(options::OPT_fexceptions, options::OPT_fno_exceptions,
- true));
+ if (getArch() == llvm::Triple::x86_64 ||
+ (GetExceptionModel(Args) != llvm::ExceptionHandling::SjLj &&
+ Args.hasFlag(options::OPT_fexceptions, options::OPT_fno_exceptions,
+ true)))
+ return UnwindTableLevel::Asynchronous;
+
+ return UnwindTableLevel::None;
}
bool MachO::UseDwarfDebugFlags() const {
bool UseObjCMixedDispatch() const override { return true; }
- bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override;
+ UnwindTableLevel
+ getDefaultUnwindTableLevel(const llvm::opt::ArgList &Args) const override;
RuntimeLibType GetDefaultRuntimeLibType() const override {
return ToolChain::RLT_CompilerRT;
bool FreeBSD::HasNativeLLVMSupport() const { return true; }
-bool FreeBSD::IsUnwindTablesDefault(const ArgList &Args) const { return true; }
+ToolChain::UnwindTableLevel
+FreeBSD::getDefaultUnwindTableLevel(const ArgList &Args) const {
+ return UnwindTableLevel::Asynchronous;
+}
bool FreeBSD::isPIEDefault(const llvm::opt::ArgList &Args) const {
return getSanitizerArgs(Args).requiresPIE();
llvm::ExceptionHandling
GetExceptionModel(const llvm::opt::ArgList &Args) const override;
- bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override;
+ UnwindTableLevel
+ getDefaultUnwindTableLevel(const llvm::opt::ArgList &Args) const override;
bool isPIEDefault(const llvm::opt::ArgList &Args) const override;
SanitizerMask getSupportedSanitizers() const override;
unsigned GetDefaultDwarfVersion() const override;
CXXStdlibType GetDefaultCXXStdlibType() const override {
return ToolChain::CST_Libcxx;
}
- bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override {
- return true;
+ UnwindTableLevel
+ getDefaultUnwindTableLevel(const llvm::opt::ArgList &Args) const override {
+ return UnwindTableLevel::Asynchronous;
}
bool isPICDefault() const override { return false; }
bool isPIEDefault(const llvm::opt::ArgList &Args) const override {
RocmInstallation.print(OS);
}
-bool Generic_GCC::IsUnwindTablesDefault(const ArgList &Args) const {
+ToolChain::UnwindTableLevel
+Generic_GCC::getDefaultUnwindTableLevel(const ArgList &Args) const {
switch (getArch()) {
case llvm::Triple::aarch64:
case llvm::Triple::ppc:
case llvm::Triple::ppc64le:
case llvm::Triple::x86:
case llvm::Triple::x86_64:
- return true;
+ return UnwindTableLevel::Asynchronous;
default:
- return false;
+ return UnwindTableLevel::None;
}
}
void printVerboseInfo(raw_ostream &OS) const override;
- bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override;
+ UnwindTableLevel
+ getDefaultUnwindTableLevel(const llvm::opt::ArgList &Args) const override;
bool isPICDefault() const override;
bool isPIEDefault(const llvm::opt::ArgList &Args) const override;
bool isPICDefaultForced() const override;
return true;
}
-bool MSVCToolChain::IsUnwindTablesDefault(const ArgList &Args) const {
+ToolChain::UnwindTableLevel
+MSVCToolChain::getDefaultUnwindTableLevel(const ArgList &Args) const {
// Don't emit unwind tables by default for MachO targets.
if (getTriple().isOSBinFormatMachO())
- return false;
+ return UnwindTableLevel::None;
// All non-x86_32 Windows targets require unwind tables. However, LLVM
// doesn't know how to generate them for all targets, so only enable
// the ones that are actually implemented.
- return getArch() == llvm::Triple::x86_64 || getArch() == llvm::Triple::arm ||
- getArch() == llvm::Triple::thumb || getArch() == llvm::Triple::aarch64;
+ if (getArch() == llvm::Triple::x86_64 || getArch() == llvm::Triple::arm ||
+ getArch() == llvm::Triple::thumb || getArch() == llvm::Triple::aarch64)
+ return UnwindTableLevel::Asynchronous;
+
+ return UnwindTableLevel::None;
}
bool MSVCToolChain::isPICDefault() const {
Action::OffloadKind DeviceOffloadKind) const override;
bool IsIntegratedAssemblerDefault() const override;
- bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override;
+ UnwindTableLevel
+ getDefaultUnwindTableLevel(const llvm::opt::ArgList &Args) const override;
bool isPICDefault() const override;
bool isPIEDefault(const llvm::opt::ArgList &Args) const override;
bool isPICDefaultForced() const override;
return NativeLLVMSupport;
}
-bool toolchains::MinGW::IsUnwindTablesDefault(const ArgList &Args) const {
+ToolChain::UnwindTableLevel
+toolchains::MinGW::getDefaultUnwindTableLevel(const ArgList &Args) const {
Arg *ExceptionArg = Args.getLastArg(options::OPT_fsjlj_exceptions,
options::OPT_fseh_exceptions,
options::OPT_fdwarf_exceptions);
if (ExceptionArg &&
ExceptionArg->getOption().matches(options::OPT_fseh_exceptions))
- return true;
- return getArch() == llvm::Triple::x86_64 || getArch() == llvm::Triple::arm ||
- getArch() == llvm::Triple::thumb || getArch() == llvm::Triple::aarch64;
+ return UnwindTableLevel::Asynchronous;
+
+ if (getArch() == llvm::Triple::x86_64 || getArch() == llvm::Triple::arm ||
+ getArch() == llvm::Triple::thumb || getArch() == llvm::Triple::aarch64)
+ return UnwindTableLevel::Asynchronous;
+ return UnwindTableLevel::None;
}
bool toolchains::MinGW::isPICDefault() const {
bool HasNativeLLVMSupport() const override;
bool IsIntegratedAssemblerDefault() const override;
- bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override;
+ UnwindTableLevel
+ getDefaultUnwindTableLevel(const llvm::opt::ArgList &Args) const override;
bool isPICDefault() const override;
bool isPIEDefault(const llvm::opt::ArgList &Args) const override;
bool isPICDefaultForced() const override;
const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const override;
- bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override {
- return true;
+ UnwindTableLevel
+ getDefaultUnwindTableLevel(const llvm::opt::ArgList &Args) const override {
+ return UnwindTableLevel::Asynchronous;
}
llvm::ExceptionHandling GetExceptionModel(
bool OpenBSD::HasNativeLLVMSupport() const { return true; }
-bool OpenBSD::IsUnwindTablesDefault(const ArgList &Args) const {
- switch (getArch()) {
- case llvm::Triple::arm:
- return false;
- default:
- return true;
- }
+ToolChain::UnwindTableLevel
+OpenBSD::getDefaultUnwindTableLevel(const ArgList &Args) const {
+ switch (getArch()) {
+ case llvm::Triple::arm:
+ return UnwindTableLevel::None;
+ default:
+ return UnwindTableLevel::Asynchronous;
+ }
}
std::string getCompilerRT(const llvm::opt::ArgList &Args, StringRef Component,
FileType Type = ToolChain::FT_Static) const override;
- bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override;
+ UnwindTableLevel
+ getDefaultUnwindTableLevel(const llvm::opt::ArgList &Args) const override;
LangOptions::StackProtectorMode
GetDefaultStackProtectorLevel(bool KernelOrKext) const override {