aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2012-03-30 16:46:21 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2012-03-30 16:46:21 +0000
commit092c5ccf5bdcaa53151645e5628cec77fcf4062b (patch)
tree8d189635dc35b19fea16c151d3b4b61bb1ec2764 /lib
parent0e4fa5ff365fccff46870b7d5d8d4d1d46e77986 (diff)
Handle unreachable code in the dominates functions. This changes users when
needed for correctness, but still doesn't clean up code that now unnecessary checks for reachability. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153755 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/VMCore/Dominators.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/VMCore/Dominators.cpp b/lib/VMCore/Dominators.cpp
index af51a05c8b..6f97774fc6 100644
--- a/lib/VMCore/Dominators.cpp
+++ b/lib/VMCore/Dominators.cpp
@@ -88,8 +88,13 @@ bool DominatorTree::dominates(const Instruction *Def,
const BasicBlock *UseBB = User->getParent();
const BasicBlock *DefBB = Def->getParent();
- assert(isReachableFromEntry(DefBB) && isReachableFromEntry(UseBB) &&
- "We only handle reachable blocks");
+ // Any unreachable use is dominated, even if Def == User.
+ if (!isReachableFromEntry(UseBB))
+ return true;
+
+ // Unreachable definitions don't dominate anything.
+ if (!isReachableFromEntry(DefBB))
+ return false;
// An instruction doesn't dominate a use in itself.
if (Def == User)
@@ -119,8 +124,13 @@ bool DominatorTree::dominates(const Instruction *Def,
const BasicBlock *UseBB) const {
const BasicBlock *DefBB = Def->getParent();
- assert(isReachableFromEntry(DefBB) && isReachableFromEntry(UseBB) &&
- "We only handle reachable blocks");
+ // Any unreachable use is dominated, even if DefBB == UseBB.
+ if (!isReachableFromEntry(UseBB))
+ return true;
+
+ // Unreachable definitions don't dominate anything.
+ if (!isReachableFromEntry(DefBB))
+ return false;
if (DefBB == UseBB)
return false;