diff options
author | Sergei Barannikov <barannikov88@gmail.com> | 2024-11-27 08:03:47 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-27 08:03:47 +0300 |
commit | 61a23646c977f5530829742fdf5b901b7d9815a2 (patch) | |
tree | f86619761aa360687d0318bbf6bc99aba9a9bf3c /llvm/lib/CodeGen/SjLjEHPrepare.cpp | |
parent | d9c4e9ffe78c34db247b164aa46eea2625b08d3a (diff) | |
download | llvm-61a23646c977f5530829742fdf5b901b7d9815a2.zip llvm-61a23646c977f5530829742fdf5b901b7d9815a2.tar.gz llvm-61a23646c977f5530829742fdf5b901b7d9815a2.tar.bz2 |
[SjLjEHPrepare] Configure call sites correctly (#117656)
After 9fe78db4, the pass inserts `store volatile i32 -1, ptr %call_site`
before all invoke instruction except the one in the entry block, which
has the effect of bypassing landing pads on exceptions.
When configuring the call site for a potentially throwing instruction
check that it is not `InvokeInst` -- they are handled by earlier code.
Diffstat (limited to 'llvm/lib/CodeGen/SjLjEHPrepare.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SjLjEHPrepare.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/SjLjEHPrepare.cpp b/llvm/lib/CodeGen/SjLjEHPrepare.cpp index c10c7401..9630ba4 100644 --- a/llvm/lib/CodeGen/SjLjEHPrepare.cpp +++ b/llvm/lib/CodeGen/SjLjEHPrepare.cpp @@ -435,6 +435,10 @@ bool SjLjEHPrepareImpl::setupEntryBlockAndCallSites(Function &F) { // where to look for it. Builder.CreateCall(FuncCtxFn, FuncCtx); + // Register the function context and make sure it's known to not throw. + CallInst *Register = Builder.CreateCall(RegisterFn, FuncCtx, ""); + Register->setDoesNotThrow(); + // At this point, we are all set up, update the invoke instructions to mark // their call_site values. for (unsigned I = 0, E = Invokes.size(); I != E; ++I) { @@ -457,15 +461,10 @@ bool SjLjEHPrepareImpl::setupEntryBlockAndCallSites(Function &F) { if (&BB == &F.front()) continue; for (Instruction &I : BB) - if (I.mayThrow()) + if (!isa<InvokeInst>(I) && I.mayThrow()) insertCallSiteStore(&I, -1); } - // Register the function context and make sure it's known to not throw - CallInst *Register = CallInst::Create( - RegisterFn, FuncCtx, "", EntryBB->getTerminator()->getIterator()); - Register->setDoesNotThrow(); - // Following any allocas not in the entry block, update the saved SP in the // jmpbuf to the new value. for (BasicBlock &BB : F) { |