[all-commits] [llvm/llvm-project] 282fb0: [IR] Store Metadata attachments in vector (#189551)
Alexis Engelke via All-commits
all-commits at lists.llvm.org
Tue Mar 31 11:35:26 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 282fb05292cab555010a645cef88d62c846511d4
https://github.com/llvm/llvm-project/commit/282fb05292cab555010a645cef88d62c846511d4
Author: Alexis Engelke <engelke at in.tum.de>
Date: 2026-03-31 (Tue, 31 Mar 2026)
Changed paths:
M llvm/include/llvm/IR/GlobalObject.h
M llvm/include/llvm/IR/Instruction.h
M llvm/include/llvm/IR/Value.h
M llvm/include/llvm/Support/Alignment.h
M llvm/lib/IR/Globals.cpp
M llvm/lib/IR/LLVMContextImpl.cpp
M llvm/lib/IR/LLVMContextImpl.h
M llvm/lib/IR/Metadata.cpp
Log Message:
-----------
[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.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list