aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ValueTracking.cpp
diff options
context:
space:
mode:
authorJuneyoung Lee <aqjune@gmail.com>2020-05-13 00:37:38 +0900
committerJuneyoung Lee <aqjune@gmail.com>2020-05-13 10:16:47 +0900
commitd3eb51f0626cc86af904bfbdb061fecbd90ffdc5 (patch)
tree21d546e0d6a638d9c3354315be4153d588cb7396 /llvm/lib/Analysis/ValueTracking.cpp
parent0796b170fb3bf38e6cc4e59746120b37c9a9cd9f (diff)
downloadllvm-d3eb51f0626cc86af904bfbdb061fecbd90ffdc5.zip
llvm-d3eb51f0626cc86af904bfbdb061fecbd90ffdc5.tar.gz
llvm-d3eb51f0626cc86af904bfbdb061fecbd90ffdc5.tar.bz2
[ValueTracking] Fix crash in isGuaranteedNotToBeUndefOrPoison when V is in an unreachable block
Summary: This fixes PR45885 by fixing isGuaranteedNotToBeUndefOrPoison so it does not look into dominating branch conditions of V when V is an instruction in an unreachable block. Reviewers: spatel, nikic, lebedev.ri Reviewed By: nikic Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D79790
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r--llvm/lib/Analysis/ValueTracking.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 691e452..a4b0202 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -4821,12 +4821,17 @@ bool llvm::isGuaranteedNotToBeUndefOrPoison(const Value *V,
if (!CtxI || !CtxI->getParent() || !DT)
return false;
+ auto *DNode = DT->getNode(CtxI->getParent());
+ if (!DNode)
+ // Unreachable block
+ return false;
+
// If V is used as a branch condition before reaching CtxI, V cannot be
// undef or poison.
// br V, BB1, BB2
// BB1:
// CtxI ; V cannot be undef or poison here
- auto Dominator = DT->getNode(CtxI->getParent())->getIDom();
+ auto *Dominator = DNode->getIDom();
while (Dominator) {
auto *TI = Dominator->getBlock()->getTerminator();