[PATCH] D119760: [DSE] Fall back to CFG scan for unreachable terminators.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 14 13:46:32 PST 2022


fhahn added a comment.

In D119760#3320798 <https://reviews.llvm.org/D119760#3320798>, @efriedma wrote:

> I'm not convinced this is right... what happens if you replace "exit" with something that throws an exception, or calls longjmp, or has an infinite loop?  I'm not seeing any logic in this patch that actually reasons about the contents of the block that ends in "unreachable".

I think this part of the code should only be responsible for checking that the killed store is not visible after the function returns (= only done for objects visible to the caller around like 1496).

If there are any reads or throwing calls, those should be handled during the mem-ssa traversal earlier. If there's an infinite loop or a function that does not return, I don't think this would cause an issue, because we only need to check if there's a path to an exit that returns to the caller via a regular return.  I'm not sure how the longjump case would be modeled exactly, but I think this would also need to be handled by the earlier checks before we reach this code.

There are a couple of extra tests (`@unreachable_exit_with_may_unwind_call`, `@unreachable_exit_and_call_may_read`) that should test some of the scenarios you mentioned.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119760



More information about the llvm-commits mailing list