[pkg-d-commits] [ldc] 64/95: Re-add uwtable function attribute on Win64

Matthias Klumpp mak at moszumanska.debian.org
Thu Jul 13 20:54:01 UTC 2017


This is an automated email from the git hooks/post-receive script.

mak pushed a commit to annotated tag v1.3.0-beta1
in repository ldc.

commit 82395def98718bd38a25df56f969cd02df9e75ab
Author: Martin <noone at nowhere.com>
Date:   Tue Mar 21 20:43:44 2017 +0100

    Re-add uwtable function attribute on Win64
    
    Apparently needed for x86_64 in general and NetBSD (possibly other BSD
    flavours too) based on `clang::ToolChain::IsUnwindTablesDefault()`.
    
    Resolves issue #2048.
---
 gen/abi.h         | 8 ++++++++
 gen/functions.cpp | 6 ++----
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/gen/abi.h b/gen/abi.h
index f19ec41..fad41e8 100644
--- a/gen/abi.h
+++ b/gen/abi.h
@@ -107,6 +107,14 @@ struct TargetABI {
     return name;
   }
 
+  /// Returns true if all functions require the LLVM uwtable attribute.
+  virtual bool needsUnwindTables() {
+    // Condensed logic of Clang implementations of
+    // `clang::ToolChain::IsUnwindTablesDefault()` based on early Clang 5.0.
+    return global.params.targetTriple->getArch() == llvm::Triple::x86_64 ||
+           global.params.targetTriple->getOS() == llvm::Triple::NetBSD;
+  }
+
   /// Returns true if the D function uses sret (struct return).
   ///
   /// A LL sret function doesn't really return a struct (in fact, it returns
diff --git a/gen/functions.cpp b/gen/functions.cpp
index e2235e2..f5431b9 100644
--- a/gen/functions.cpp
+++ b/gen/functions.cpp
@@ -944,10 +944,8 @@ void DtoDefineFunction(FuncDeclaration *fd, bool linkageAvailableExternally) {
 
   assert(!func->hasDLLImportStorageClass());
 
-  // On x86_64, always set 'uwtable' for System V ABI compatibility.
-  // TODO: Find a better place for this.
-  if (global.params.targetTriple->getArch() == llvm::Triple::x86_64 &&
-      !global.params.isWindows) {
+  // function attributes
+  if (gABI->needsUnwindTables()) {
     func->addFnAttr(LLAttribute::UWTable);
   }
   if (opts::sanitize != opts::None) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-d/ldc.git



More information about the pkg-d-commits mailing list