[llvm] r250552 - [WinEH] Fix CatchRetSuccessorColorMap accounting

Joseph Tremoulet via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 16 14:22:54 PDT 2015


Author: josepht
Date: Fri Oct 16 16:22:54 2015
New Revision: 250552

URL: http://llvm.org/viewvc/llvm-project?rev=250552&view=rev
Log:
[WinEH] Fix CatchRetSuccessorColorMap accounting

Summary:
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.

Reviewers: majnemer, rnk

Subscribers: rnk, llvm-commits

Differential Revision: http://reviews.llvm.org/D13798

Added:
    llvm/trunk/test/CodeGen/X86/win-catchpad-nested.ll
Modified:
    llvm/trunk/lib/CodeGen/WinEHPrepare.cpp

Modified: llvm/trunk/lib/CodeGen/WinEHPrepare.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/WinEHPrepare.cpp?rev=250552&r1=250551&r2=250552&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/WinEHPrepare.cpp (original)
+++ llvm/trunk/lib/CodeGen/WinEHPrepare.cpp Fri Oct 16 16:22:54 2015
@@ -703,8 +703,6 @@ void llvm::calculateCatchReturnSuccessor
       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;
     }

Added: llvm/trunk/test/CodeGen/X86/win-catchpad-nested.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/win-catchpad-nested.ll?rev=250552&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/win-catchpad-nested.ll (added)
+++ llvm/trunk/test/CodeGen/X86/win-catchpad-nested.ll Fri Oct 16 16:22:54 2015
@@ -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




More information about the llvm-commits mailing list