LLVM  14.0.0git
Classes | Namespaces | Functions
OptimizedStructLayout.h File Reference
#include "llvm/Support/Alignment.h"
#include "llvm/ADT/ArrayRef.h"
#include <utility>
Include dependency graph for OptimizedStructLayout.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  llvm::OptimizedStructLayoutField
 A field in a structure. More...
 

Namespaces

 llvm
 This file implements support for optimizing divisions by a constant.
 

Functions

std::pair< uint64_t, Alignllvm::performOptimizedStructLayout (MutableArrayRef< OptimizedStructLayoutField > Fields)
 Compute a layout for a struct containing the given fields, making a best-effort attempt to minimize the amount of space required. More...
 

Detailed Description

This file provides an interface for laying out a sequence of fields as a struct in a way that attempts to minimizes the total space requirements of the struct while still satisfying the layout requirements of the individual fields. The resulting layout may be substantially more compact than simply laying out the fields in their original order.

Fields may be pre-assigned fixed offsets. They may also be given sizes that are not multiples of their alignments. There is no currently no way to describe that a field has interior padding that other fields may be allocated into.

This algorithm does not claim to be "optimal" for several reasons:

Definition in file OptimizedStructLayout.h.