[WinEH] Don't skip landing pads that end with an unreachable instruction.
authorAndrew Kaylor <andrew.kaylor@intel.com>
Thu, 23 Apr 2015 00:20:44 +0000 (00:20 +0000)
committerAndrew Kaylor <andrew.kaylor@intel.com>
Thu, 23 Apr 2015 00:20:44 +0000 (00:20 +0000)
llvm-svn: 235563

llvm/lib/CodeGen/WinEHPrepare.cpp
llvm/test/CodeGen/WinEH/cppeh-prepared-catch-reordered.ll
llvm/test/CodeGen/WinEH/cppeh-prepared-catch.ll

index 67f7cdc..e11da29 100644 (file)
@@ -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<UnreachableInst>(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;
index 4946c6a..5c8170b 100644 (file)
@@ -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
 }
 
index 98b4afc..8e8fc76 100644 (file)
@@ -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
 }