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*(xref:llvm/Value.adoc[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

Name

Description

CB

Call to an allocation function.

TLI

Target library info used to identify allocation functions.

Mapper

Optional mapper that rewrites allocation operands.

Created with MrDocs