OSDN Git Service

[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)
commitac396ea37fedd0f80a906220f7f372f541309e2a
tree214540cd01c3546997f48b67d3f46abfe8e1eb68
parent384a721ef9575bc59b890d35d6c31a12dd63b55d
[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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@280646 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Coroutines/CoroEarly.cpp
lib/Transforms/Coroutines/CoroSplit.cpp
lib/Transforms/Coroutines/Coroutines.cpp
test/Transforms/Coroutines/ex5.ll [new file with mode: 0644]