Skip to content

Commit 0132d88

Browse files
committed
WinEH: Remove dummy _d_{enter,leave}_cleanup calls
1 parent 50d8c67 commit 0132d88

4 files changed

Lines changed: 2 additions & 43 deletions

File tree

gen/runtime.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -727,12 +727,6 @@ static void buildRuntimeModule() {
727727
}
728728

729729
if (useMSVCEH()) {
730-
// _d_enter_cleanup(ptr frame)
731-
createFwdDecl(LINK::c, boolTy, {"_d_enter_cleanup"}, {voidPtrTy});
732-
733-
// _d_leave_cleanup(ptr frame)
734-
createFwdDecl(LINK::c, voidTy, {"_d_leave_cleanup"}, {voidPtrTy});
735-
736730
// Throwable _d_eh_enter_catch(ptr exception, ClassInfo catchType)
737731
createFwdDecl(LINK::c, throwableTy, {"_d_eh_enter_catch"},
738732
{voidPtrTy, classInfoTy}, {});

gen/trycatchfinally.cpp

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -845,15 +845,12 @@ TryCatchFinallyScopes::runCleanupPad(CleanupCursor scope,
845845
//
846846
// cleanuppad:
847847
// %0 = cleanuppad within %funclet[]
848-
// %frame = nullptr
849-
// if (!_d_enter_cleanup(%frame)) br label %cleanupret
850-
// else br label %copy
848+
// br label %copy
851849
//
852850
// copy:
853851
// invoke _dtor to %cleanupret unwind %unwindTo [ "funclet"(token %0) ]
854852
//
855853
// cleanupret:
856-
// _d_leave_cleanup(%frame)
857854
// cleanupret %0 unwind %unwindTo
858855
//
859856
llvm::BasicBlock *cleanupbb = irs.insertBB("cleanuppad");
@@ -863,28 +860,14 @@ TryCatchFinallyScopes::runCleanupPad(CleanupCursor scope,
863860

864861
llvm::BasicBlock *cleanupret = irs.insertBBAfter(cleanupbb, "cleanupret");
865862

866-
// preparation to allocate some space on the stack where _d_enter_cleanup
867-
// can place an exception frame (but not done here)
868-
auto frame = getNullPtr();
869-
870863
const auto savedInsertPoint = irs.saveInsertPoint();
871864

872-
auto endFn = getRuntimeFunction(Loc(), irs.module, "_d_leave_cleanup");
873-
irs.ir->SetInsertPoint(cleanupret);
874-
irs.DBuilder.EmitStopPoint(irs.func()->decl->loc);
875-
irs.ir->CreateCall(endFn, frame,
876-
{llvm::OperandBundleDef("funclet", cleanuppad)}, "");
877865
llvm::CleanupReturnInst::Create(cleanuppad, unwindTo, cleanupret);
878866

879867
auto copybb = cleanupScopes[scope].runCopying(irs, cleanupbb, cleanupret,
880868
unwindTo, cleanuppad);
881869

882-
auto beginFn = getRuntimeFunction(Loc(), irs.module, "_d_enter_cleanup");
883-
irs.ir->SetInsertPoint(cleanupbb);
884-
irs.DBuilder.EmitStopPoint(irs.func()->decl->loc);
885-
auto exec = irs.ir->CreateCall(
886-
beginFn, frame, {llvm::OperandBundleDef("funclet", cleanuppad)}, "");
887-
createBranch(exec, copybb, cleanupret, cleanupbb);
870+
createBranch(copybb, cleanupbb);
888871

889872
return cleanupbb;
890873
}

runtime/druntime/src/ldc/eh_msvc.d

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -625,22 +625,6 @@ static ~this()
625625
}
626626
}
627627

628-
///////////////////////////////////////////////////////////////
629-
extern(C) bool _d_enter_cleanup(void* ptr)
630-
{
631-
// currently just used to avoid that a cleanup handler that can
632-
// be inferred to not return, is removed by the LLVM optimizer
633-
//
634-
// TODO: setup an exception handler here (ptr passes the address
635-
// of a 40 byte stack area in a parent fuction scope) to deal with
636-
// unhandled exceptions during unwinding.
637-
return true;
638-
}
639-
640-
extern(C) void _d_leave_cleanup(void* ptr)
641-
{
642-
}
643-
644628
///////////////////////////////////////////////////////////////
645629
void msvc_eh_init()
646630
{

tests/debuginfo/msvc_eh.d

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,4 @@ void foo_msvc()
2828
WithDtor swd_2 = { 48 };
2929
}
3030
// CHECK-DAG: call {{.*}}@_d_eh_enter_catch{{.*}} !dbg
31-
// CHECK-DAG: call {{.*}}@_d_enter_cleanup{{.*}} !dbg
32-
// CHECK-DAG: call {{.*}}@_d_leave_cleanup{{.*}} !dbg
3331
}

0 commit comments

Comments
 (0)