[LazyValueInfo] Insert an Overdefined placeholder to prevent infinite recursion
authorPeilin Guo <guopeilin1@huawei.com>
Fri, 7 May 2021 08:05:50 +0000 (16:05 +0800)
committerPeilin Guo <guopeilin1@huawei.com>
Fri, 7 May 2021 08:05:50 +0000 (16:05 +0800)
commit911a541620bcc78e637589b8623d94b8f3cdafba
tree38746ccd83db5c58f51380f475c01e3f0190ff17
parent9deb7eeaf76c3285b72ce75d30fcade63b96e2dc
[LazyValueInfo] Insert an Overdefined placeholder to prevent infinite recursion

getValueFromCondition() uses a Visited set to record the intermediate value.
However, it uses a postorder way to compute the value first and update the
Visited set later. Thus it will be trapped into an infinite recursion if there
exists IRs that use no dominated by its def as in this example:

  %tmp3 = or i1 undef, %tmp4
  %tmp4 = or i1 undef, %tmp3

To prevent this, we can insert an Overdefined placeholder into the set
before computing the actual value.

Reviewed by: nikic

Differential Revision: https://reviews.llvm.org/D101273
llvm/lib/Analysis/LazyValueInfo.cpp
llvm/test/Transforms/JumpThreading/insert-placeholder-to-prevent-infinite-recursion.ll [new file with mode: 0644]