#include "llvm/Support/OptimizedStructLayout.h"
#include <optional>
usingnamespacellvm;
Field;
#ifndef NDEBUG
static void checkValidLayout(ArrayRef<Field> Fields, uint64_t Size,
Align MaxAlign) {
uint64_t LastEnd = 0;
Align ComputedMaxAlign;
for (auto &Field : Fields) {
assert(Field.hasFixedOffset() &&
"didn't assign a fixed offset to field");
assert(isAligned(Field.Alignment, Field.Offset) &&
"didn't assign a correctly-aligned offset to field");
assert(Field.Offset >= LastEnd &&
"didn't assign offsets in ascending order");
LastEnd = Field.getEndOffset();
assert(Field.Alignment <= MaxAlign &&
"didn't compute MaxAlign correctly");
ComputedMaxAlign = std::max(Field.Alignment, MaxAlign);
}
assert(LastEnd == Size && "didn't compute LastEnd correctly");
assert(ComputedMaxAlign == MaxAlign && "didn't compute MaxAlign correctly");
}
#endif
std::pair<uint64_t, Align>
llvm::performOptimizedStructLayout(MutableArrayRef<Field> Fields) { … }