[PATCH] D31178: [libcxxabi] Fix exception address alignment test for EHABI

Asiri Rathnayake via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 21 03:36:33 PDT 2017


rmaprath updated this revision to Diff 92450.
rmaprath added a comment.

Fixed a few paths.


https://reviews.llvm.org/D31178

Files:
  test/libcxxabi/test/config.py
  test/lit.site.cfg.in
  test/test_exception_address_alignment.pass.cpp


Index: test/test_exception_address_alignment.pass.cpp
===================================================================
--- test/test_exception_address_alignment.pass.cpp
+++ test/test_exception_address_alignment.pass.cpp
@@ -15,16 +15,25 @@
 // working around this failure.
 // XFAIL: darwin && libcxxabi-has-system-unwinder
 
-// Test that the address of the exception object is properly aligned to the
-// largest supported alignment for the system.
+// Test that the address of the exception object is properly aligned as required
+// by the relevant ABI
 
 #include <cstdint>
 #include <cassert>
 
 #include <unwind.h>
 
 struct __attribute__((aligned)) AlignedType {};
-static_assert(alignof(AlignedType) == alignof(_Unwind_Exception),
+
+// EHABI  : 8-byte aligned
+// Itanium: Largest supported alignment for the system
+#if _LIBUNWIND_ARM_EHABI
+#  define EXPECTED_ALIGNMENT 8
+#else
+#  define EXPECTED_ALIGNMENT alignof(AlignedType)
+#endif
+
+static_assert(alignof(_Unwind_Exception) == EXPECTED_ALIGNMENT,
   "_Unwind_Exception is incorrectly aligned. This test is expected to fail");
 
 struct MinAligned {  };
@@ -35,7 +44,7 @@
     try {
       throw MinAligned{};
     } catch (MinAligned const& ref) {
-      assert(reinterpret_cast<uintptr_t>(&ref) % alignof(AlignedType) == 0);
+      assert(reinterpret_cast<uintptr_t>(&ref) % EXPECTED_ALIGNMENT == 0);
     }
   }
 }
Index: test/lit.site.cfg.in
===================================================================
--- test/lit.site.cfg.in
+++ test/lit.site.cfg.in
@@ -6,6 +6,8 @@
 config.abi_library_path         = "@LIBCXXABI_LIBRARY_DIR@"
 config.libcxx_src_root          = "@LIBCXXABI_LIBCXX_PATH@"
 config.cxx_headers              = "@LIBCXXABI_LIBCXX_INCLUDES@"
+config.libunwind_src            = "@LIBCXXABI_LIBUNWIND_SOURCES@"
+config.libunwind_headers        = "@LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL@"
 config.cxx_library_root         = "@LIBCXXABI_LIBCXX_LIBRARY_PATH@"
 config.llvm_unwinder            = "@LIBCXXABI_USE_LLVM_UNWINDER@"
 config.enable_threads           = "@LIBCXXABI_ENABLE_THREADS@"
Index: test/libcxxabi/test/config.py
===================================================================
--- test/libcxxabi/test/config.py
+++ test/libcxxabi/test/config.py
@@ -20,14 +20,18 @@
         self.libcxxabi_obj_root = None
         self.abi_library_path = None
         self.libcxx_src_root = None
+        self.libunwind_src = None
 
     def configure_src_root(self):
         self.libcxxabi_src_root = self.get_lit_conf(
             'libcxxabi_src_root',
             os.path.dirname(self.config.test_source_root))
         self.libcxx_src_root = self.get_lit_conf(
             'libcxx_src_root',
             os.path.join(self.libcxxabi_src_root, '/../libcxx'))
+        self.libunwind_src = self.get_lit_conf(
+            'libunwind_src',
+            os.path.join(self.libcxxabi_src_root, '/../libunwind/src'))
 
     def configure_obj_root(self):
         self.libcxxabi_obj_root = self.get_lit_conf('libcxxabi_obj_root')
@@ -84,6 +88,15 @@
                                   % libcxxabi_headers)
         self.cxx.compile_flags += ['-I' + libcxxabi_headers]
 
+        libunwind_headers = self.get_lit_conf(
+           'libunwind_headers',
+           os.path.join(self.libunwind_src, '/../include'))
+        if self.get_lit_bool('llvm_unwinder', False):
+            if not os.path.isdir(libunwind_headers):
+                self.lit_config.fatal("libunwind_headers='%s' is not a directory."
+                                      % libunwind_headers)
+            self.cxx.compile_flags += ['-I' + libunwind_headers]
+
     def configure_compile_flags_exceptions(self):
         pass
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31178.92450.patch
Type: text/x-patch
Size: 3695 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170321/3ec1613a/attachment.bin>


More information about the cfe-commits mailing list