adjust a couple xforms to work with null bb's in BlockAddress.
authorChris Lattner <sabre@nondot.org>
Sat, 31 Oct 2009 20:13:24 +0000 (20:13 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 31 Oct 2009 20:13:24 +0000 (20:13 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85680 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/IPO/GlobalOpt.cpp
lib/Transforms/Utils/ValueMapper.cpp

index 49e9683a556f6ba86222f5e80dcf677e7ed437c5..94951002b4610acf57bf0acdd350a3fab12a2e00 100644 (file)
@@ -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));
index 39331d78169a36585b73dcac0ad049413f43ac13..7929eb9ac2b032fb65e7ecf9ac1d3c30ee1f861b 100644 (file)
@@ -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!");