llvm::rdf::NodeAllocator

Bump-pointer allocator that maps between node ids and addresses.

Synopsis

Declared in <llvm/CodeGen/RDFGraph.h>

struct NodeAllocator;

Description

Fast memory allocation and translation between node id and node address. This is really the same idea as the one underlying the "bump pointer allocator", the difference being in the translation. A node id is composed of two components: the index of the block in which it was allocated, and the index within the block. With the default settings, where the number of nodes per block is 4096, the node id (minus 1) is:

bit position: 11 0 +----------------------------+--------------+ | Index of the block |Index in block| +----------------------------+--------------+

The actual node id is the above plus 1, to avoid creating a node id of 0.

This method significantly improved the build time, compared to using maps (std::unordered_map or DenseMap) to translate between pointers and ids.

Enums

NameDescription
Unnamed enum Constants controlling per-node storage layout.

Member Functions

NameDescription
NodeAllocator [constructor]Construct an allocator that packs NPB nodes per storage block.
New Allocate and return a new zero-initialized node.
clear Release all allocated nodes and reset the allocator.
id Return the node id corresponding to pointer P.
ptr Return the node pointer for id N.