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

via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 20 13:29: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,
+                                              uint32_t &uniqueHashCount) {
+  uint32_t BucketCount = 0;
+
+  sort(hashes);
+  uniqueHashCount = llvm::unique(hashes) - hashes.begin();
----------------
cmtice wrote:

Ok, I went back and double check the callers; they do NOT expect a usable vector after this call, so that is fine.  However I'm getting a compile time error using the MutableArrayRef, which I could use to help figuring out how to fix: 

third_party/llvm/llvm-project/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp:43:50: error: non-const lvalue reference to type 'MutableArrayRef<uint32_t>' (aka 'MutableArrayRef<unsigned int>') cannot bind to a value of unrelated type 'SmallVector<uint32_t, 0>' (aka 'SmallVector<unsigned int, 0>')
   43 |       llvm::dwarf::computeDebugNamesUniqueHashes(Uniques, UniqueHashCount);
      |                                                  ^~~~~~~
third_party/llvm/llvm-project/llvm/include/llvm/BinaryFormat/Dwarf.h:618:74: note: passing argument to parameter 'hashes' here
  618 | inline uint32_t computeDebugNamesUniqueHashes(MutableArrayRef<uint32_t> &hashes,
      |                                                                          ^
1 error generated.

('Uniques', at the call site, line 43, is a SmallVector...)

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


More information about the llvm-commits mailing list