[libcxx-commits] [PATCH] D141222: [libc++] Use __verbose_abort instead of std::abort in __throw_ functions

Nikolas Klauser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Mar 1 09:39:48 PST 2023


philnik added a comment.

In D141222#4037026 <https://reviews.llvm.org/D141222#4037026>, @ldionne wrote:

> This is great. I actually thought I had a local patch doing this, but I can't find it. At least it's been on my mind for a while, and in fact it was the main reason why I generalized from `__libcpp_assertion_handler` to `__libcpp_verbose_abort`.
>
> One thing to keep in mind is that calling `__libcpp_verbose_abort` may generate larger code than calling `abort()` did, which could be annoying for folks compiling with `-fno-exceptions`. I think we may want to e.g. mark `__libcpp_verbose_abort` as `cold` to help the compiler optimize it better when possible, but at the end of the day, the calling convention for variadic functions on some architectures like arm64 isn't super size-friendly. I don't think this should prevent us from making this change, but size regressions should be on our radar.

The compiler already considers `[[noreturn]]` functions to be extremely unlikely: https://godbolt.org/z/9xoYWfK4T. So I don't think we have to give the compiler extra hints.

In D141222#4037300 <https://reviews.llvm.org/D141222#4037300>, @ldionne wrote:

> In D141222#4037293 <https://reviews.llvm.org/D141222#4037293>, @ldionne wrote:
>
>> Oh actually I had created D131619 <https://reviews.llvm.org/D131619>, that's what I was looking for.
>
> Looking at that patch again, I feel like the additional
>
>   _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI inline
>   void __exception_abort(char const* __file, int __line, char const* __msg) {
>     std::__libcpp_verbose_abort("%s:%d: Exception thrown with exceptions disabled: %s\n", __file, __line, __msg);
>   }
>
> and
>
>   _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI inline
>   void __assertion_abort(char const* __file, int __line, char const* __expr, char const* __msg) {
>     std::__libcpp_verbose_abort("%s:%d: Assertion %s failed: %s\n", __file, __line, __expr, __msg);
>   }
>
> did make sense, no?

I don't think so. This would only give people the `__throw_whatever` functions, which seems not exactly useful.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141222



More information about the libcxx-commits mailing list