[libcxx-commits] [PATCH] D101298: [libc++abi][AIX] Enable calculating addresses with DW_EH_PE_datarel

Xing Xue via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Apr 29 10:52:36 PDT 2021


xingxue updated this revision to Diff 341579.
xingxue edited the summary of this revision.
xingxue added a comment.

Refreshed to base on the split out NFC patch https://reviews.llvm.org/D101545.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101298/new/

https://reviews.llvm.org/D101298

Files:
  libcxxabi/src/cxa_personality.cpp


Index: libcxxabi/src/cxa_personality.cpp
===================================================================
--- libcxxabi/src/cxa_personality.cpp
+++ libcxxabi/src/cxa_personality.cpp
@@ -296,8 +296,12 @@
         if (result)
             result += (uintptr_t)(*data);
         break;
-    case DW_EH_PE_textrel:
     case DW_EH_PE_datarel:
+        assert((base != 0) && "DW_EH_PE_datarel is invalid with a base of 0");
+        if (result)
+            result += base;
+        break;
+    case DW_EH_PE_textrel:
     case DW_EH_PE_funcrel:
     case DW_EH_PE_aligned:
     default:
@@ -536,6 +540,9 @@
 {
 #if defined(__USING_SJLJ_EXCEPTIONS__)
 #define __builtin_eh_return_data_regno(regno) regno
+#elif defined(__ibmxl__)
+// IBM xlclang++ compiler does not support __builtin_eh_return_data_regno.
+#define __builtin_eh_return_data_regno(regno) regno + 3
 #endif
   _Unwind_SetGR(context, __builtin_eh_return_data_regno(0),
                 reinterpret_cast<uintptr_t>(unwind_exception));
@@ -615,7 +622,11 @@
         return;
     }
     results.languageSpecificData = lsda;
+#if defined(_AIX)
+    uintptr_t base = _Unwind_GetDataRelBase(context);
+#else
     uintptr_t base = 0;
+#endif
     // Get the current instruction pointer and offset it before next
     // instruction in the current frame which threw the exception.
     uintptr_t ip = _Unwind_GetIP(context) - 1;
@@ -921,8 +932,13 @@
         set_registers(unwind_exception, context, results);
         // Cache base for calculating the address of ttype in
         // __cxa_call_unexpected.
-        if (results.ttypeIndex < 0)
+        if (results.ttypeIndex < 0) {
+#if defined(_AIX)
+          exception_header->catchTemp = (void *)_Unwind_GetDataRelBase(context);
+#else
           exception_header->catchTemp = 0;
+#endif
+        }
         return _URC_INSTALL_CONTEXT;
     }
 
@@ -956,7 +972,11 @@
     if (results.ttypeIndex < 0) {
       __cxa_exception* exception_header =
             (__cxa_exception*)(unwind_exception + 1) - 1;
+#if defined(_AIX)
+      exception_header->catchTemp = (void *)_Unwind_GetDataRelBase(context);
+#else
       exception_header->catchTemp = 0;
+#endif
     }
     return _URC_INSTALL_CONTEXT;
 }
@@ -1250,6 +1270,15 @@
     std::__terminate(t_handler);
 }
 
+#if defined(_AIX)
+// Personality routine for EH using the range table. Make it an alias of
+// __gxx_personality_v0().
+_LIBCXXABI_FUNC_VIS _Unwind_Reason_Code __xlcxx_personality_v1(
+    int version, _Unwind_Action actions, uint64_t exceptionClass,
+    _Unwind_Exception* unwind_exception, _Unwind_Context* context)
+    __attribute__((alias("__gxx_personality_v0")));
+#endif
+
 }  // extern "C"
 
 }  // __cxxabiv1


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101298.341579.patch
Type: text/x-patch
Size: 2693 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210429/daccc740/attachment.bin>


More information about the libcxx-commits mailing list