[llvm] [LLVM][DWARF] Refactor code for generating DWARF V5 .debug_names (PR #82394)

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 20 13:24:50 PST 2024


================
@@ -613,6 +613,24 @@ enum AcceleratorTable {
   DW_hash_function_djb = 0u
 };
 
+// Uniquify the string hashes and calculate the bucket count for the
+// DWARF v5 Accelerator Table.
+inline uint32_t computeDebugNamesUniqueHashes(MutableArrayRef<uint32_t> hashes,
----------------
dwblaikie wrote:

Ah. Yeah, naming it after what it returns seems the most legible.

If the intent is to use the uniqued hashes array after the call (not relevant to the current caller, but possibly relevant to the new usage you want to add) maybe the simplest thing is to have the function take a `SmallVectorImpl<uint32_t>&`, and after calling `uique`, use that result to shorten the vector down to the size of the uniqued range (by calling the vector's `resize` function) - then the caller can inspect the vector's size after calling, and doesn't need the secondary out parameter?

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


More information about the llvm-commits mailing list