diff options
author | Chris Lattner <sabre@nondot.org> | 2009-10-31 20:13:24 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-10-31 20:13:24 +0000 |
commit | c1dc35094e3ffcb4b3a765f0f786b8a2948bc321 (patch) | |
tree | fc2ae649b0f036d8ad53661a318ae6e9bc43d57f | |
parent | 7d83ebcadd725d050cc58962e9b7c4312d676e7f (diff) | |
download | external_llvm-c1dc35094e3ffcb4b3a765f0f786b8a2948bc321.zip external_llvm-c1dc35094e3ffcb4b3a765f0f786b8a2948bc321.tar.gz external_llvm-c1dc35094e3ffcb4b3a765f0f786b8a2948bc321.tar.bz2 |
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
-rw-r--r-- | lib/Transforms/IPO/GlobalOpt.cpp | 3 | ||||
-rw-r--r-- | lib/Transforms/Utils/ValueMapper.cpp | 9 |
2 files changed, 8 insertions, 4 deletions
diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp index 49e9683..9495100 100644 --- a/lib/Transforms/IPO/GlobalOpt.cpp +++ b/lib/Transforms/IPO/GlobalOpt.cpp @@ -2345,8 +2345,7 @@ static bool EvaluateFunction(Function *F, Constant *&RetVal, Value *Val = getVal(Values, IBI->getAddress())->stripPointerCasts(); if (BlockAddress *BA = dyn_cast<BlockAddress>(Val)) NewBB = BA->getBasicBlock(); - else - return false; // Cannot determine. + if (NewBB == 0) return false; // Cannot determine. } else if (ReturnInst *RI = dyn_cast<ReturnInst>(CurInst)) { if (RI->getNumOperands()) RetVal = getVal(Values, RI->getOperand(0)); diff --git a/lib/Transforms/Utils/ValueMapper.cpp b/lib/Transforms/Utils/ValueMapper.cpp index 39331d7..7929eb9 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<BlockAddress>(C)) { Function *F = cast<Function>(MapValue(BA->getFunction(), VM)); - BasicBlock *BB = cast_or_null<BasicBlock>(MapValue(BA->getBasicBlock(),VM)); - return VM[V] = BlockAddress::get(F, BB ? BB : BA->getBasicBlock()); + BasicBlock *BB = 0; + if (BA->getBasicBlock()) { + BB = cast_or_null<BasicBlock>(MapValue(BA->getBasicBlock(),VM)); + BB = BB ? BB : BA->getBasicBlock(); + } + + return VM[V] = BlockAddress::get(F, BB); } llvm_unreachable("Unknown type of constant!"); |