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
One nitpick: this test includes a lot of attribute group annotations, like #3 and #5, but these attribute groups aren't defined. If I run opt -verify on this IR file, I get this, which defines 3 attribute groups: https://reviews.llvm.org/P8178
As far as I know there's no practical reason to remove these non-existent attribute group references, but as a personal preference, I'd prefer if you modified the test such that it either (a) doesn't use undefined attribute groups, or (b) defines the attribute groups it uses, for example by using the output from https://reviews.llvm.org/P8178. The reason I'd prefer this is because I think it makes the LLVM IR slightly more readable -- as a reader I won't go looking for a definition of #3 that doesn't exist.