[libcxx-commits] [PATCH] D122536: [libc++] Optimize `exception_ptr`, especially for the empty case

Mark de Wever via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Apr 13 10:09:28 PDT 2022


Mordante added a comment.

> In D122536#3414390 <https://reviews.llvm.org/D122536#3414390>, @Mordante wrote:
>
>> Can you add some benchmarks to show how much improvements these changes bring?
>
> I don't know what a sensible benchmark for this would look like, but have a look at the generated assembly:
>
> Example 1 (from #44892 <https://github.com/llvm/llvm-project/issues/44892>): https://godbolt.org/z/YGq86cszM. With my changes, this compiles to just
>
>   0000000000000000 <_Z4testv>:
>      0:	b0 01                	mov    al,0x1
>      2:	c3                   	ret
>
> Example 2 (from #39333 <https://github.com/llvm/llvm-project/issues/39333>): https://godbolt.org/z/oee13ennv. With my changes, this becomes
>
>   0000000000000000 <main>:
>      0:	31 c0                	xor    eax,eax
>      2:	c3                   	ret

That assembly looks convincing, thanks.



================
Comment at: libcxx/include/exception:144
 
+#ifndef _LIBCPP_EXCEPTION_PTR_GNU_INLINE
+#define _LIBCPP_EXCEPTION_PTR_GNU_INLINE __attribute__((__gnu_inline__)) inline
----------------
I would like some comment describing this `_LIBCPP_EXCEPTION_PTR_GNU_INLINE` magic. Reading the other comments in this review make it clear, could you add short summary of that information here?


================
Comment at: libcxx/include/exception:145
+#ifndef _LIBCPP_EXCEPTION_PTR_GNU_INLINE
+#define _LIBCPP_EXCEPTION_PTR_GNU_INLINE __attribute__((__gnu_inline__)) inline
+#endif
----------------
We should validate whether the compiler supports this attribute.


================
Comment at: libcxx/include/exception:163
+
+    exception_ptr(exception_ptr&& __rhs) _NOEXCEPT : __ptr_(__rhs.__ptr_) {
+        __rhs.__ptr_ = nullptr;
----------------
Same at line 167.


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

https://reviews.llvm.org/D122536



More information about the libcxx-commits mailing list