just for the hell of it, allow globalopt to statically evaluate
authorChris Lattner <sabre@nondot.org>
Thu, 29 Oct 2009 05:51:50 +0000 (05:51 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 29 Oct 2009 05:51:50 +0000 (05:51 +0000)
static constructors with indirect gotos :)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85495 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/IPO/GlobalOpt.cpp

index f11230c494b49a7f07ecd2772ebe4302c7155bb0..49e9683a556f6ba86222f5e80dcf677e7ed437c5 100644 (file)
@@ -2341,6 +2341,12 @@ static bool EvaluateFunction(Function *F, Constant *&RetVal,
           dyn_cast<ConstantInt>(getVal(Values, SI->getCondition()));
         if (!Val) return false;  // Cannot determine.
         NewBB = SI->getSuccessor(SI->findCaseValue(Val));
+      } else if (IndirectBrInst *IBI = dyn_cast<IndirectBrInst>(CurInst)) {
+        Value *Val = getVal(Values, IBI->getAddress())->stripPointerCasts();
+        if (BlockAddress *BA = dyn_cast<BlockAddress>(Val))
+          NewBB = BA->getBasicBlock();
+        else
+          return false;  // Cannot determine.
       } else if (ReturnInst *RI = dyn_cast<ReturnInst>(CurInst)) {
         if (RI->getNumOperands())
           RetVal = getVal(Values, RI->getOperand(0));