llvm::getAllocSize

Return the size of the requested allocation.

Synopsis

Declared in <llvm/Analysis/MemoryBuiltins.h>

std::optional<APInt>
getAllocSize(
    CallBase const* CB,
    TargetLibraryInfo const* TLI,
    function_ref<Value const*(Value const*)> Mapper = [](const Value *V) {
      return V;
    });

Description

With a trivial mapper, this is similar to calling getObjectSize(..., Exact), but without looking through calls that return their argument. A mapper function can be used to replace one Value* (operand to the allocation) with another. This is useful when doing abstract interpretation.

Return Value

The requested allocation size, or std::nullopt if unknown.

Parameters

NameDescription
CBCall to an allocation function.
TLITarget library info used to identify allocation functions.
MapperOptional mapper that rewrites allocation operands.