[little optimizations]

This commit is contained in:
Martin Kinkelin 2022-02-12 02:54:52 +01:00
parent 1adf50fb17
commit 9e71551a61
2 changed files with 6 additions and 12 deletions

View file

@ -149,17 +149,9 @@ static void write_struct_literal(Loc loc, LLValue *mem, StructDeclaration *sd,
DtoAssign(loc, &field, &val, TOKblit);
}
offset += vd->type->size();
// Also zero out padding bytes counted as being part of the type in DMD
// but not in LLVM; e.g. real/x86_fp80.
int implicitPadding =
vd->type->size() - gDataLayout->getTypeStoreSize(DtoType(vd->type));
assert(implicitPadding >= 0);
if (implicitPadding > 0) {
IF_LOG Logger::println("zeroing %d padding bytes", implicitPadding);
voidptr = write_zeroes(voidptr, offset - implicitPadding, offset);
}
// Make sure to zero out padding bytes counted as being part of the type in
// DMD but not in LLVM; e.g. real/x86_fp80.
offset += gDataLayout->getTypeStoreSize(DtoType(vd->type));
}
// initialize trailing padding

View file

@ -284,7 +284,9 @@ void IrAggr::addFieldInitializers(
}
AggrTypeBuilder b(false, offset);
b.addAggregate(decl, &explicitInitializers, AggrTypeBuilder::Aliases::Skip);
b.addAggregate(decl,
explicitInitializers.empty() ? nullptr : &explicitInitializers,
AggrTypeBuilder::Aliases::Skip);
offset = b.currentOffset();
const size_t baseLLFieldIndex = constants.size();