llvm::tryEnforceAlignment

Try to raise a controlled object's alignment to a preferred value.

Synopsis

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

Align
tryEnforceAlignment(
    Value* V,
    Align PrefAlign,
    DataLayout const& DL);

Description

If the specified pointer points to an object that we control, try to modify the object's alignment to PrefAlign. Returns a minimum known alignment of the value after the operation, which may be lower than PrefAlign.

Increating value alignment isn't often possible though. 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

Minimum known alignment of the value after the operation.

Parameters

NameDescription
VPointer value whose underlying object may be realigned.
PrefAlignPreferred alignment to try to enforce.
DLData layout used to reason about object alignment.