Replacing lowering vectors with FixedSizeValueStore (#5636)

Changes the vectors on `Lower::FileContext` to be `FixedSizeValueStore`
where possible, which we have several at this point.

This changes `FixedSizeValueStore` to prefer inferring the size from a
`ValueStore<IdT>`, which should make adding incorrect sizes harder. Note
I wasn't sure that adding a `size()` to `TypeStore` that returned
`insts().size()` would be good because it doesn't directly work that
way; `ConstantValueStore` would've also required more work since it
doesn't have access to that right now.
This commit is contained in:
Jon Ross-Perkins
2025-06-10 20:15:19 +00:00
committed by GitHub
parent 3d603fced7
commit 81ca949ab8
11 changed files with 136 additions and 101 deletions
+2 -1
View File
@@ -16,7 +16,8 @@ TreeAndSubtrees::TreeAndSubtrees(const Lex::TokenizedBuffer& tokens,
const Tree& tree)
: tokens_(&tokens),
tree_(&tree),
subtree_sizes_(SubtreeSizeStore::MakeForOverwrite(tree_->size())) {
subtree_sizes_(
SubtreeSizeStore::MakeForOverwriteWithExplicitSize(tree_->size())) {
// A stack of nodes which haven't yet been used as children.
llvm::SmallVector<NodeId> size_stack;
for (auto n : tree.postorder()) {