llvm-project
282fb052 - [IR] Store Metadata attachments in vector (#189551)

Commit
20 days ago
[IR] Store Metadata attachments in vector (#189551) Metadata is accessed rather often, so store metadata attachments in a vector indexed by a number instead of a map from Value*; inside the vector, the metadata attachments form a linked list. Instruction and GlobalObject store the first metadata attachment index directly. Care is taken that the offset in the structures is identical. In addition to substantial performance improvements, this also leads to a measurable reduction in memory usage -- several instructions have metadata in debug builds (debug metadata) and release builds (primarily TBAA), causing the hash table to become quite large. In Instruction, this uses 4 padding bytes (it might be debatable whether this is the best use for this space); GlobalObject grows by 4 bytes. However, should we want grow Instruction by 8 bytes in the future, the additionally used memory will be ~similar to the memory saved here, so we could do so without causing a release-to-release memory regression. This also makes the HasMetadata bit redundant, cleanup will follow separately -- this is a bit annoying, because this should be inline, but Value can't access subclass members.
Author
Parents
Loading