mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-04 09:00:33 +03:00
DebugInfo: Use the IRBuilder to create a ret instruction.
This ensures that a previous set debug location will be set on the return instruction.
This commit is contained in:
parent
104e7c991f
commit
b301407f9c
2 changed files with 7 additions and 7 deletions
|
@ -1045,20 +1045,20 @@ void DtoDefineFunction(FuncDeclaration* fd)
|
||||||
// pass the previous block into this block
|
// pass the previous block into this block
|
||||||
gIR->DBuilder.EmitStopPoint(fd->endloc);
|
gIR->DBuilder.EmitStopPoint(fd->endloc);
|
||||||
if (func->getReturnType() == LLType::getVoidTy(gIR->context())) {
|
if (func->getReturnType() == LLType::getVoidTy(gIR->context())) {
|
||||||
llvm::ReturnInst::Create(gIR->context(), gIR->scopebb());
|
gIR->ir->CreateRetVoid();
|
||||||
}
|
}
|
||||||
else if (!fd->isMain()) {
|
else if (!fd->isMain()) {
|
||||||
AsmBlockStatement* asmb = fd->fbody->endsWithAsm();
|
AsmBlockStatement* asmb = fd->fbody->endsWithAsm();
|
||||||
if (asmb) {
|
if (asmb) {
|
||||||
assert(asmb->abiret);
|
assert(asmb->abiret);
|
||||||
llvm::ReturnInst::Create(gIR->context(), asmb->abiret, bb);
|
gIR->ir->CreateRet(asmb->abiret);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
llvm::ReturnInst::Create(gIR->context(), llvm::UndefValue::get(func->getReturnType()), bb);
|
gIR->ir->CreateRet(llvm::UndefValue::get(func->getReturnType()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
llvm::ReturnInst::Create(gIR->context(), LLConstant::getNullValue(func->getReturnType()), bb);
|
gIR->ir->CreateRet(LLConstant::getNullValue(func->getReturnType()));
|
||||||
}
|
}
|
||||||
gIR->DBuilder.EmitFuncEnd(fd);
|
gIR->DBuilder.EmitFuncEnd(fd);
|
||||||
|
|
||||||
|
|
|
@ -404,7 +404,7 @@ public:
|
||||||
DtoEnclosingHandlers(stmt->loc, NULL);
|
DtoEnclosingHandlers(stmt->loc, NULL);
|
||||||
|
|
||||||
// emit ret
|
// emit ret
|
||||||
llvm::ReturnInst::Create(gIR->context(), irs->scopebb());
|
gIR->ir->CreateRetVoid();
|
||||||
}
|
}
|
||||||
// the return type is not void, so this is a normal "register" return
|
// the return type is not void, so this is a normal "register" return
|
||||||
else
|
else
|
||||||
|
@ -464,7 +464,7 @@ public:
|
||||||
// emit scopes
|
// emit scopes
|
||||||
DtoEnclosingHandlers(stmt->loc, NULL);
|
DtoEnclosingHandlers(stmt->loc, NULL);
|
||||||
|
|
||||||
llvm::ReturnInst::Create(gIR->context(), v, irs->scopebb());
|
gIR->ir->CreateRet(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// no return value expression means it's a void function
|
// no return value expression means it's a void function
|
||||||
|
@ -472,7 +472,7 @@ public:
|
||||||
{
|
{
|
||||||
assert(irs->topfunc()->getReturnType() == LLType::getVoidTy(gIR->context()));
|
assert(irs->topfunc()->getReturnType() == LLType::getVoidTy(gIR->context()));
|
||||||
DtoEnclosingHandlers(stmt->loc, NULL);
|
DtoEnclosingHandlers(stmt->loc, NULL);
|
||||||
llvm::ReturnInst::Create(gIR->context(), irs->scopebb());
|
gIR->ir->CreateRetVoid();
|
||||||
}
|
}
|
||||||
|
|
||||||
// the return terminated this basicblock, start a new one
|
// the return terminated this basicblock, start a new one
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue