[GuardWidening] Fix the crash while replacing the users of poison.
authorSerguei Katkov <serguei.katkov@azul.com>
Mon, 3 Apr 2023 09:29:39 +0000 (16:29 +0700)
committerSerguei Katkov <serguei.katkov@azul.com>
Mon, 3 Apr 2023 10:20:38 +0000 (17:20 +0700)
commit2b9509627caa2b0ca27eb1b05099eb016491f027
treefd14c93558c391ab9f22eb9a307f295b71e3db80
parent6afe972195454a1110ed8d20c6f2a547e6366379
[GuardWidening] Fix the crash while replacing the users of poison.

When we replace poison with freeze poison it might appear
that user of poison is a constant (for example vector constant).

In this case we will get that constant will get non-constant operand.

Moreover replacing poison and GlobalValue everywhere in module seems
to be overkill. So the solution will be just make a replacement
only in instructions we visited (contributing to hoisted condition).
Moreover if user of posion is constant, this constant also should need
a freeze and it does not make sense to replace poison with frozen version,
just freeze another constant.

Reviewed By: mkazantsev
Differential Revision: https://reviews.llvm.org/D147429
llvm/lib/Transforms/Scalar/GuardWidening.cpp
llvm/test/Transforms/GuardWidening/hang.ll
llvm/test/Transforms/GuardWidening/posion.ll