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

Fabian Wolff via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Apr 12 08:12:03 PDT 2022


fwolff added a comment.

In D122536#3409909 <https://reviews.llvm.org/D122536#3409909>, @philnik wrote:

> I think this could be implemented in a non ABI breaking way by using `__attribute__((__gnu_inline__))`. See https://godbolt.org/z/W83rTb714 for an example. If you want to allow it in ABIv1 this way you should probably just disable the magic in ABIv2.

Sorry, but I haven't been able to get this to work. I don't really understand your example, and the documentation for `gnu_inline` is pretty sparse. But we need an ABI break anyway in order to add the move constructor and assignment operator.

In D122536#3443999 <https://reviews.llvm.org/D122536#3443999>, @avogelsgesang wrote:

> afaict, this should also fix https://github.com/llvm/llvm-project/issues/39333

Yes, indeed, thanks for pointing this out!

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122536



More information about the libcxx-commits mailing list