[libcxxabi] r299435 - Fix exception address alignment test for EHABI

Asiri Rathnayake via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 4 07:03:54 PDT 2017


Author: asiri
Date: Tue Apr  4 09:03:54 2017
New Revision: 299435

URL: http://llvm.org/viewvc/llvm-project?rev=299435&view=rev
Log:
Fix exception address alignment test for EHABI

This test fails on ARM bare-metal targets because it assumes the Itanium ABI,
whereas EHABI requires the exception address to be 8-byte aligned.

I was a bit puzzled at first because this should've failed on the public
arm-linux builder too. I think the reason it passes there is because we don't
include libunwind headers in the include path when running the libcxxabi tests,
so the system unwind.h gets picked up.

Reviewers: rengolin, EricWF
Differential revision: https://reviews.llvm.org/D31178

Modified:
    libcxxabi/trunk/CMakeLists.txt
    libcxxabi/trunk/test/libcxxabi/test/config.py
    libcxxabi/trunk/test/lit.site.cfg.in
    libcxxabi/trunk/test/test_exception_address_alignment.pass.cpp

Modified: libcxxabi/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=299435&r1=299434&r2=299435&view=diff
==============================================================================
--- libcxxabi/trunk/CMakeLists.txt (original)
+++ libcxxabi/trunk/CMakeLists.txt Tue Apr  4 09:03:54 2017
@@ -502,9 +502,14 @@ if (LIBCXXABI_USE_LLVM_UNWINDER OR LLVM_
     set(LIBCXXABI_LIBUNWIND_SOURCES "")
   endif()
 
-  if (NOT LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL STREQUAL "LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL-NOTFOUND")
+  if (LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL STREQUAL "LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL-NOTFOUND")
+    set(LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL "")
+  endif()
+
+  if (NOT LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL STREQUAL "")
     include_directories("${LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL}")
   endif()
+
   if (NOT LIBCXXABI_LIBUNWIND_SOURCES STREQUAL "")
     include_directories("${LIBCXXABI_LIBUNWIND_SOURCES}")
   endif()

Modified: libcxxabi/trunk/test/libcxxabi/test/config.py
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/libcxxabi/test/config.py?rev=299435&r1=299434&r2=299435&view=diff
==============================================================================
--- libcxxabi/trunk/test/libcxxabi/test/config.py (original)
+++ libcxxabi/trunk/test/libcxxabi/test/config.py Tue Apr  4 09:03:54 2017
@@ -84,6 +84,13 @@ class Configuration(LibcxxConfiguration)
                                   % libcxxabi_headers)
         self.cxx.compile_flags += ['-I' + libcxxabi_headers]
 
+        libunwind_headers = self.get_lit_conf('libunwind_headers', None)
+        if self.get_lit_bool('llvm_unwinder', False) and libunwind_headers:
+            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
 

Modified: libcxxabi/trunk/test/lit.site.cfg.in
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/lit.site.cfg.in?rev=299435&r1=299434&r2=299435&view=diff
==============================================================================
--- libcxxabi/trunk/test/lit.site.cfg.in (original)
+++ libcxxabi/trunk/test/lit.site.cfg.in Tue Apr  4 09:03:54 2017
@@ -6,6 +6,7 @@ config.libcxxabi_obj_root       = "@LIBC
 config.abi_library_path         = "@LIBCXXABI_LIBRARY_DIR@"
 config.libcxx_src_root          = "@LIBCXXABI_LIBCXX_PATH@"
 config.cxx_headers              = "@LIBCXXABI_LIBCXX_INCLUDES@"
+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@"

Modified: libcxxabi/trunk/test/test_exception_address_alignment.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/test_exception_address_alignment.pass.cpp?rev=299435&r1=299434&r2=299435&view=diff
==============================================================================
--- libcxxabi/trunk/test/test_exception_address_alignment.pass.cpp (original)
+++ libcxxabi/trunk/test/test_exception_address_alignment.pass.cpp Tue Apr  4 09:03:54 2017
@@ -15,8 +15,8 @@
 // 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>
@@ -24,7 +24,16 @@
 #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 defined(_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 @@ int main() {
     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);
     }
   }
 }




More information about the cfe-commits mailing list