[llvm] [LiveDebugValues][nfc] Reduce memory usage of InstrRef (PR #76051)

Felipe de Azevedo Piovezan via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 20 11:32:08 PST 2023


================
@@ -207,9 +207,48 @@ using namespace llvm;
 /// Type for a table of values in a block.
 using ValueTable = SmallVector<ValueIDNum, 0>;
 
-/// Type for a table-of-table-of-values, i.e., the collection of either
-/// live-in or live-out values for each block in the function.
-using FuncValueTable = SmallVector<ValueTable, 0>;
+/// A collection of ValueTables, one per BB in a function, with convenient
+/// accessor methods.
+struct FuncValueTable {
+  FuncValueTable(int NumBBs, int NumLocs) {
+    Storage.reserve(NumBBs);
+    for ([[maybe_unused]] auto _ : llvm::seq(NumBBs))
----------------
felipepiovezan wrote:

I got very close to writing this instead 😅 
```
map_to_vector(seq(NumBBs), 
                           [](auto){return std::make_unique<ValueTable>(NumLocs, ValueIDNum::EmptyValue));});
```

But I don't mind rewriting it as a traditional style loop. Will update the pr shortly

https://github.com/llvm/llvm-project/pull/76051


More information about the llvm-commits mailing list