[PATCH] D77920: [Windows EH] Fix the order of Nested try-catches in $tryMap$ table

Aaron Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 10 16:42:16 PDT 2020


asmith updated this revision to Diff 256702.
asmith retitled this revision from "[Windows EH] the order of Nested try-catches in $tryMap$ table" to "[Windows EH] Fix the order of Nested try-catches in $tryMap$ table".
asmith added a comment.

Nit - update comment


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77920/new/

https://reviews.llvm.org/D77920

Files:
  llvm/lib/CodeGen/WinEHPrepare.cpp


Index: llvm/lib/CodeGen/WinEHPrepare.cpp
===================================================================
--- llvm/lib/CodeGen/WinEHPrepare.cpp
+++ llvm/lib/CodeGen/WinEHPrepare.cpp
@@ -260,6 +260,13 @@
 
     // catchpads are separate funclets in C++ EH due to the way rethrow works.
     int TryHigh = CatchLow - 1;
+
+    // MSVC FrameHandler3/4 expect that Catch Handlers in $tryMap$ are
+    // stored in pre-order (outer first, inner next), not post-order.
+    // Add a map here to fix CatchHigh after the children are processed.
+    addTryBlockMapEntry(FuncInfo, TryLow, TryHigh, CatchLow, Handlers);
+    unsigned TBMEIdx = FuncInfo.TryBlockMap.size() - 1;
+
     for (const auto *CatchPad : Handlers) {
       FuncInfo.FuncletBaseStateMap[CatchPad] = CatchLow;
       for (const User *U : CatchPad->users()) {
@@ -280,7 +287,8 @@
       }
     }
     int CatchHigh = FuncInfo.getLastStateNumber();
-    addTryBlockMapEntry(FuncInfo, TryLow, TryHigh, CatchHigh, Handlers);
+    // Now child Catches are processed, update CatchHigh
+    FuncInfo.TryBlockMap[TBMEIdx].CatchHigh = CatchHigh;
     LLVM_DEBUG(dbgs() << "TryLow[" << BB->getName() << "]: " << TryLow << '\n');
     LLVM_DEBUG(dbgs() << "TryHigh[" << BB->getName() << "]: " << TryHigh
                       << '\n');


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77920.256702.patch
Type: text/x-patch
Size: 1291 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200410/581ffa9b/attachment.bin>


More information about the llvm-commits mailing list