mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-03 16:41:06 +03:00
MSVC: Attach !dbg info to _d_eh_enter_catch, _d_enter_cleanup and _d_leave_cleanup calls.
This commit is contained in:
parent
7ac1216292
commit
302d71a9de
4 changed files with 26 additions and 6 deletions
|
@ -874,6 +874,11 @@ void ldc::DIBuilder::EmitStopPoint(Loc &loc) {
|
|||
LOG_SCOPE;
|
||||
IR->ir->SetCurrentDebugLocation(
|
||||
llvm::DebugLoc::get(loc.linnum, charnum, GetCurrentScope()));
|
||||
currentLoc = loc;
|
||||
}
|
||||
|
||||
Loc ldc::DIBuilder::GetCurrentLoc() const {
|
||||
return currentLoc;
|
||||
}
|
||||
|
||||
void ldc::DIBuilder::EmitValue(llvm::Value *val, VarDeclaration *vd) {
|
||||
|
|
|
@ -87,6 +87,8 @@ class DIBuilder {
|
|||
#endif
|
||||
}
|
||||
|
||||
Loc currentLoc;
|
||||
|
||||
public:
|
||||
explicit DIBuilder(IRState *const IR);
|
||||
|
||||
|
@ -127,6 +129,8 @@ public:
|
|||
/// \brief Emits debug info for block end
|
||||
void EmitBlockEnd();
|
||||
|
||||
Loc GetCurrentLoc() const;
|
||||
|
||||
void EmitStopPoint(Loc &loc);
|
||||
|
||||
void EmitValue(llvm::Value *val, VarDeclaration *vd);
|
||||
|
|
|
@ -816,6 +816,8 @@ public:
|
|||
exnObj = DtoAlloca(var->type, "exnObj");
|
||||
}
|
||||
irs->scope() = save;
|
||||
irs->DBuilder.EmitStopPoint(ctch->loc); // re-set debug loc after the
|
||||
// SetInsertPoint(allocaInst) call
|
||||
} else if (ctch->type) {
|
||||
// catch without var
|
||||
exnObj = DtoAlloca(ctch->type, "exnObj");
|
||||
|
|
|
@ -283,21 +283,30 @@ llvm::BasicBlock *ScopeStack::runCleanupPad(CleanupCursor scope,
|
|||
// can place an exception frame (but not done here)
|
||||
auto frame = getNullPtr(getVoidPtrType());
|
||||
|
||||
auto savedInsertBlock = irs->ir->GetInsertBlock();
|
||||
auto savedInsertPoint = irs->ir->GetInsertPoint();
|
||||
auto savedDbgLoc = irs->DBuilder.GetCurrentLoc();
|
||||
|
||||
auto endFn = getRuntimeFunction(Loc(), irs->module, "_d_leave_cleanup");
|
||||
llvm::CallInst::Create(endFn, frame,
|
||||
{llvm::OperandBundleDef("funclet", cleanuppad)}, "",
|
||||
cleanupret);
|
||||
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 = executeCleanupCopying(irs, cleanupScopes[scope], cleanupbb,
|
||||
cleanupret, unwindTo, cleanuppad);
|
||||
|
||||
auto beginFn = getRuntimeFunction(Loc(), irs->module, "_d_enter_cleanup");
|
||||
auto exec = llvm::CallInst::Create(
|
||||
beginFn, frame, {llvm::OperandBundleDef("funclet", cleanuppad)}, "",
|
||||
cleanupbb);
|
||||
irs->ir->SetInsertPoint(cleanupbb);
|
||||
irs->DBuilder.EmitStopPoint(irs->func()->decl->loc);
|
||||
auto exec = irs->ir->CreateCall(
|
||||
beginFn, frame, {llvm::OperandBundleDef("funclet", cleanuppad)}, "");
|
||||
llvm::BranchInst::Create(copybb, cleanupret, exec, cleanupbb);
|
||||
|
||||
irs->ir->SetInsertPoint(savedInsertBlock, savedInsertPoint);
|
||||
irs->DBuilder.EmitStopPoint(savedDbgLoc);
|
||||
|
||||
return cleanupbb;
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue