[PATCH] D155764: [BOLT][DWARF][NFC] Replace MD5 with hash_combine

Alexander Yermolovich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 19 16:33:29 PDT 2023


ayermolo created this revision.
Herald added subscribers: treapster, hoy, modimo, wenlei.
Herald added a reviewer: rafauler.
Herald added a reviewer: Amir.
Herald added a reviewer: maksfb.
Herald added a project: All.
ayermolo requested review of this revision.
Herald added subscribers: llvm-commits, yota9.
Herald added a project: LLVM.

Slight performance improvment.

Collected on clang-17 built with DWARF4 + split dwarf.
MD5
8:46.50 real,   713.38 user,    64.19 sys,      0 amem, 41933136 mmem
8:27.44 real,   708.55 user,    63.83 sys,      0 amem, 41906576 mmem
8:40.37 real,   724.63 user,    62.56 sys,      0 amem, 42319572 mmem

hash_combine‚Ä®
8:03.99 real,   681.92 user,    60.04 sys,      0 amem, 42459204 mmem
8:02.92 real,   685.20 user,    62.56 sys,      0 amem, 41879164 mmem
7:57.85 real,   690.27 user,    60.12 sys,      0 amem, 41806240 mmem

Test Plan:


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D155764

Files:
  bolt/lib/Core/DIEBuilder.cpp


Index: bolt/lib/Core/DIEBuilder.cpp
===================================================================
--- bolt/lib/Core/DIEBuilder.cpp
+++ bolt/lib/Core/DIEBuilder.cpp
@@ -838,12 +838,11 @@
   // Before DWARF5 TU units are in their own section, so at least one offset,
   // first one, will be the same as CUs in .debug_info.dwo section
   if (DU.getVersion() < 5 && DU.isTypeUnit()) {
-    MD5 Hash;
-    uint64_t TypeUnitHash = cast_or_null<DWARFTypeUnit>(&DU)->getTypeHash();
-    uint64_t Offset = DU.getOffset();
-    Hash.update(llvm::ArrayRef((uint8_t *)&TypeUnitHash, sizeof(TypeUnitHash)));
-    Hash.update(llvm::ArrayRef((uint8_t *)&Offset, sizeof(Offset)));
-    return Hash.final().high();
+    const uint64_t TypeUnitHash =
+        cast_or_null<DWARFTypeUnit>(&DU)->getTypeHash();
+    const uint64_t Offset = DU.getOffset();
+    return llvm::hash_combine(llvm::hash_value(TypeUnitHash),
+                              llvm::hash_value(Offset));
   }
   return DU.getOffset();
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155764.542241.patch
Type: text/x-patch
Size: 998 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230719/983a8efb/attachment.bin>


More information about the llvm-commits mailing list