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

Name

Description

V

Pointer value whose alignment is queried or enforced.

PrefAlign

Preferred alignment to try to ensure, if any.

DL

Data layout used to reason about object alignment.

CxtI

Optional context instruction for local analysis.

AC

Optional assumption cache used during analysis.

DT

Optional dominator tree used during analysis.

Created with MrDocs