[llvm] [CodeGen][WinEH] Update saved esp for inlined inallocas (PR #116585)

via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 19 23:17:15 PST 2024


================
@@ -774,3 +778,27 @@ void WinEHStatePass::insertStateNumberStore(Instruction *IP, int State) {
                                               RegNode, StateFieldIndex);
   Builder.CreateStore(Builder.getInt32(State), StateField);
 }
+
+void WinEHStatePass::updateEspForInAllocas(Function &F) {
+  for (BasicBlock &BB : F) {
+    for (Instruction &I : BB) {
+      if (auto *Alloca = dyn_cast<AllocaInst>(&I)) {
+        if (!Alloca->isUsedWithInAlloca())
----------------
MuellerMP wrote:

Thanks for your insight @rnk - greatly appreciated!
Fixing up callless inalloca allocas will probably reduce the impact this fix has on O2.
I'm going to look into it the following couple of weekends.
I guess my current fix is still valid for (atleast) those edge cases of using dynamic allocas or statement expressions.
Maybe I should separate the continued work on hoisting callless inalloca allocas if you have concerns regarding the reliability of proving them (new PR).

PS: Not to be obnoxious but if you find any more spare time to spend on WinEH reviews - a colleague of mine has prepped some state handling improvements for /EHa over at #116546.

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


More information about the llvm-commits mailing list