Author: hans
Date: Thu Aug 10 18:47:32 2017
New Revision: 310677

URL: http://llvm.org/viewvc/llvm-project?rev=310677&view=rev
Log:
Merging r310006:
------------------------------------------------------------------------
r310006 | ahatanak | 2017-08-03 16:55:42 -0700 (Thu, 03 Aug 2017) | 22 lines

[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/branches/release_50/   (props changed)
    cfe/branches/release_50/include/clang/Driver/ToolChain.h
    cfe/branches/release_50/lib/Driver/ToolChain.cpp
    cfe/branches/release_50/lib/Driver/ToolChains/Clang.cpp
    cfe/branches/release_50/lib/Driver/ToolChains/CrossWindows.cpp
    cfe/branches/release_50/lib/Driver/ToolChains/CrossWindows.h
    cfe/branches/release_50/lib/Driver/ToolChains/Darwin.cpp
    cfe/branches/release_50/lib/Driver/ToolChains/Darwin.h
    cfe/branches/release_50/lib/Driver/ToolChains/Gnu.cpp
    cfe/branches/release_50/lib/Driver/ToolChains/Gnu.h
    cfe/branches/release_50/lib/Driver/ToolChains/MSVC.cpp
    cfe/branches/release_50/lib/Driver/ToolChains/MSVC.h
    cfe/branches/release_50/lib/Driver/ToolChains/MinGW.cpp
    cfe/branches/release_50/lib/Driver/ToolChains/MinGW.h
    cfe/branches/release_50/lib/Driver/ToolChains/NetBSD.h
    cfe/branches/release_50/test/Driver/clang-translation.c

Propchange: cfe/branches/release_50/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Aug 10 18:47:32 2017
@@ -1,4 +1,4 @@
 /cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:308455,308722,308824,308897,308996,309058,309112-309113,309226,309263,309327,309382-309383,309488,309503,309523,309569,309607,309633,309636,309640,309722,309752,309975,310057,310158,310191,310359
+/cfe/trunk:308455,308722,308824,308897,308996,309058,309112-309113,309226,309263,309327,309382-309383,309488,309503,309523,309569,309607,309633,309636,309640,309722,309752,309975,310006,310057,310158,310191,310359
 /cfe/trunk/test:170344
 /cfe/trunk/test/SemaTemplate:126920

Modified: cfe/branches/release_50/include/clang/Driver/ToolChain.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/branches/release_50/include/clang/Driver/ToolChain.h?rev=310677&r1=310676&r2=310677&view=diff
==============================================================================
--- cfe/branches/release_50/include/clang/Driver/ToolChain.h (original)
+++ cfe/branches/release_50/include/clang/Driver/ToolChain.h Thu Aug 10 
18:47:32 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/branches/release_50/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/branches/release_50/lib/Driver/ToolChain.cpp?rev=310677&r1=310676&r2=310677&view=diff
==============================================================================
--- cfe/branches/release_50/lib/Driver/ToolChain.cpp (original)
+++ cfe/branches/release_50/lib/Driver/ToolChain.cpp Thu Aug 10 18:47:32 2017
@@ -217,7 +217,7 @@ StringRef ToolChain::getDefaultUniversal
   }
 }
 
