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:
Kai Nacke 2015-06-04 21:22:38 +02:00
parent 104e7c991f
commit b301407f9c
2 changed files with 7 additions and 7 deletions

View file

@ -1045,20 +1045,20 @@ void DtoDefineFunction(FuncDeclaration* fd)
// pass the previous block into this block
gIR->DBuilder.EmitStopPoint(fd->endloc);
if (func->getReturnType() == LLType::getVoidTy(gIR->context())) {
llvm::ReturnInst::Create(gIR->context(), gIR->scopebb());
gIR->ir->CreateRetVoid();
}
else if (!fd->isMain()) {
AsmBlockStatement* asmb = fd->fbody->endsWithAsm();
if (asmb) {
assert(asmb->abiret);
llvm::ReturnInst::Create(gIR->context(), asmb->abiret, bb);
gIR->ir->CreateRet(asmb->abiret);
}
else {
llvm::ReturnInst::Create(gIR->context(), llvm::UndefValue::get(func->getReturnType()), bb);
gIR->ir->CreateRet(llvm::UndefValue::get(func->getReturnType()));
}
}
else
llvm::ReturnInst::Create(gIR->context(), LLConstant::getNullValue(func->getReturnType()), bb);
gIR->ir->CreateRet(LLConstant::getNullValue(func->getReturnType()));
}
gIR->DBuilder.EmitFuncEnd(fd);