mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-06 19:06:02 +03:00
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:
parent
25195fb36c
commit
3840a03af4
8 changed files with 69 additions and 22 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue