From 09af67aba54e6d2a05e3071c0c7ba43bde678df9 Mon Sep 17 00:00:00 2001 From: Joseph Tremoulet Date: Sun, 27 Sep 2015 01:47:46 +0000 Subject: [EH] Create removeUnwindEdge utility Summary: Factor the code that rewrites invokes to calls and rewrites WinEH terminators to their "unwind to caller" equivalents into a helper in Utils/Local, and use it in the three places I'm aware of that need to do this. Reviewers: andrew.w.kaylor, majnemer, rnk Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D13152 llvm-svn: 248677 --- llvm/lib/CodeGen/WinEHPrepare.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'llvm/lib/CodeGen') diff --git a/llvm/lib/CodeGen/WinEHPrepare.cpp b/llvm/lib/CodeGen/WinEHPrepare.cpp index d5af24ed71a..b062b1a29d3 100644 --- a/llvm/lib/CodeGen/WinEHPrepare.cpp +++ b/llvm/lib/CodeGen/WinEHPrepare.cpp @@ -3184,9 +3184,23 @@ void WinEHPrepare::removeImplausibleTerminators(Function &F) { for (BasicBlock *SuccBB : TI->successors()) SuccBB->removePredecessor(BB); + if (IsUnreachableCleanupendpad) { + // We can't simply replace a cleanupendpad with unreachable, because + // its predecessor edges are EH edges and unreachable is not an EH + // pad. Change all predecessors to the "unwind to caller" form. + for (pred_iterator PI = pred_begin(BB), PE = pred_end(BB); + PI != PE;) { + BasicBlock *Pred = *PI++; + removeUnwindEdge(Pred); + } + } + new UnreachableInst(BB->getContext(), TI); TI->eraseFromParent(); } + // FIXME: Check for invokes/cleanuprets/cleanupendpads which unwind to + // implausible catchendpads (i.e. catchendpad not in immediate parent + // funclet). } } } -- cgit v1.2.3