Commit 282ec405 authored by Juneyoung Lee's avatar Juneyoung Lee
Browse files

[ValueTracking] A value is never undef or poison if it must raise UB

Summary:
This patch helps isGuaranteedNotToBeUndefOrPoison return true if the value
makes the program always undefined.

According to value tracking functions' comments, it is not still in consensus
whether a poison value can be bitwise or not, so conservatively only the case with
i1 is considered.

Reviewers: spatel, lebedev.ri, reames, nlopes, regehr

Reviewed By: nlopes

Subscribers: uenoku, hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D75396
parent 5cbb2656
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -4551,6 +4551,13 @@ bool llvm::isGuaranteedNotToBeUndefOrPoison(const Value *V) {
      return true;
  }

  if (auto I = dyn_cast<Instruction>(V)) {
    if (programUndefinedIfFullPoison(I) && I->getType()->isIntegerTy(1))
      // Note: once we have an agreement that poison is a value-wise concept,
      // we can remove the isIntegerTy(1) constraint.
      return true;
  }

  return false;
}