Don't call dominates on unreachable instructions.
authorRafael Espindola <rafael.espindola@gmail.com>
Sun, 26 Feb 2012 01:50:14 +0000 (01:50 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Sun, 26 Feb 2012 01:50:14 +0000 (01:50 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151466 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/Dominators.h
lib/Analysis/InstructionSimplify.cpp

index b539a788a2204a8b9e73c0e6e8f4b966d34a38e5..587307314736a81079ed7db86c901142db8f572b 100644 (file)
@@ -820,7 +820,7 @@ public:
     DT->splitBlock(NewBB);
   }
 
-  bool isReachableFromEntry(const BasicBlock* A) {
+  bool isReachableFromEntry(const BasicBlock* A) const {
     return DT->isReachableFromEntry(A);
   }
 
index 37253f72cf6b33610fae5b72c7c739a59e202fe8..b518d0ca71cda317b11cc5814c452c6db948fc53 100644 (file)
@@ -92,7 +92,8 @@ static bool ValueDominatesPHI(Value *V, PHINode *P, const DominatorTree *DT) {
 
   // If we have a DominatorTree then do a precise test.
   if (DT)
-    return DT->dominates(I, P);
+    return !DT->isReachableFromEntry(P->getParent()) ||
+      !DT->isReachableFromEntry(I->getParent()) || DT->dominates(I, P);
 
   // Otherwise, if the instruction is in the entry block, and is not an invoke,
   // then it obviously dominates all phi nodes.