[llvm] r252413 - [WinEH] Update PHIs of CATCHRET successors
David Majnemer via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 7 18:36:02 PST 2015
Author: majnemer
Date: Sat Nov 7 20:36:00 2015
New Revision: 252413
URL: http://llvm.org/viewvc/llvm-project?rev=252413&view=rev
Log:
[WinEH] Update PHIs of CATCHRET successors
The TailDuplication machine pass ran across a malformed CFG: a PHI node
referred it's predecessor's predecessor instead of it's predecessor.
This occurred because we split the edge in X86ISelLowering when we
processed the CATCHRET but forgot to do something about the PHI nodes.
This fixes PR25444.
Added:
llvm/trunk/test/CodeGen/X86/tail-dup-catchret.ll
Modified:
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=252413&r1=252412&r2=252413&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Sat Nov 7 20:36:00 2015
@@ -21419,10 +21419,10 @@ X86TargetLowering::EmitLoweredCatchRet(M
// the new block to the return destination with a normal JMP_4.
MachineBasicBlock *RestoreMBB =
MF->CreateMachineBasicBlock(BB->getBasicBlock());
+ assert(BB->succ_size() == 1);
MF->insert(TargetMBB->getIterator(), RestoreMBB);
- BB->removeSuccessor(TargetMBB);
+ RestoreMBB->transferSuccessorsAndUpdatePHIs(BB);
BB->addSuccessor(RestoreMBB);
- RestoreMBB->addSuccessor(TargetMBB);
MI->getOperand(0).setMBB(RestoreMBB);
auto RestoreMBBI = RestoreMBB->begin();
Added: llvm/trunk/test/CodeGen/X86/tail-dup-catchret.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/tail-dup-catchret.ll?rev=252413&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/tail-dup-catchret.ll (added)
+++ llvm/trunk/test/CodeGen/X86/tail-dup-catchret.ll Sat Nov 7 20:36:00 2015
@@ -0,0 +1,34 @@
+; RUN: llc < %s | FileCheck %s
+target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
+target triple = "i686-pc-windows-msvc18.0.0"
+
+define void @f() personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
+entry:
+ invoke void @g()
+ to label %try.cont unwind label %catch.dispatch
+
+catch.dispatch: ; preds = %entry
+ %0 = catchpad [i8* null, i32 64, i8* null]
+ to label %catch unwind label %catchendblock
+
+catch: ; preds = %catch.dispatch
+ catchret %0 to label %try.cont
+
+try.cont: ; preds = %entry, %catch
+ %b.0 = phi i1 [ false, %catch ], [ true, %entry ]
+ tail call void @h(i1 zeroext %b.0)
+ ret void
+
+catchendblock: ; preds = %catch.dispatch
+ catchendpad unwind to caller
+}
+
+; CHECK-LABEL: _f:
+; CHECK: calll _g
+; CHECK: calll _h
+
+declare void @g()
+
+declare i32 @__CxxFrameHandler3(...)
+
+declare void @h(i1 zeroext)
More information about the llvm-commits
mailing list