From: Chris Lattner Date: Thu, 29 Oct 2009 05:51:50 +0000 (+0000) Subject: just for the hell of it, allow globalopt to statically evaluate X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=b3d5a65d94ca017570fe86578423186c6a2f642e;p=oota-llvm.git just for the hell of it, allow globalopt to statically evaluate static constructors with indirect gotos :) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85495 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp index f11230c494b..49e9683a556 100644 --- a/lib/Transforms/IPO/GlobalOpt.cpp +++ b/lib/Transforms/IPO/GlobalOpt.cpp @@ -2341,6 +2341,12 @@ static bool EvaluateFunction(Function *F, Constant *&RetVal, dyn_cast(getVal(Values, SI->getCondition())); if (!Val) return false; // Cannot determine. NewBB = SI->getSuccessor(SI->findCaseValue(Val)); + } else if (IndirectBrInst *IBI = dyn_cast(CurInst)) { + Value *Val = getVal(Values, IBI->getAddress())->stripPointerCasts(); + if (BlockAddress *BA = dyn_cast(Val)) + NewBB = BA->getBasicBlock(); + else + return false; // Cannot determine. } else if (ReturnInst *RI = dyn_cast(CurInst)) { if (RI->getNumOperands()) RetVal = getVal(Values, RI->getOperand(0));