llvm::GetPointerBaseWithConstantOffset

Analyze the specified pointer to see if it can be expressed as a base pointer plus a constant offset. Return the base and offset to the caller.

Synopsis

Declared in <llvm/Analysis/ValueTracking.h>

Value*
GetPointerBaseWithConstantOffset(
    Value* Ptr,
    int64_t& Offset,
    DataLayout const& DL,
    bool AllowNonInbounds = true);

Description

This is a wrapper around Value::stripAndAccumulateConstantOffsets that creates and later unpacks the required APInt.

Return Value

Base pointer after stripping constant offsets.

Parameters

NameDescription
PtrPointer to decompose into base plus offset.
OffsetOutput constant offset from the returned base.
DLData layout used for pointer index sizes.
AllowNonInboundsWhether non-inbounds GEPs may contribute offsets.