r310006 - [Driver][Darwin] Pass -munwind-table when !UseSjLjExceptions.
Hans Wennborg via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 10 18:48:29 PDT 2017
r310677.
On Thu, Aug 10, 2017 at 5:30 PM, Akira Hatanaka <ahatanaka at apple.com> wrote:
> Can we merge this one to 5.0 too?
>
>> On Aug 3, 2017, at 4:55 PM, Akira Hatanaka via cfe-commits <cfe-commits at lists.llvm.org> wrote:
>>
>> Author: ahatanak
>> Date: Thu Aug 3 16:55:42 2017
>> New Revision: 310006
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=310006&view=rev
>> Log:
>> [Driver][Darwin] Pass -munwind-table when !UseSjLjExceptions.
>>
>> This commit fixes a bug where clang/llvm doesn't emit an unwind table
>> for a function when it is marked noexcept. Without this patch, the
>> following code terminates with an uncaught exception on ARM64:
>>
>> int foo1() noexcept {
>> try {
>> throw 0;
>> } catch (int i) {
>> return 0;
>> }
>> return 1;
>> }
>>
>> int main() {
>> return foo1();
>> }
>>
>> rdar://problem/32411865
>>
>> Differential Revision: https://reviews.llvm.org/D35693
>>
>> Modified:
>> cfe/trunk/include/clang/Driver/ToolChain.h
>> cfe/trunk/lib/Driver/ToolChain.cpp
>> cfe/trunk/lib/Driver/ToolChains/Clang.cpp
>> cfe/trunk/lib/Driver/ToolChains/CrossWindows.cpp
>> cfe/trunk/lib/Driver/ToolChains/CrossWindows.h
>> cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
>> cfe/trunk/lib/Driver/ToolChains/Darwin.h
>> cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
>> cfe/trunk/lib/Driver/ToolChains/Gnu.h
>> cfe/trunk/lib/Driver/ToolChains/MSVC.cpp
>> cfe/trunk/lib/Driver/ToolChains/MSVC.h
>> cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
>> cfe/trunk/lib/Driver/ToolChains/MinGW.h
>> cfe/trunk/lib/Driver/ToolChains/NetBSD.h
>> cfe/trunk/test/Driver/clang-translation.c
>>
>> Modified: cfe/trunk/include/clang/Driver/ToolChain.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=310006&r1=310005&r2=310006&view=diff
>> ==============================================================================
>> --- cfe/trunk/include/clang/Driver/ToolChain.h (original)
>> +++ cfe/trunk/include/clang/Driver/ToolChain.h Thu Aug 3 16:55:42 2017
>> @@ -315,7 +315,7 @@ public:
>>
>> /// 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;
>>
>> Modified: cfe/trunk/lib/Driver/ToolChain.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=310006&r1=310005&r2=310006&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/Driver/ToolChain.cpp (original)
>> +++ cfe/trunk/lib/Driver/ToolChain.cpp Thu Aug 3 16:55:42 2017
>> @@ -217,7 +217,7 @@ StringRef ToolChain::getDefaultUniversal
>> }
>> }
>>
>> -bool ToolChain::IsUnwindTablesDefault() const {
>> +bool ToolChain::IsUnwindTablesDefault(const ArgList &Args) const {
>> return false;
>> }
>>
>>
>> Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=310006&r1=310005&r2=310006&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
>> +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Thu Aug 3 16:55:42 2017
>> @@ -2599,7 +2599,7 @@ void Clang::ConstructJob(Compilation &C,
>> 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,
>>
>> Modified: cfe/trunk/lib/Driver/ToolChains/CrossWindows.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CrossWindows.cpp?rev=310006&r1=310005&r2=310006&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/Driver/ToolChains/CrossWindows.cpp (original)
>> +++ cfe/trunk/lib/Driver/ToolChains/CrossWindows.cpp Thu Aug 3 16:55:42 2017
>> @@ -213,7 +213,7 @@ CrossWindowsToolChain::CrossWindowsToolC
>> }
>> }
>>
>> -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;
>>
>> Modified: cfe/trunk/lib/Driver/ToolChains/CrossWindows.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CrossWindows.h?rev=310006&r1=310005&r2=310006&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/Driver/ToolChains/CrossWindows.h (original)
>> +++ cfe/trunk/lib/Driver/ToolChains/CrossWindows.h Thu Aug 3 16:55:42 2017
>> @@ -56,7 +56,7 @@ public:
>> 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;
>>
>> Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=310006&r1=310005&r2=310006&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
>> +++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Thu Aug 3 16:55:42 2017
>> @@ -1844,8 +1844,8 @@ Darwin::TranslateArgs(const DerivedArgLi
>> 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 {
>>
>> Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.h?rev=310006&r1=310005&r2=310006&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/Driver/ToolChains/Darwin.h (original)
>> +++ cfe/trunk/lib/Driver/ToolChains/Darwin.h Thu Aug 3 16:55:42 2017
>> @@ -216,7 +216,7 @@ public:
>>
>> 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;
>>
>> Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=310006&r1=310005&r2=310006&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
>> +++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Thu Aug 3 16:55:42 2017
>> @@ -2300,7 +2300,7 @@ void Generic_GCC::printVerboseInfo(raw_o
>> CudaInstallation.print(OS);
>> }
>>
>> -bool Generic_GCC::IsUnwindTablesDefault() const {
>> +bool Generic_GCC::IsUnwindTablesDefault(const ArgList &Args) const {
>> return getArch() == llvm::Triple::x86_64;
>> }
>>
>>
>> Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.h?rev=310006&r1=310005&r2=310006&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/Driver/ToolChains/Gnu.h (original)
>> +++ cfe/trunk/lib/Driver/ToolChains/Gnu.h Thu Aug 3 16:55:42 2017
>> @@ -284,7 +284,7 @@ public:
>>
>> 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;
>>
>> Modified: cfe/trunk/lib/Driver/ToolChains/MSVC.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/MSVC.cpp?rev=310006&r1=310005&r2=310006&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/Driver/ToolChains/MSVC.cpp (original)
>> +++ cfe/trunk/lib/Driver/ToolChains/MSVC.cpp Thu Aug 3 16:55:42 2017
>> @@ -699,7 +699,7 @@ bool MSVCToolChain::IsIntegratedAssemble
>> 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.
>>
>> Modified: cfe/trunk/lib/Driver/ToolChains/MSVC.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/MSVC.h?rev=310006&r1=310005&r2=310006&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/Driver/ToolChains/MSVC.h (original)
>> +++ cfe/trunk/lib/Driver/ToolChains/MSVC.h Thu Aug 3 16:55:42 2017
>> @@ -73,7 +73,7 @@ public:
>> 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;
>>
>> Modified: cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/MinGW.cpp?rev=310006&r1=310005&r2=310006&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/Driver/ToolChains/MinGW.cpp (original)
>> +++ cfe/trunk/lib/Driver/ToolChains/MinGW.cpp Thu Aug 3 16:55:42 2017
>> @@ -346,7 +346,7 @@ Tool *toolchains::MinGW::buildLinker() c
>> 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;
>> }
>>
>>
>> Modified: cfe/trunk/lib/Driver/ToolChains/MinGW.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/MinGW.h?rev=310006&r1=310005&r2=310006&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/Driver/ToolChains/MinGW.h (original)
>> +++ cfe/trunk/lib/Driver/ToolChains/MinGW.h Thu Aug 3 16:55:42 2017
>> @@ -60,7 +60,7 @@ public:
>> 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;
>>
>> Modified: cfe/trunk/lib/Driver/ToolChains/NetBSD.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/NetBSD.h?rev=310006&r1=310005&r2=310006&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/Driver/ToolChains/NetBSD.h (original)
>> +++ cfe/trunk/lib/Driver/ToolChains/NetBSD.h Thu Aug 3 16:55:42 2017
>> @@ -65,7 +65,10 @@ public:
>> 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:
>>
>> Modified: cfe/trunk/test/Driver/clang-translation.c
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/clang-translation.c?rev=310006&r1=310005&r2=310006&view=diff
>> ==============================================================================
>> --- cfe/trunk/test/Driver/clang-translation.c (original)
>> +++ cfe/trunk/test/Driver/clang-translation.c Thu Aug 3 16:55:42 2017
>> @@ -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
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
More information about the cfe-commits
mailing list