Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions gen/runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -727,12 +727,6 @@ static void buildRuntimeModule() {
}

if (useMSVCEH()) {
// _d_enter_cleanup(ptr frame)
createFwdDecl(LINK::c, boolTy, {"_d_enter_cleanup"}, {voidPtrTy});

// _d_leave_cleanup(ptr frame)
createFwdDecl(LINK::c, voidTy, {"_d_leave_cleanup"}, {voidPtrTy});

// Throwable _d_eh_enter_catch(ptr exception, ClassInfo catchType)
createFwdDecl(LINK::c, throwableTy, {"_d_eh_enter_catch"},
{voidPtrTy, classInfoTy}, {});
Expand Down
21 changes: 2 additions & 19 deletions gen/trycatchfinally.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -845,15 +845,12 @@ TryCatchFinallyScopes::runCleanupPad(CleanupCursor scope,
//
// cleanuppad:
// %0 = cleanuppad within %funclet[]
// %frame = nullptr
// if (!_d_enter_cleanup(%frame)) br label %cleanupret
// else br label %copy
// br label %copy
//
// copy:
// invoke _dtor to %cleanupret unwind %unwindTo [ "funclet"(token %0) ]
//
// cleanupret:
// _d_leave_cleanup(%frame)
// cleanupret %0 unwind %unwindTo
//
llvm::BasicBlock *cleanupbb = irs.insertBB("cleanuppad");
Expand All @@ -863,28 +860,14 @@ TryCatchFinallyScopes::runCleanupPad(CleanupCursor scope,

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

// preparation to allocate some space on the stack where _d_enter_cleanup
// can place an exception frame (but not done here)
auto frame = getNullPtr();

const auto savedInsertPoint = irs.saveInsertPoint();

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

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

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

return cleanupbb;
}
16 changes: 0 additions & 16 deletions runtime/druntime/src/ldc/eh_msvc.d
Original file line number Diff line number Diff line change
Expand Up @@ -625,22 +625,6 @@ static ~this()
}
}

///////////////////////////////////////////////////////////////
extern(C) bool _d_enter_cleanup(void* ptr)
{
// currently just used to avoid that a cleanup handler that can
// be inferred to not return, is removed by the LLVM optimizer
//
// TODO: setup an exception handler here (ptr passes the address
// of a 40 byte stack area in a parent fuction scope) to deal with
// unhandled exceptions during unwinding.
return true;
}

extern(C) void _d_leave_cleanup(void* ptr)
{
}

///////////////////////////////////////////////////////////////
void msvc_eh_init()
{
Expand Down
2 changes: 0 additions & 2 deletions tests/debuginfo/msvc_eh.d
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,4 @@ void foo_msvc()
WithDtor swd_2 = { 48 };
}
// CHECK-DAG: call {{.*}}@_d_eh_enter_catch{{.*}} !dbg
// CHECK-DAG: call {{.*}}@_d_enter_cleanup{{.*}} !dbg
// CHECK-DAG: call {{.*}}@_d_leave_cleanup{{.*}} !dbg
}
Loading