From 61a23646c977f5530829742fdf5b901b7d9815a2 Mon Sep 17 00:00:00 2001 From: Sergei Barannikov Date: Wed, 27 Nov 2024 08:03:47 +0300 Subject: [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. --- llvm/lib/CodeGen/SjLjEHPrepare.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'llvm/lib/CodeGen/SjLjEHPrepare.cpp') 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(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) { -- cgit v1.1