summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-10-31 20:13:24 +0000
committerChris Lattner <sabre@nondot.org>2009-10-31 20:13:24 +0000
commit3c89c53f35e89956be26c7b4c5163164b41e75e5 (patch)
tree9ed3e55826736be51103e4fa4219a745d3793180 /llvm/lib
parent0a65b636ce884c07094a110d478d58acc4b37800 (diff)
downloadbcm5719-llvm-3c89c53f35e89956be26c7b4c5163164b41e75e5.tar.gz
bcm5719-llvm-3c89c53f35e89956be26c7b4c5163164b41e75e5.zip
adjust a couple xforms to work with null bb's in BlockAddress.
llvm-svn: 85680
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/IPO/GlobalOpt.cpp3
-rw-r--r--llvm/lib/Transforms/Utils/ValueMapper.cpp9
2 files changed, 8 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
index 49e9683a556..94951002b46 100644
--- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/llvm/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/llvm/lib/Transforms/Utils/ValueMapper.cpp b/llvm/lib/Transforms/Utils/ValueMapper.cpp
index 39331d78169..7929eb9ac2b 100644
--- a/llvm/lib/Transforms/Utils/ValueMapper.cpp
+++ b/llvm/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!");
OpenPOWER on IntegriCloud