LLVM 19.0.0git
Classes | Namespaces | Functions
OptimizedStructLayout.h File Reference

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. More...

#include "llvm/Support/Alignment.h"
#include "llvm/ADT/ArrayRef.h"
#include <utility>

Go to the source code of this file.

Classes

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

Namespaces

namespace  llvm
 This is an optimization pass for GlobalISel generic memory operations.
 

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.
 

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.