[llvm-bugs] [Bug 45547] New: Optimize exception_ptr, especially for common cases.

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Apr 15 03:34:46 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=45547

            Bug ID: 45547
           Summary: Optimize exception_ptr, especially for common cases.
           Product: libc++
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: redbeard0531 at gmail.com
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com

Right now the libc++ exception_ptr type is very expensive to use, even in the
cases where it is never or very rarely non-null. Given the intended usage, that
is likely to be the common case. This type will become even more important with
coroutines, and a poor implementation will handicap the performance of task
types, even when the compiler can prove that no exception will be thrown.

Specific improvements:
- Move optimization. Right now it is copy-only, while moves should be as cheap
as for unique_ptr.
- Swap optimization. Currently only the MSABI implementation has a specialized
std::swap. Using the default on intanium abi is very bad right now without move
optimizations, but even with them, it should generate better code if customized
than if not.
- Inline trivial operations for null cases, only calling out-of-line helpers
for non-null cases. This is especially important for the destructor and move
operations since currently the compiler is forced to emit an out of line call,
even when it can prove the pointer is null. This would also be useful for copy
operations.
- Comparison to nullptr shouldn't construct an exception_ptr that needs to be
destroyed. This may not matter if the prior bullet is done.

Example codegen that should all optimize away: https://godbolt.org/z/NaNKe5

Related libstdc++ bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90295

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200415/102cd4ba/attachment.html>


More information about the llvm-bugs mailing list