[Coroutines] Remove corresponding phi values when apply simplifyTerminatorLeadingToRet
authorBrian Gesiak <modocache@gmail.com>
Sun, 5 Jan 2020 22:07:57 +0000 (17:07 -0500)
committerBrian Gesiak <modocache@gmail.com>
Sun, 5 Jan 2020 23:26:30 +0000 (18:26 -0500)
commit83a9321f60d837e4d41c9c08c09ab9e4c171ada4
tree3e6b427e58af48efc3f591308ece551115a8cb29
parent445f4d2310e751a6ab18f84b1d4ad13037ffd819
[Coroutines] Remove corresponding phi values when apply simplifyTerminatorLeadingToRet

Summary:
In addMustTailToCoroResumes, we set musttail on those resume instructions that are followed by a ret instruction. This is done by simplifyTerminatorLeadingToRet which replace a sequence of branches leading to a ret with a clone of the ret.

However it forgets to remove corresponding PHI values that come from basic block of replaced branch, and may cause jumpthreading pass hangs (https://bugs.llvm.org/show_bug.cgi?id=43720)

This patch fix this issue

Test Plan:
cppcoro library with O3+flto
check-llvm

Reviewers: modocache, GorNishanov, lewissbaker

Reviewed By: modocache

Subscribers: mehdi_amini, EricWF, hiraditya, dexonsmith, jfb, llvm-commits

Tags: #llvm

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

Patch by junparser (JunMa)!
llvm/lib/Transforms/Coroutines/CoroSplit.cpp
llvm/test/Transforms/Coroutines/coro-split-musttail.ll
llvm/test/Transforms/Coroutines/coro-split-musttail1.ll [new file with mode: 0644]