mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-08 20:06:03 +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);
|
DtoAssign(loc, &field, &val, TOKblit);
|
||||||
}
|
}
|
||||||
|
|
||||||
offset += vd->type->size();
|
// 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.
|
||||||
// Also zero out padding bytes counted as being part of the type in DMD
|
offset += gDataLayout->getTypeStoreSize(DtoType(vd->type));
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialize trailing padding
|
// initialize trailing padding
|
||||||
|
|
|
@ -284,7 +284,9 @@ void IrAggr::addFieldInitializers(
|
||||||
}
|
}
|
||||||
|
|
||||||
AggrTypeBuilder b(false, offset);
|
AggrTypeBuilder b(false, offset);
|
||||||
b.addAggregate(decl, &explicitInitializers, AggrTypeBuilder::Aliases::Skip);
|
b.addAggregate(decl,
|
||||||
|
explicitInitializers.empty() ? nullptr : &explicitInitializers,
|
||||||
|
AggrTypeBuilder::Aliases::Skip);
|
||||||
offset = b.currentOffset();
|
offset = b.currentOffset();
|
||||||
|
|
||||||
const size_t baseLLFieldIndex = constants.size();
|
const size_t baseLLFieldIndex = constants.size();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue