mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-07 03:16:05 +03:00
[little optimizations]
This commit is contained in:
parent
1adf50fb17
commit
9e71551a61
2 changed files with 6 additions and 12 deletions
14
gen/toir.cpp
14
gen/toir.cpp
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue