[llvm] 282ec40 - [ValueTracking] A value is never undef or poison if it must raise UB

Juneyoung Lee via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 29 14:36:06 PST 2020


Author: Juneyoung Lee
Date: 2020-03-01T07:35:58+09:00
New Revision: 282ec40504369e6533e03d7690417feb0da8cdd4

URL: https://github.com/llvm/llvm-project/commit/282ec40504369e6533e03d7690417feb0da8cdd4
DIFF: https://github.com/llvm/llvm-project/commit/282ec40504369e6533e03d7690417feb0da8cdd4.diff

LOG: [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

Added: 
    

Modified: 
    llvm/lib/Analysis/ValueTracking.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 0520ce5abc05..650990d22a3f 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -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;
 }
 


        


More information about the llvm-commits mailing list