[PATCH] D13798: [WinEH] Fix CatchRetSuccessorColorMap accounting

Joseph Tremoulet via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 16 00:51:36 PDT 2015


JosephTremoulet created this revision.
JosephTremoulet added a reviewer: majnemer.
JosephTremoulet added a subscriber: llvm-commits.

We now use the block for the catchpad itself, rather than its normal
successor, as the funclet entry.
Putting the normal successor in the map leads downstream funclet
membership computations to erroneous results.

http://reviews.llvm.org/D13798

Files:
  lib/CodeGen/WinEHPrepare.cpp
  test/CodeGen/X86/win-catchpad-nested.ll

Index: test/CodeGen/X86/win-catchpad-nested.ll
===================================================================
--- /dev/null
+++ test/CodeGen/X86/win-catchpad-nested.ll
@@ -0,0 +1,41 @@
+; RUN: llc -mtriple=x86_64-pc-windows-coreclr < %s | FileCheck %s
+
+declare void @ProcessCLRException()
+
+declare void @f()
+
+define void @test1() personality void ()* @ProcessCLRException {
+entry:
+  invoke void @f()
+          to label %exit unwind label %outer.pad
+outer.pad:
+  %outer = catchpad [i32 1]
+          to label %outer.catch unwind label %outer.end
+outer.catch:
+  invoke void @f()
+          to label %outer.ret unwind label %inner.pad
+inner.pad:
+  %inner = catchpad [i32 2]
+          to label %inner.ret unwind label %inner.end
+inner.ret:
+  catchret %inner to label %outer.ret
+inner.end:
+  catchendpad unwind label %outer.end
+outer.ret:
+  catchret %outer to label %exit
+outer.end:
+  catchendpad unwind to caller
+exit:
+  ret void
+}
+
+; Check the catchret targets
+; CHECK-LABEL: test1: # @test1
+; CHECK: [[Exit:^[^: ]+]]: # %exit
+; CHECK: [[OuterRet:^[^: ]+]]: # %outer.ret
+; CHECK-NEXT: leaq [[Exit]](%rip), %rax
+; CHECK:      retq   # CATCHRET
+; CHECK: {{^[^: ]+}}: # %inner.pad
+; CHECK: .seh_endprolog
+; CHECK-NEXT: leaq [[OuterRet]](%rip), %rax
+; CHECK:      retq   # CATCHRET
Index: lib/CodeGen/WinEHPrepare.cpp
===================================================================
--- lib/CodeGen/WinEHPrepare.cpp
+++ lib/CodeGen/WinEHPrepare.cpp
@@ -721,8 +721,6 @@
       std::set<BasicBlock *> &SuccessorColors = BlockColors[CatchRetSuccessor];
       assert(SuccessorColors.size() == 1 && "Expected BB to be monochrome!");
       BasicBlock *Color = *SuccessorColors.begin();
-      if (auto *CPI = dyn_cast<CatchPadInst>(Color->getFirstNonPHI()))
-        Color = CPI->getNormalDest();
       // Record the catchret successor's funclet membership.
       FuncInfo.CatchRetSuccessorColorMap[CatchReturn] = Color;
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13798.37560.patch
Type: text/x-patch
Size: 1965 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151016/9f0f6e5d/attachment.bin>


More information about the llvm-commits mailing list