[libcxx-commits] [libcxxabi] [libcxx] [libcxxabi] Dont throw in make exception ptr if __cxa_init_primary_exception is available (PR #65534)

via libcxx-commits libcxx-commits at lists.llvm.org
Thu Oct 12 18:04:23 PDT 2023


================
@@ -36,13 +36,19 @@ class type_info; // forward declaration
 
 // runtime routines use C calling conventions, but are in __cxxabiv1 namespace
 namespace __cxxabiv1 {
+
+struct __cxa_exception;
+
 extern "C"  {
 
 // 2.4.2 Allocating the Exception Object
 extern _LIBCXXABI_FUNC_VIS void *
 __cxa_allocate_exception(size_t thrown_size) throw();
 extern _LIBCXXABI_FUNC_VIS void
 __cxa_free_exception(void *thrown_exception) throw();
+// This function is an llvm extension
+extern _LIBCXXABI_FUNC_VIS __cxa_exception*
+__cxa_init_primary_exception(void* object, std::type_info* tinfo, void(_LIBCXXABI_DTOR_FUNC* dest)(void*)) throw();
----------------
itrofimow wrote:

To add some context to the discussion:

- gcc has this function as "GNU extension": https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/libsupc%2B%2B/cxxabi_init_exception.h#L70, which was added with the exact same performance reasoning in mind: https://gcc.gnu.org/legacy-ml/libstdc++/2016-08/msg00036.html
- as of recently `libcxxrt` has this function as well: https://github.com/libcxxrt/libcxxrt/blob/master/src/cxxabi.h#L211

https://github.com/llvm/llvm-project/pull/65534


More information about the libcxx-commits mailing list