diff options
| author | John McCall <rjmccall@apple.com> | 2011-06-01 02:17:11 +0000 | 
|---|---|---|
| committer | John McCall <rjmccall@apple.com> | 2011-06-01 02:17:11 +0000 | 
| commit | fca778626755d862b3a09a2473a76828d2c5aaa2 (patch) | |
| tree | 39bc32d64167f19582f59d124af5757a396fd179 /llvm/lib/Transforms | |
| parent | 48581a64547a14475cf3ba7c9ccc1f073d081e6e (diff) | |
| download | bcm5719-llvm-fca778626755d862b3a09a2473a76828d2c5aaa2.tar.gz bcm5719-llvm-fca778626755d862b3a09a2473a76828d2c5aaa2.zip | |
First, do no harm -- even if we can't find a selector for an enclosing
landing pad, forward llvm.eh.resume calls to it instead of turning them
invalidly into invokes.
llvm-svn: 132382
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Utils/InlineFunction.cpp | 22 | 
1 files changed, 18 insertions, 4 deletions
| diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp index d2fd07aed10..4a829874832 100644 --- a/llvm/lib/Transforms/Utils/InlineFunction.cpp +++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp @@ -214,13 +214,24 @@ BasicBlock *InvokeInliningInfo::getInnerUnwindDest() {  /// at the end of the given block, as a branch to the inner unwind  /// block.  Returns true if the call was forwarded.  bool InvokeInliningInfo::forwardEHResume(CallInst *call, BasicBlock *src) { +  // First, check whether this is a call to the intrinsic.    Function *fn = dyn_cast<Function>(call->getCalledValue());    if (!fn || fn->getName() != "llvm.eh.resume")      return false; +   +  // At this point, we need to return true on all paths, because +  // otherwise we'll construct an invoke of the intrinsic, which is +  // not well-formed. -  // If this fails, maybe it should be a fatal error. +  // Try to find or make an inner unwind dest, which will fail if we +  // can't find a selector call for the outer unwind dest.    BasicBlock *dest = getInnerUnwindDest(); -  if (!dest) return false; +  bool hasSelector = (dest != 0); + +  // If we failed, just use the outer unwind dest, dropping the +  // exception and selector on the floor. +  if (!hasSelector) +    dest = OuterUnwindDest;    // Make a branch.    BranchInst::Create(dest, src); @@ -228,8 +239,11 @@ bool InvokeInliningInfo::forwardEHResume(CallInst *call, BasicBlock *src) {    // Update the phis in the destination.  They were inserted in an    // order which makes this work.    addIncomingPHIValuesForInto(src, dest); -  InnerExceptionPHI->addIncoming(call->getArgOperand(0), src); -  InnerSelectorPHI->addIncoming(call->getArgOperand(1), src); + +  if (hasSelector) { +    InnerExceptionPHI->addIncoming(call->getArgOperand(0), src); +    InnerSelectorPHI->addIncoming(call->getArgOperand(1), src); +  }    return true;  } | 

