HomePhabricator

[LazyValueInfo] Insert an Overdefined placeholder to prevent infinite recursion

Authored by guopeilin on May 7 2021, 1:05 AM.

Description

[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