Skip to content

Commit b4a4174

Browse files
committed
[fix wrong early-return regression]
1 parent 6d3da15 commit b4a4174

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

gen/llvmhelpers.cpp

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -900,24 +900,18 @@ void DtoVarDeclaration(VarDeclaration *vd) {
900900
LLType *lltype = DtoType(type); // void for noreturn
901901
if (lltype->isVoidTy()) {
902902
irLocal->value = getNullPtr();
903-
return;
904-
}
905-
906-
llvm::AllocaInst *allocainst;
907-
908-
if (type != vd->type) {
909-
allocainst = DtoAlloca(type, vd->toChars());
910903
} else {
911-
allocainst = DtoAlloca(vd, vd->toChars());
912-
}
913-
914-
irLocal->value = allocainst;
904+
auto allocainst = type != vd->type ? DtoAlloca(type, vd->toChars())
905+
: DtoAlloca(vd, vd->toChars());
915906

916-
gIR->DBuilder.EmitLocalVariable(allocainst, vd);
907+
irLocal->value = allocainst;
908+
gIR->DBuilder.EmitLocalVariable(allocainst, vd);
917909

918-
// The lifetime of a stack variable starts from the point it is declared
919-
gIR->funcGen().localVariableLifetimeAnnotator.addLocalVariable(
920-
allocainst, DtoConstUlong(size(type)));
910+
// The lifetime of a stack variable starts from the
911+
// point it is declared
912+
gIR->funcGen().localVariableLifetimeAnnotator.addLocalVariable(
913+
allocainst, DtoConstUlong(size(type)));
914+
}
921915
}
922916

923917
IF_LOG Logger::cout() << "llvm value for decl: " << *getIrLocal(vd)->value

0 commit comments

Comments
 (0)