[PATCH] D86767: [libunwind] Minor SJLJ config cleanup. NFCI.

Ryan Prichard via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 28 00:52:01 PDT 2020


rprichard created this revision.
rprichard added reviewers: compnerd, mstorsjo.
Herald added subscribers: libcxx-commits, llvm-commits, kristof.beyls, aprantl.
Herald added projects: LLVM, libunwind.
Herald added a reviewer: libunwind.
rprichard requested review of this revision.

When targeting armv7 iOS, Clang defines the __USING_SJLJ_EXCEPTIONS__
macro, so checking (defined(__APPLE__) && defined(__arm__)) too is
redundant.

Many _LIBUNWIND_SUPPORT_* macros in config.h don't apply to SJLJ, so
stop defining them.

Replace:

  defined(__ARM_DWARF_EH__) || !defined(__arm__)

with:

  !defined(_LIBUNWIND_ARM_EHABI)

Generally, when libunwind is built for SJLJ, none of the .hpp files are
included, and almost all of the .c and .cpp files are defined away
except for Unwind-sjlj.c. Unwind_AppleExtras.cpp is an exception
because it includes two hpp files, which it doesn't use. Remove the
unneeded includes, which restores the rule that SJLJ-mode ignores most
unwinder code.

(Nevertheless, keep AddressSpace.hpp building for Apple/armv7/SJLJ by
making the findUnwindSections block conditional on
_LIBUNWIND_SUPPORT_COMPACT_UNWIND.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86767

Files:
  libunwind/src/AddressSpace.hpp
  libunwind/src/Unwind_AppleExtras.cpp
  libunwind/src/config.h


Index: libunwind/src/config.h
===================================================================
--- libunwind/src/config.h
+++ libunwind/src/config.h
@@ -18,8 +18,12 @@
 #include <stdint.h>
 #include <stdlib.h>
 
+#include <__libunwind_config.h>
+
 // Platform specific configuration defines.
-#ifdef __APPLE__
+#if defined(__USING_SJLJ_EXCEPTIONS__)
+  // None of these macros apply to SJLJ unwinding.
+#elif defined(__APPLE__)
   #if defined(FOR_DYLD)
     #define _LIBUNWIND_SUPPORT_COMPACT_UNWIND 1
   #else
@@ -33,7 +37,7 @@
     #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1
   #endif
 #else
-  #if defined(__ARM_DWARF_EH__) || !defined(__arm__)
+  #if !defined(_LIBUNWIND_ARM_EHABI)
     #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1
     #define _LIBUNWIND_SUPPORT_DWARF_INDEX 1
   #endif
@@ -81,7 +85,7 @@
 #error Unsupported target
 #endif
 
-#if (defined(__APPLE__) && defined(__arm__)) || defined(__USING_SJLJ_EXCEPTIONS__)
+#if defined(__USING_SJLJ_EXCEPTIONS__)
 #define _LIBUNWIND_BUILD_SJLJ_APIS
 #endif
 
@@ -91,8 +95,7 @@
 
 #if defined(__i386__) || defined(__x86_64__) ||                                \
     defined(__ppc__) || defined(__ppc64__) || defined(__powerpc64__) ||        \
-    (!defined(__APPLE__) && defined(__arm__)) ||                               \
-    defined(__aarch64__) ||                                                    \
+    defined(__arm__) || defined(__aarch64__) ||                                \
     defined(__mips__) ||                                                       \
     defined(__riscv) ||                                                        \
     defined(__hexagon__)
Index: libunwind/src/Unwind_AppleExtras.cpp
===================================================================
--- libunwind/src/Unwind_AppleExtras.cpp
+++ libunwind/src/Unwind_AppleExtras.cpp
@@ -8,8 +8,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "config.h"
-#include "AddressSpace.hpp"
-#include "DwarfParser.hpp"
 
 
 // static linker symbols to prevent wrong two level namespace for _Unwind symbols
Index: libunwind/src/AddressSpace.hpp
===================================================================
--- libunwind/src/AddressSpace.hpp
+++ libunwind/src/AddressSpace.hpp
@@ -522,7 +522,7 @@
 
 inline bool LocalAddressSpace::findUnwindSections(pint_t targetAddr,
                                                   UnwindInfoSections &info) {
-#ifdef __APPLE__
+#if defined(__APPLE__) && defined(_LIBUNWIND_SUPPORT_COMPACT_UNWIND)
   dyld_unwind_sections dyldInfo;
   if (_dyld_find_unwind_sections((void *)targetAddr, &dyldInfo)) {
     info.dso_base                      = (uintptr_t)dyldInfo.mh;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86767.288541.patch
Type: text/x-patch
Size: 2698 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200828/58d2286b/attachment-0001.bin>


More information about the llvm-commits mailing list