aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-08-31 21:17:44 +0000
committerChris Lattner <sabre@nondot.org>2003-08-31 21:17:44 +0000
commit3186d275f73fb0ce2ee0fea6c688daafc82ffac2 (patch)
tree1ffbcffb6018a916570696419201f9419f38aa3f
parent84991f332e926d42090c5a063540f5077d6bf399 (diff)
Fix bug: TailDuplicate/2003-08-31-UnreachableBlocks.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8276 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/Scalar/TailDuplication.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/Transforms/Scalar/TailDuplication.cpp b/lib/Transforms/Scalar/TailDuplication.cpp
index 9427fc664a..688119805a 100644
--- a/lib/Transforms/Scalar/TailDuplication.cpp
+++ b/lib/Transforms/Scalar/TailDuplication.cpp
@@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/Transforms/Scalar.h"
+#include "llvm/Constant.h"
#include "llvm/Function.h"
#include "llvm/iPHINode.h"
#include "llvm/iTerminators.h"
@@ -268,8 +269,10 @@ Value *TailDup::GetValueInBlock(BasicBlock *BB, Value *OrigVal,
ValueHolder &BBVal = ValueMap[BB];
if (BBVal) return BBVal; // Value already computed for this block?
- assert(pred_begin(BB) != pred_end(BB) &&
- "Propagating PHI nodes to unreachable blocks?");
+ // If this block has no predecessors, then it must be unreachable, thus, it
+ // doesn't matter which value we use.
+ if (pred_begin(BB) == pred_end(BB))
+ return BBVal = Constant::getNullValue(OrigVal->getType());
// If there is no value already available in this basic block, we need to
// either reuse a value from an incoming, dominating, basic block, or we need