summaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/SjLjEHPrepare.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/SjLjEHPrepare.cpp')
-rw-r--r--llvm/lib/CodeGen/SjLjEHPrepare.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/SjLjEHPrepare.cpp b/llvm/lib/CodeGen/SjLjEHPrepare.cpp
index d2fd4a6d8fd9..8211e3d6a9dd 100644
--- a/llvm/lib/CodeGen/SjLjEHPrepare.cpp
+++ b/llvm/lib/CodeGen/SjLjEHPrepare.cpp
@@ -472,8 +472,12 @@ bool SjLjEHPrepare::setupEntryBlockAndCallSites(Function &F) {
// Finally, for any returns from this function, if this function contains an
// invoke, add a call to unregister the function context.
- for (ReturnInst *Return : Returns)
- CallInst::Create(UnregisterFn, FuncCtx, "", Return);
+ for (ReturnInst *Return : Returns) {
+ Instruction *InsertPoint = Return;
+ if (CallInst *CI = Return->getParent()->getTerminatingMustTailCall())
+ InsertPoint = CI;
+ CallInst::Create(UnregisterFn, FuncCtx, "", InsertPoint);
+ }
return true;
}