[Coroutines] Part11: Add final suspend handling.
authorGor Nishanov <GorNishanov@gmail.com>
Mon, 5 Sep 2016 04:44:30 +0000 (04:44 +0000)
committerGor Nishanov <GorNishanov@gmail.com>
Mon, 5 Sep 2016 04:44:30 +0000 (04:44 +0000)
commit0e18f75a92002f1901d7a70c24b8caa256d12334
treeafe9b780f55c64c0524d584cb57b57af281461c5
parent42b69dd961a008446a326c409b99f61cce632484
[Coroutines] Part11: Add final suspend handling.

Summary:
A frontend may designate a particular suspend to be final, by setting the second argument of the coro.suspend intrinsic to true. Such a suspend point has two properties:

* it is possible to check whether a suspended coroutine is at the final suspend point via coro.done intrinsic;
* a resumption of a coroutine stopped at the final suspend point leads to undefined behavior. The only possible action for a coroutine at a final suspend point is destroying it via coro.destroy intrinsic.

This patch adds final suspend handling logic to CoroEarly and CoroSplit passes.
Now, the final suspend point example from docs\Coroutines.rst compiles and produces expected result (see test/Transform/Coroutines/ex5.ll).

Reviewers: majnemer

Subscribers: mehdi_amini, llvm-commits

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

llvm-svn: 280646
llvm/lib/Transforms/Coroutines/CoroEarly.cpp
llvm/lib/Transforms/Coroutines/CoroSplit.cpp
llvm/lib/Transforms/Coroutines/Coroutines.cpp
llvm/test/Transforms/Coroutines/ex5.ll [new file with mode: 0644]