teach various passes about blockaddress. We no longer
crash on any clang tests.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85465 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Transforms/Utils/ValueMapper.cpp b/lib/Transforms/Utils/ValueMapper.cpp
index 21126c9..39331d7 100644
--- a/lib/Transforms/Utils/ValueMapper.cpp
+++ b/lib/Transforms/Utils/ValueMapper.cpp
@@ -113,8 +113,8 @@
if (BlockAddress *BA = dyn_cast<BlockAddress>(C)) {
Function *F = cast<Function>(MapValue(BA->getFunction(), VM));
- BasicBlock *BB = cast<BasicBlock>(MapValue(BA->getBasicBlock(), VM));
- return VM[V] = BlockAddress::get(F, BB);
+ BasicBlock *BB = cast_or_null<BasicBlock>(MapValue(BA->getBasicBlock(),VM));
+ return VM[V] = BlockAddress::get(F, BB ? BB : BA->getBasicBlock());
}
llvm_unreachable("Unknown type of constant!");