mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-01-20 14:53:14 +01:00
Enable insertion of missing terminator instruction for main.
This commit is contained in:
@@ -695,16 +695,17 @@ void DtoDefineFunc(FuncDeclaration* fd)
|
||||
|
||||
// llvm requires all basic blocks to end with a TerminatorInst but DMD does not put a return statement
|
||||
// in automatically, so we do it here.
|
||||
if (!fd->isMain()) {
|
||||
if (!gIR->scopereturned()) {
|
||||
// pass the previous block into this block
|
||||
if (global.params.symdebug) DtoDwarfFuncEnd(fd);
|
||||
if (func->getReturnType() == LLType::VoidTy) {
|
||||
llvm::ReturnInst::Create(gIR->scopebb());
|
||||
}
|
||||
else {
|
||||
if (!gIR->scopereturned()) {
|
||||
// pass the previous block into this block
|
||||
if (global.params.symdebug) DtoDwarfFuncEnd(fd);
|
||||
if (func->getReturnType() == LLType::VoidTy) {
|
||||
llvm::ReturnInst::Create(gIR->scopebb());
|
||||
}
|
||||
else {
|
||||
if (!fd->isMain())
|
||||
llvm::ReturnInst::Create(llvm::UndefValue::get(func->getReturnType()), gIR->scopebb());
|
||||
}
|
||||
else
|
||||
llvm::ReturnInst::Create(llvm::Constant::getNullValue(func->getReturnType()), gIR->scopebb());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user