[PATCH] D79474: [Windows EH] Fix the order of Nested try-catches in $tryMap$ table
Ten Tzen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 6 14:44:39 PDT 2020
tentzen updated this revision to Diff 262478.
tentzen added a comment.
fixed a comment.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D79474/new/
https://reviews.llvm.org/D79474
Files:
llvm/lib/CodeGen/WinEHPrepare.cpp
llvm/test/CodeGen/X86/win-catchpad-nested-cxx.ll
Index: llvm/test/CodeGen/X86/win-catchpad-nested-cxx.ll
===================================================================
--- llvm/test/CodeGen/X86/win-catchpad-nested-cxx.ll
+++ llvm/test/CodeGen/X86/win-catchpad-nested-cxx.ll
@@ -63,13 +63,13 @@
; CHECK-NEXT: .long 1
; CHECK: $tryMap$try_in_catch:
-; CHECK-NEXT: .long 2
-; CHECK-NEXT: .long 2
+; CHECK-NEXT: .long 0
+; CHECK-NEXT: .long 0
; CHECK-NEXT: .long 3
; CHECK-NEXT: .long 1
; CHECK-NEXT: .long ($handlerMap$0$try_in_catch)
-; CHECK-NEXT: .long 0
-; CHECK-NEXT: .long 0
+; CHECK-NEXT: .long 2
+; CHECK-NEXT: .long 2
; CHECK-NEXT: .long 3
; CHECK-NEXT: .long 1
; CHECK-NEXT: .long ($handlerMap$1$try_in_catch)
Index: llvm/lib/CodeGen/WinEHPrepare.cpp
===================================================================
--- llvm/lib/CodeGen/WinEHPrepare.cpp
+++ llvm/lib/CodeGen/WinEHPrepare.cpp
@@ -263,6 +263,13 @@
// catchpads are separate funclets in C++ EH due to the way rethrow works.
int TryHigh = CatchLow - 1;
+
+ // MSVC FrameHandler3/4 expect Catch Handlers in $tryMap$ are
+ // stored in pre-order (outer first, inner next), not post-order
+ // Add to map here. Fix the CatchHigh after 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()) {
@@ -283,7 +290,9 @@
}
}
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: D79474.262478.patch
Type: text/x-patch
Size: 2001 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200506/2b8a3ade/attachment.bin>
More information about the llvm-commits
mailing list