diff options
author | Juneyoung Lee <aqjune@gmail.com> | 2020-02-29 13:10:31 +0900 |
---|---|---|
committer | Juneyoung Lee <aqjune@gmail.com> | 2020-03-01 07:35:58 +0900 |
commit | 282ec40504369e6533e03d7690417feb0da8cdd4 (patch) | |
tree | d43a5013d847968f1b8e5fb668004964cc5326f4 /llvm/lib/Analysis/ValueTracking.cpp | |
parent | 5cbb26569474f33a39942255ba96f3427c155087 (diff) | |
download | llvm-282ec40504369e6533e03d7690417feb0da8cdd4.zip llvm-282ec40504369e6533e03d7690417feb0da8cdd4.tar.gz llvm-282ec40504369e6533e03d7690417feb0da8cdd4.tar.bz2 |
[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
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 0520ce5..650990d 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; } |