[PATCH] D82999: [CodeGen] Check the cleanup flag before destructing lifetime-extended temporaries created in conditional expressions

Akira Hatanaka via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 8 18:31:28 PDT 2020


ahatanak added a comment.

In D82999#2129855 <https://reviews.llvm.org/D82999#2129855>, @rjmccall wrote:

> In D82999#2129417 <https://reviews.llvm.org/D82999#2129417>, @ahatanak wrote:
>
> > In test case `test13` in clang/test/CodeGenCXX/exceptions.cpp, I think you can turn `invoke void @_ZN6test131AC1Ev` into `call void @_ZN6test131AC1Ev`, no? If the false expression throws, there is nothing to clean up in the false expression and also nothing in the true expression has to be cleaned up.
>
>
> Yes, this is true.  It would be possible to enhance Clang's cleanup stack to support this sort of thing — we'd want to be able to mark a cleanup as "currently known inactive" without potentially popping it off the cleanup stack, and then we could have conditional scopes remember the cleanups that were added, deactivate them this way, and then reactivate them after the merge.  Swift's cleanup manager supports something similar.


OK, I see. Since the enhancement isn't trivial to implement, I think we should do it in a separate patch if it has a large impact on code size. WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82999





More information about the cfe-commits mailing list