From f47686bf3d05553e0fad7dff067c13f21df8797d Mon Sep 17 00:00:00 2001
From: Akira Hatanaka <ahatanaka@apple.com>
Date: Thu, 5 May 2016 01:41:07 +0000
Subject: [PATCH] Do not add uwtable attribute by default for MachO targets.

r217178 changed clang to add function attribute uwtable by default on
Win64, which caused the __eh_frame section to be emitted by default.
This commit restores the previous behavior for MachO targets.

rdar://problem/25282627


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@268589 91177308-0d34-0410-b5e6-96231b3b80d8
---
 lib/Driver/MSVCToolChain.cpp   | 5 +++++
 test/Driver/win-macho-unwind.c | 4 ++++
 2 files changed, 9 insertions(+)
 create mode 100644 test/Driver/win-macho-unwind.c

diff --git a/lib/Driver/MSVCToolChain.cpp b/lib/Driver/MSVCToolChain.cpp
index 7f84d1f9d94..acfb507fea5 100644
--- a/lib/Driver/MSVCToolChain.cpp
+++ b/lib/Driver/MSVCToolChain.cpp
@@ -71,6 +71,11 @@ bool MSVCToolChain::IsUnwindTablesDefault() 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.
+
+  // Don't emit unwind tables by default for MachO targets.
+  if (getTriple().isOSBinFormatMachO())
+    return false;
+
   return getArch() == llvm::Triple::x86_64;
 }
 
diff --git a/test/Driver/win-macho-unwind.c b/test/Driver/win-macho-unwind.c
new file mode 100644
index 00000000000..a2895d2fe8c
--- /dev/null
+++ b/test/Driver/win-macho-unwind.c
@@ -0,0 +1,4 @@
+// RUN: %clang -target x86_64-pc-win32-macho -### -S %s -o %t.s 2>&1 | FileCheck %s
+ 
+// Do not add function attribute "uwtable" for macho targets.
+// CHECK-NOT: -munwind-tables
-- 
GitLab