llvm::getOrEnforceKnownAlignment

Return a known alignment for a value, optionally raising it first.

Synopsis

Declared in <llvm/Transforms/Utils/Local.h>

Align
getOrEnforceKnownAlignment(
    Value* V,
    MaybeAlign PrefAlign,
    DataLayout const& DL,
    Instruction const* CxtI = nullptr,
    AssumptionCache* AC = nullptr,
    DominatorTree const* DT = nullptr);

Description

Try to ensure that the alignment of V is at least PrefAlign bytes. If the owning object can be modified and has an alignment less than PrefAlign, it will be increased and PrefAlign returned. If the alignment cannot be increased, the known alignment of the value is returned.

It is not always possible to modify the alignment of the underlying object, so if alignment is important, a more reliable approach is to simply align all global variables and allocation instructions to their preferred alignment from the beginning.

Return Value

The ensured or known alignment of V.

Parameters

NameDescription
VPointer value whose alignment is queried or enforced.
PrefAlignPreferred alignment to try to ensure, if any.
DLData layout used to reason about object alignment.
CxtIOptional context instruction for local analysis.
ACOptional assumption cache used during analysis.
DTOptional dominator tree used during analysis.