[llvm] [WinEH] Emit state stores for SEH scopes (PR #116546)

Maurice Heumann via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 24 04:13:11 PST 2024


================
@@ -653,7 +672,15 @@ void WinEHStatePass::addStateStores(Function &F, WinEHFuncInfo &FuncInfo) {
       InitialState = FinalState = ParentBaseState;
     for (Instruction &I : *BB) {
       auto *Call = dyn_cast<CallBase>(&I);
-      if (!Call || !isStateStoreNeeded(Personality, *Call))
+      if (!Call)
+        continue;
+
+      if (isSehScopeEnd(*Call)) {
----------------
momo5502 wrote:

I added the state store before the scope end. To do that, I added a condition to `getStateForCall` as unlike other invoke instructions, that reference the state of the unwind destination, this one should reference the state of the normal destination (as the unwind destination is the same as for SEH scope begin).

I also thought about adapting `calculateStateNumbersForInvokes` within `WinEHPrepare.cpp`, which fills the `InvokeStateMap`. However, I wasn't sure what is better, so I put the SEH scope end check into `getStateForCall`, as that would be the smallest change.

https://github.com/llvm/llvm-project/pull/116546


More information about the llvm-commits mailing list