Index: cfe/trunk/include/clang/Driver/ToolChain.h =================================================================== --- cfe/trunk/include/clang/Driver/ToolChain.h +++ cfe/trunk/include/clang/Driver/ToolChain.h @@ -315,7 +315,7 @@ /// IsUnwindTablesDefault - Does this tool chain use -funwind-tables /// by default. - virtual bool IsUnwindTablesDefault() const; + virtual bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const; /// \brief Test whether this toolchain defaults to PIC. virtual bool isPICDefault() const = 0; Index: cfe/trunk/lib/Driver/ToolChain.cpp =================================================================== --- cfe/trunk/lib/Driver/ToolChain.cpp +++ cfe/trunk/lib/Driver/ToolChain.cpp @@ -217,7 +217,7 @@ } } -bool ToolChain::IsUnwindTablesDefault() const { +bool ToolChain::IsUnwindTablesDefault(const ArgList &Args) const { return false; } Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp =================================================================== --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp @@ -2599,7 +2599,7 @@ bool AsynchronousUnwindTables = Args.hasFlag(options::OPT_fasynchronous_unwind_tables, options::OPT_fno_asynchronous_unwind_tables, - (getToolChain().IsUnwindTablesDefault() || + (getToolChain().IsUnwindTablesDefault(Args) || getToolChain().getSanitizerArgs().needsUnwindTables()) && !KernelOrKext); if (Args.hasFlag(options::OPT_funwind_tables, options::OPT_fno_unwind_tables, Index: cfe/trunk/lib/Driver/ToolChains/CrossWindows.h =================================================================== --- cfe/trunk/lib/Driver/ToolChains/CrossWindows.h +++ cfe/trunk/lib/Driver/ToolChains/CrossWindows.h @@ -56,7 +56,7 @@ const llvm::opt::ArgList &Args); bool IsIntegratedAssemblerDefault() const override { return true; } - bool IsUnwindTablesDefault() const override; + bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override; bool isPICDefault() const override; bool isPIEDefault() const override; bool isPICDefaultForced() const override; Index: cfe/trunk/lib/Driver/ToolChains/CrossWindows.cpp =================================================================== --- cfe/trunk/lib/Driver/ToolChains/CrossWindows.cpp +++ cfe/trunk/lib/Driver/ToolChains/CrossWindows.cpp @@ -213,7 +213,7 @@ } } -bool CrossWindowsToolChain::IsUnwindTablesDefault() const { +bool CrossWindowsToolChain::IsUnwindTablesDefault(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; Index: cfe/trunk/lib/Driver/ToolChains/Darwin.h =================================================================== --- cfe/trunk/lib/Driver/ToolChains/Darwin.h +++ cfe/trunk/lib/Driver/ToolChains/Darwin.h @@ -216,7 +216,7 @@ bool UseObjCMixedDispatch() const override { return true; } - bool IsUnwindTablesDefault() const override; + bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override; RuntimeLibType GetDefaultRuntimeLibType() const override { return ToolChain::RLT_CompilerRT; Index: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp =================================================================== --- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp +++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp @@ -1844,8 +1844,8 @@ return DAL; } -bool MachO::IsUnwindTablesDefault() const { - return getArch() == llvm::Triple::x86_64; +bool MachO::IsUnwindTablesDefault(const ArgList &Args) const { + return !UseSjLjExceptions(Args); } bool MachO::UseDwarfDebugFlags() const { Index: cfe/trunk/lib/Driver/ToolChains/Gnu.h =================================================================== --- cfe/trunk/lib/Driver/ToolChains/Gnu.h +++ cfe/trunk/lib/Driver/ToolChains/Gnu.h @@ -284,7 +284,7 @@ void printVerboseInfo(raw_ostream &OS) const override; - bool IsUnwindTablesDefault() const override; + bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override; bool isPICDefault() const override; bool isPIEDefault() const override; bool isPICDefaultForced() const override; Index: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp =================================================================== --- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp +++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp @@ -2300,7 +2300,7 @@ CudaInstallation.print(OS); } -bool Generic_GCC::IsUnwindTablesDefault() const { +bool Generic_GCC::IsUnwindTablesDefault(const ArgList &Args) const { return getArch() == llvm::Triple::x86_64; } Index: cfe/trunk/lib/Driver/ToolChains/MSVC.h =================================================================== --- cfe/trunk/lib/Driver/ToolChains/MSVC.h +++ cfe/trunk/lib/Driver/ToolChains/MSVC.h @@ -73,7 +73,7 @@ Action::OffloadKind DeviceOffloadKind) const override; bool IsIntegratedAssemblerDefault() const override; - bool IsUnwindTablesDefault() const override; + bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override; bool isPICDefault() const override; bool isPIEDefault() const override; bool isPICDefaultForced() const override; Index: cfe/trunk/lib/Driver/ToolChains/MSVC.cpp =================================================================== --- cfe/trunk/lib/Driver/ToolChains/MSVC.cpp +++ cfe/trunk/lib/Driver/ToolChains/MSVC.cpp @@ -699,7 +699,7 @@ return true; } -bool MSVCToolChain::IsUnwindTablesDefault() const { +bool MSVCToolChain::IsUnwindTablesDefault(const ArgList &Args) const { // Emit unwind tables by default on Win64. All non-x86_32 Windows platforms // such as ARM and PPC actually require unwind tables, but LLVM doesn't know // how to generate them yet. Index: cfe/trunk/lib/Driver/ToolChains/MinGW.h =================================================================== --- cfe/trunk/lib/Driver/ToolChains/MinGW.h +++ cfe/trunk/lib/Driver/ToolChains/MinGW.h @@ -60,7 +60,7 @@ const llvm::opt::ArgList &Args); bool IsIntegratedAssemblerDefault() const override; - bool IsUnwindTablesDefault() const override; + bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override; bool isPICDefault() const override; bool isPIEDefault() const override; bool isPICDefaultForced() const override; Index: cfe/trunk/lib/Driver/ToolChains/MinGW.cpp =================================================================== --- cfe/trunk/lib/Driver/ToolChains/MinGW.cpp +++ cfe/trunk/lib/Driver/ToolChains/MinGW.cpp @@ -346,7 +346,7 @@ return new tools::MinGW::Linker(*this); } -bool toolchains::MinGW::IsUnwindTablesDefault() const { +bool toolchains::MinGW::IsUnwindTablesDefault(const ArgList &Args) const { return getArch() == llvm::Triple::x86_64; } Index: cfe/trunk/lib/Driver/ToolChains/NetBSD.h =================================================================== --- cfe/trunk/lib/Driver/ToolChains/NetBSD.h +++ cfe/trunk/lib/Driver/ToolChains/NetBSD.h @@ -65,7 +65,10 @@ const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override; - bool IsUnwindTablesDefault() const override { return true; } + bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override { + return true; + } + SanitizerMask getSupportedSanitizers() const override; protected: Index: cfe/trunk/test/Driver/clang-translation.c =================================================================== --- cfe/trunk/test/Driver/clang-translation.c +++ cfe/trunk/test/Driver/clang-translation.c @@ -69,6 +69,14 @@ // ARMV7_HARDFLOAT-NOT: "-msoft-float" // ARMV7_HARDFLOAT: "-x" "c" +// RUN: %clang -target arm64-apple-ios10 -### -S %s -arch arm64 2>&1 | \ +// RUN: FileCheck -check-prefix=ARM64-APPLE %s +// ARM64-APPLE: -munwind-table + +// RUN: %clang -target armv7k-apple-watchos4.0 -### -S %s -arch armv7k 2>&1 | \ +// RUN: FileCheck -check-prefix=ARMV7K-APPLE %s +// ARMV7K-APPLE: -munwind-table + // RUN: %clang -target arm-linux -### -S %s -march=armv5e 2>&1 | \ // RUN: FileCheck -check-prefix=ARMV5E %s // ARMV5E: clang