[PATCH] D128815: [LICM] Do not sink instructions that use tokens. PR56243
Max Kazantsev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 29 06:12:21 PDT 2022
mkazantsev created this revision.
mkazantsev added reviewers: reames, fhahn, lebedev.ri, nikic, efriedma.
Herald added subscribers: asbirlea, hiraditya.
Herald added a project: All.
mkazantsev requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
In current implementation, definition of LCSSA is violated by tokens.
In fact, token values that are defined in loop can be sunk down the loop
without creation of LCSSA Phis for their token arguments. Later on, any
pass that expects that all in-loop values go through phis may produce
incorrect IR on it.
https://github.com/llvm/llvm-project/issues/56243 shows how it happens
to LoopSimplifyCFG that may break SSA form because it is unable to fix a
LCSSA Phi for token out going out of the loop. But potentially, any other
transform that relies on definition of LCSSA may be affected.
This patch prohibits LICM from introducing new out-of-loop users of
token defs. It does not fight the situation when such uses existed before
the transform.
This is not a full solution for this general problem. The full solution should
possibly revisit how we define LCSSA and tokens. It just addresses one case
of sinking. Note that LICM is not the only pass that may introduce an out-of-loop
use of token which didn't exist: for example, InstCombine can do the same.
They should be addressed separately, in a similar manner. So far I could not
create a real test that would crash on this, which doesn't mean there is no
problem.
https://reviews.llvm.org/D128815
Files:
llvm/lib/Transforms/Scalar/LICM.cpp
llvm/test/Transforms/LICM/pr56243.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128815.440973.patch
Type: text/x-patch
Size: 4416 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220629/41fff7aa/attachment.bin>
More information about the llvm-commits
mailing list