Don't emit init symbol for zero-initialized structs (#3131)

And optimize previous usages of it to direct memset-zero.
This commit is contained in:
Martin Kinkelin 2019-09-12 00:30:09 +02:00 committed by GitHub
parent 25195fb36c
commit 3840a03af4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 69 additions and 22 deletions

View file

@ -1650,10 +1650,16 @@ DValue *DtoSymbolAddress(Loc &loc, Type *type, Declaration *decl) {
IF_LOG Logger::print("Sym: type=%s\n", sdecltype->toChars());
assert(sdecltype->ty == Tstruct);
TypeStruct *ts = static_cast<TypeStruct *>(sdecltype);
assert(ts->sym);
DtoResolveStruct(ts->sym);
StructDeclaration *sd = ts->sym;
assert(sd);
DtoResolveStruct(sd);
LLValue *initsym = getIrAggr(ts->sym)->getInitSymbol();
if (sd->zeroInit) {
error(loc, "no init symbol for zero-initialized struct");
fatal();
}
LLValue *initsym = getIrAggr(sd)->getInitSymbol();
initsym = DtoBitCast(initsym, DtoType(ts->pointerTo()));
return new DLValue(type, initsym);
}