[coroutines] Handle unwind edge splitting
authorGor Nishanov <GorNishanov@gmail.com>
Tue, 16 May 2017 14:11:39 +0000 (14:11 +0000)
committerGor Nishanov <GorNishanov@gmail.com>
Tue, 16 May 2017 14:11:39 +0000 (14:11 +0000)
commit23453c11ff50632364fd617c9c9f2a1693621b8d
tree6162034164c3f2fba426a1d50c2d6c088d225a06
parent41e656768d2b6c7f3d27119d862b7eaf9055f3c7
[coroutines] Handle unwind edge splitting

Summary:
RewritePHIs algorithm used in building of CoroFrame inserts a placeholder
```
%placeholder = phi [%val]
```
on every edge leading to a block starting with PHI node with multiple incoming edges,
so that if one of the incoming values was spilled and need to be reloaded, we have a
place to insert a reload. We use SplitEdge helper function to split the incoming edge.

SplitEdge function does not deal with unwind edges comping into a block with an EHPad.

This patch adds an ehAwareSplitEdge function that can correctly split the unwind edge.

For landing pads, we clone the landing pad into every edge block and replace the original
landing pad with a PHI collection the values from all incoming landing pads.

For WinEH pads, we keep the original EHPad in place and insert cleanuppad/cleapret in the
edge blocks.

Reviewers: majnemer, rnk

Reviewed By: majnemer

Subscribers: EricWF, llvm-commits

Differential Revision: https://reviews.llvm.org/D31845

llvm-svn: 303172
llvm/lib/Transforms/Coroutines/CoroFrame.cpp
llvm/test/Transforms/Coroutines/coro-eh-aware-edge-split.ll [new file with mode: 0644]