[llvm-dev] A bug related with undef value when bootstrap MemorySSA.cpp

Sanjoy Das via llvm-dev llvm-dev at lists.llvm.org
Mon Jul 17 11:43:13 PDT 2017

On Mon, Jul 17, 2017 at 11:21 AM, Daniel Berlin <dberlin at dberlin.org> wrote:
>> On Mon, Jul 17, 2017 at 10:32 AM, Xinliang David Li <davidxl at google.com>
>> wrote:
>> > The issue blocks another optimization patch and Wei has spent huge
>> > amount of
>> > effort isolating the the bootstrap failure to this same problem. I agree
>> > with Wei that other developers may also get hit by the same issue and
>> > the
>> > cost of leaving this issue open for long can be very high to the
>> > community.
>> I can't speak for others, but I am fine with adding a workaround for
>> this.  However, I suspect isGuaranteedNotToBeUndefOrPoison in
>> LoopUnswitch may regress other benchmarks.
> Any other thoughts on a more minimal fix?

I can't think of any good answers here.

The semantic we want is "branching on poison or undef is undefined
behavior" (which lets us do propagateEquality).  Given that, we could
be clever about implementing isGuaranteedNotToBeUndefOrPoison; for
instance if we have:

do {
  if (a != b) {
} while (...);

then we can use post-domination to prove that "a != b" is not undef
(otherwise the loop is guaranteed to have undefined behavior).

(I hate to say this), a more aggressive fix is to introduce a "freeze"
intrinsic that freezes only an i1.  LoopUnswitch would wrap the loop
invariant condition in this after hoisting the branch.  This would be
a poor man's version of the more invasive patches Juneyoung already
has developed.

-- Sanjoy

More information about the llvm-dev mailing list