[PATCH] D88059: [Coroutine] Split PHI Nodes in `cleanuppad` blocks in a way that obeys EH pad rules

Daniel Paoliello via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 21 17:05:37 PDT 2020


dpaoliello created this revision.
dpaoliello added reviewers: llvm-commits, rnk.
Herald added subscribers: lxfind, modocache, hiraditya.
Herald added a project: LLVM.
dpaoliello requested review of this revision.

Issue Details:
In order to support coroutine splitting, any multi-value PHI node in a coroutine is split into multiple blocks with single-value PHI Nodes, which then allows a subsequent transform to generate `reload` instructions as required (i.e., to reload the value if required if the coroutine has been resumed). This causes issues with EH pads (`catchswitch` and `catchpad`) as all pads within a `catchswitch` must have the same unwind destination, but the coroutine splitting logic may modify them to each have a unique unwind destination if there is a PHI node in the unwind `cleanuppad` that is set from values in the `catchswitch` and `cleanuppad` blocks.

Fix Details:
During splitting, if such a PHI node is detected, then create a "dispatcher" `cleanuppad` as well as the blocks with single-value PHI Nodes: thus the "dispatcher" is the unwind destination and it will detect which predecessor called it and then branch to the appropriate single-value PHI node block, which will then branch back to the original `cleanuppad` block.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88059

Files:
  llvm/lib/Transforms/Coroutines/CoroFrame.cpp
  llvm/test/Transforms/Coroutines/coro-catchswitch-cleanuppad.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88059.293295.patch
Type: text/x-patch
Size: 11308 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200922/1263dce8/attachment.bin>


More information about the llvm-commits mailing list