-bool ToolChain::IsUnwindTablesDefault() const {
+bool ToolChain::IsUnwindTablesDefault(const ArgList &Args) const {
   return false;
 }
 

Modified: cfe/branches/release_50/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/branches/release_50/lib/Driver/ToolChains/Clang.cpp?rev=310677&r1=310676&r2=310677&view=diff
==============================================================================
--- cfe/branches/release_50/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/branches/release_50/lib/Driver/ToolChains/Clang.cpp Thu Aug 10 18:47:32 
2017
@@ -2538,7 +2538,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/branches/release_50/lib/Driver/ToolChains/CrossWindows.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/branches/release_50/lib/Driver/ToolChains/CrossWindows.cpp?rev=310677&r1=310676&r2=310677&view=diff
==============================================================================
--- cfe/branches/release_50/lib/Driver/ToolChains/CrossWindows.cpp (original)
+++ cfe/branches/release_50/lib/Driver/ToolChains/CrossWindows.cpp Thu Aug 10 
18:47:32 2017
@@ -214,7 +214,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/branches/release_50/lib/Driver/ToolChains/CrossWindows.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/branches/release_50/lib/Driver/ToolChains/CrossWindows.h?rev=310677&r1=310676&r2=310677&view=diff
==============================================================================
--- cfe/branches/release_50/lib/Driver/ToolChains/CrossWindows.h (original)
+++ cfe/branches/release_50/lib/Driver/ToolChains/CrossWindows.h Thu Aug 10 
18:47:32 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/branches/release_50/lib/Driver/ToolChains/Darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/branches/release_50/lib/Driver/ToolChains/Darwin.cpp?rev=310677&r1=310676&r2=310677&view=diff
==============================================================================
--- cfe/branches/release_50/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/branches/release_50/lib/Driver/ToolChains/Darwin.cpp Thu Aug 10 
18:47:32 2017
@@ -1836,8 +1836,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/branches/release_50/lib/Driver/ToolChains/Darwin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/branches/release_50/lib/Driver/ToolChains/Darwin.h?rev=310677&r1=310676&r2=310677&view=diff
==============================================================================
--- cfe/branches/release_50/lib/Driver/ToolChains/Darwin.h (original)
+++ cfe/branches/release_50/lib/Driver/ToolChains/Darwin.h Thu Aug 10 18:47:32 
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/branches/release_50/lib/Driver/ToolChains/Gnu.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/branches/release_50/lib/Driver/ToolChains/Gnu.cpp?rev=310677&r1=310676&r2=310677&view=diff
==============================================================================
--- cfe/branches/release_50/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/branches/release_50/lib/Driver/ToolChains/Gnu.cpp Thu Aug 10 18:47:32 
2017
@@ -2291,7 +2291,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/branches/release_50/lib/Driver/ToolChains/Gnu.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/branches/release_50/lib/Driver/ToolChains/Gnu.h?rev=310677&r1=310676&r2=310677&view=diff
==============================================================================
--- cfe/branches/release_50/lib/Driver/ToolChains/Gnu.h (original)
+++ cfe/branches/release_50/lib/Driver/ToolChains/Gnu.h Thu Aug 10 18:47:32 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/branches/release_50/lib/Driver/ToolChains/MSVC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/branches/release_50/lib/Driver/ToolChains/MSVC.cpp?rev=310677&r1=310676&r2=310677&view=diff
==============================================================================
--- cfe/branches/release_50/lib/Driver/ToolChains/MSVC.cpp (original)
+++ cfe/branches/release_50/lib/Driver/ToolChains/MSVC.cpp Thu Aug 10 18:47:32 
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/branches/release_50/lib/Driver/ToolChains/MSVC.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/branches/release_50/lib/Driver/ToolChains/MSVC.h?rev=310677&r1=310676&r2=310677&view=diff
==============================================================================
--- cfe/branches/release_50/lib/Driver/ToolChains/MSVC.h (original)
+++ cfe/branches/release_50/lib/Driver/ToolChains/MSVC.h Thu Aug 10 18:47:32 
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/branches/release_50/lib/Driver/ToolChains/MinGW.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/branches/release_50/lib/Driver/ToolChains/MinGW.cpp?rev=310677&r1=310676&r2=310677&view=diff
==============================================================================
--- cfe/branches/release_50/lib/Driver/ToolChains/MinGW.cpp (original)
+++ cfe/branches/release_50/lib/Driver/ToolChains/MinGW.cpp Thu Aug 10 18:47:32 
2017
@@ -347,7 +347,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/branches/release_50/lib/Driver/ToolChains/MinGW.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/branches/release_50/lib/Driver/ToolChains/MinGW.h?rev=310677&r1=310676&r2=310677&view=diff
==============================================================================
--- cfe/branches/release_50/lib/Driver/ToolChains/MinGW.h (original)
+++ cfe/branches/release_50/lib/Driver/ToolChains/MinGW.h Thu Aug 10 18:47:32 
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/branches/release_50/lib/Driver/ToolChains/NetBSD.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/branches/release_50/lib/Driver/ToolChains/NetBSD.h?rev=310677&r1=310676&r2=310677&view=diff
==============================================================================
--- cfe/branches/release_50/lib/Driver/ToolChains/NetBSD.h (original)
+++ cfe/branches/release_50/lib/Driver/ToolChains/NetBSD.h Thu Aug 10 18:47:32 
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/branches/release_50/test/Driver/clang-translation.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/branches/release_50/test/Driver/clang-translation.c?rev=310677&r1=310676&r2=310677&view=diff
==============================================================================
--- cfe/branches/release_50/test/Driver/clang-translation.c (original)
+++ cfe/branches/release_50/test/Driver/clang-translation.c Thu Aug 10 18:47:32 
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


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

Reply via email to