diff options
author | Jun Ma <JunMa@linux.alibaba.com> | 2020-03-18 11:42:16 +0800 |
---|---|---|
committer | Tom Stellard <tstellar@redhat.com> | 2020-04-29 17:13:34 -0700 |
commit | e4312b950dd7b019e14b991a17d6ac260b8e8082 (patch) | |
tree | fe927dd2b2e8490fe9af2fba9f9092596f617454 /llvm/lib/Transforms | |
parent | 9cf9cf2a398ce70d9187afa59db6500e7a1f2cd0 (diff) | |
download | bcm5719-llvm-e4312b950dd7b019e14b991a17d6ac260b8e8082.tar.gz bcm5719-llvm-e4312b950dd7b019e14b991a17d6ac260b8e8082.zip |
[Coroutines] Fix PR45130
For now, when final suspend can be simplified by simplifySuspendPoint,
handleFinalSuspend is executed as well to remove last case in switch
instruction. This patch fixes it.
Differential Revision: https://reviews.llvm.org/D76345
(cherry picked from commit 032251e34d17c1cbf21e7571514bb775ed5cdf30)
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Coroutines/CoroSplit.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp index 66cb3e74e53..1e067a45d01 100644 --- a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp +++ b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp @@ -1155,7 +1155,10 @@ static void simplifySuspendPoints(coro::Shape &Shape) { if (N == 0) return; while (true) { - if (simplifySuspendPoint(cast<CoroSuspendInst>(S[I]), Shape.CoroBegin)) { + auto SI = cast<CoroSuspendInst>(S[I]); + // Leave final.suspend to handleFinalSuspend since it is undefined behavior + // to resume a coroutine suspended at the final suspend point. + if (!SI->isFinal() && simplifySuspendPoint(SI, Shape.CoroBegin)) { if (--N == I) break; std::swap(S[I], S[N]); |