From c1dc35094e3ffcb4b3a765f0f786b8a2948bc321 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 31 Oct 2009 20:13:24 +0000 Subject: adjust a couple xforms to work with null bb's in BlockAddress. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85680 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Utils/ValueMapper.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib/Transforms/Utils/ValueMapper.cpp') diff --git a/lib/Transforms/Utils/ValueMapper.cpp b/lib/Transforms/Utils/ValueMapper.cpp index 39331d7816..7929eb9ac2 100644 --- a/lib/Transforms/Utils/ValueMapper.cpp +++ b/lib/Transforms/Utils/ValueMapper.cpp @@ -113,8 +113,13 @@ Value *llvm::MapValue(const Value *V, ValueMapTy &VM) { if (BlockAddress *BA = dyn_cast(C)) { Function *F = cast(MapValue(BA->getFunction(), VM)); - BasicBlock *BB = cast_or_null(MapValue(BA->getBasicBlock(),VM)); - return VM[V] = BlockAddress::get(F, BB ? BB : BA->getBasicBlock()); + BasicBlock *BB = 0; + if (BA->getBasicBlock()) { + BB = cast_or_null(MapValue(BA->getBasicBlock(),VM)); + BB = BB ? BB : BA->getBasicBlock(); + } + + return VM[V] = BlockAddress::get(F, BB); } llvm_unreachable("Unknown type of constant!"); -- cgit v1.2.3