[Coroutines] Don't transform cmpinst prematurely in simplifyTerminatorLeadingToRet
authorChuanqi Xu <yedeng.yd@linux.alibaba.com>
Fri, 30 Jun 2023 05:59:39 +0000 (13:59 +0800)
committerChuanqi Xu <yedeng.yd@linux.alibaba.com>
Fri, 30 Jun 2023 06:27:19 +0000 (14:27 +0800)
commit0a7ff0960e33b6b27961afa5cbb7dd9eb4f1a283
treee9900667d490fe24436a4eaab089560600db732e
parent19b1d3bd7eeecbeb1e45045960faf325c7bc5c64
[Coroutines] Don't transform cmpinst prematurely in simplifyTerminatorLeadingToRet

Previously, we would try to transform cmpinst in
simplifyTerminatorLeadingToRet if we found it was a constant. However,
this is incorrect.

Since the resolved constants in simplifyTerminatorLeadingToRet are not
truely constants. They are basically constants along cerntain code
paths.

In this way, it is clearly incorrect to transform the compare
instruction to a constant.

It will cause confusing miscompilations. This patch tries to fix this.
llvm/lib/Transforms/Coroutines/CoroSplit.cpp
llvm/test/Transforms/Coroutines/coro-split-musttail12.ll [new file with mode: 0644]