aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/IPO/GlobalOpt.cpp
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2012-02-12 05:09:35 +0000
committerNick Lewycky <nicholas@mxc.ca>2012-02-12 05:09:35 +0000
commit132bd9ce56e1f6d0231c34acec738a8bc92c9cfa (patch)
tree5c62e37a2c5cdf9180443a6effa93c334f62dcd7 /lib/Transforms/IPO/GlobalOpt.cpp
parent6f160d3d78c1b7839b6bc053339e1fdfbf0276de (diff)
downloadexternal_llvm-132bd9ce56e1f6d0231c34acec738a8bc92c9cfa.zip
external_llvm-132bd9ce56e1f6d0231c34acec738a8bc92c9cfa.tar.gz
external_llvm-132bd9ce56e1f6d0231c34acec738a8bc92c9cfa.tar.bz2
Handle InvokeInst in EvaluateBlock. Don't try to support exceptions, it's just
that no optz'ns have run yet to convert invokes to calls. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150326 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO/GlobalOpt.cpp')
-rw-r--r--lib/Transforms/IPO/GlobalOpt.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp
index c7f71a6..d959a22 100644
--- a/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/lib/Transforms/IPO/GlobalOpt.cpp
@@ -2403,18 +2403,19 @@ static bool EvaluateBlock(BasicBlock::iterator CurInst, BasicBlock *&NextBB,
UndefValue::get(Ty),
AI->getName()));
InstResult = AllocaTmps.back();
- } else if (CallInst *CI = dyn_cast<CallInst>(CurInst)) {
+ } else if (isa<CallInst>(CurInst) || isa<InvokeInst>(CurInst)) {
+ CallSite CS(CurInst);
// Debug info can safely be ignored here.
- if (isa<DbgInfoIntrinsic>(CI)) {
+ if (isa<DbgInfoIntrinsic>(CS.getInstruction())) {
++CurInst;
continue;
}
// Cannot handle inline asm.
- if (isa<InlineAsm>(CI->getCalledValue())) return false;
+ if (isa<InlineAsm>(CS.getCalledValue())) return false;
- if (MemSetInst *MSI = dyn_cast<MemSetInst>(CI)) {
+ if (MemSetInst *MSI = dyn_cast<MemSetInst>(CS.getInstruction())) {
if (MSI->isVolatile()) return false;
Constant *Ptr = getVal(Values, MSI->getDest());
Constant *Val = getVal(Values, MSI->getValue());
@@ -2430,13 +2431,12 @@ static bool EvaluateBlock(BasicBlock::iterator CurInst, BasicBlock *&NextBB,
// Resolve function pointers.
Function *Callee = dyn_cast<Function>(getVal(Values,
- CI->getCalledValue()));
- if (!Callee) return false; // Cannot resolve.
+ CS.getCalledValue()));
+ if (!Callee || Callee->mayBeOverridden())
+ return false; // Cannot resolve.
SmallVector<Constant*, 8> Formals;
- CallSite CS(CI);
- for (User::op_iterator i = CS.arg_begin(), e = CS.arg_end();
- i != e; ++i)
+ for (User::op_iterator i = CS.arg_begin(), e = CS.arg_end(); i != e; ++i)
Formals.push_back(getVal(Values, *i));
if (Callee->isDeclaration()) {
@@ -2457,6 +2457,11 @@ static bool EvaluateBlock(BasicBlock::iterator CurInst, BasicBlock *&NextBB,
TLI))
return false;
InstResult = RetVal;
+
+ if (InvokeInst *II = dyn_cast<InvokeInst>(CurInst)) {
+ NextBB = II->getNormalDest();
+ return true;
+ }
}
} else if (isa<TerminatorInst>(CurInst)) {
if (BranchInst *BI = dyn_cast<BranchInst>(CurInst)) {