From a1df0a312001ac1a9951c8925d7639442304a6e1 Mon Sep 17 00:00:00 2001 From: Andrew Kaylor Date: Thu, 23 Apr 2015 00:20:44 +0000 Subject: [PATCH] [WinEH] Don't skip landing pads that end with an unreachable instruction. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235563 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/WinEHPrepare.cpp | 10 ++++------ test/CodeGen/WinEH/cppeh-prepared-catch-reordered.ll | 1 + test/CodeGen/WinEH/cppeh-prepared-catch.ll | 1 + 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/CodeGen/WinEHPrepare.cpp b/lib/CodeGen/WinEHPrepare.cpp index 67f7cdc8faf..e11da29fedc 100644 --- a/lib/CodeGen/WinEHPrepare.cpp +++ b/lib/CodeGen/WinEHPrepare.cpp @@ -637,12 +637,6 @@ bool WinEHPrepare::prepareExceptionHandlers( LPadHasActionList = true; break; } - // FIXME: This is here to help with the development of nested landing pad - // outlining. It should be removed when that is finished. - if (isa(Inst)) { - LPadHasActionList = true; - break; - } } // If we've already outlined the handlers for this landingpad, @@ -1011,6 +1005,10 @@ static BasicBlock *createStubLandingPad(Function *Handler, llvm::StructType::get(Type::getInt8PtrTy(Context), Type::getInt32Ty(Context), nullptr), PersonalityFn, 0); + // Insert a call to llvm.eh.actions so that we don't try to outline this lpad. + Function *ActionIntrin = Intrinsic::getDeclaration(Handler->getParent(), + Intrinsic::eh_actions); + Builder.CreateCall(ActionIntrin, "recover"); LPad->setCleanup(true); Builder.CreateUnreachable(); return StubBB; diff --git a/test/CodeGen/WinEH/cppeh-prepared-catch-reordered.ll b/test/CodeGen/WinEH/cppeh-prepared-catch-reordered.ll index 4946c6affc3..5c8170b0d4b 100644 --- a/test/CodeGen/WinEH/cppeh-prepared-catch-reordered.ll +++ b/test/CodeGen/WinEH/cppeh-prepared-catch-reordered.ll @@ -106,6 +106,7 @@ entry.split: ; preds = %entry stub: ; preds = %entry %4 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) cleanup + %recover = call i8* (...) @llvm.eh.actions() unreachable } diff --git a/test/CodeGen/WinEH/cppeh-prepared-catch.ll b/test/CodeGen/WinEH/cppeh-prepared-catch.ll index 98b4afcd055..8e8fc76818c 100644 --- a/test/CodeGen/WinEH/cppeh-prepared-catch.ll +++ b/test/CodeGen/WinEH/cppeh-prepared-catch.ll @@ -70,6 +70,7 @@ done: lpad: ; preds = %entry %4 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) cleanup + %recover = call i8* (...) @llvm.eh.actions() unreachable } -- 2.34.1