[PATCH] D137101: [CodeView] Replace GHASH hasher by BLAKE3
Alexandre Ganea via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 31 12:26:01 PDT 2022
aganea created this revision.
aganea added reviewers: rnk, hans, thieta.
Herald added a subscriber: hiraditya.
Herald added a project: All.
aganea requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
We already discussed this in the past: SHA1 in `GloballyHashedType::hashType()` is coming top in the profiles. By simply replacing with BLAKE3, the link time is reduced from 15 sec to 13 sec. I am only using MSVC .OBJs in this case. As a reference, the resulting .PDB is approx 2.1GiB and .EXE is approx 250MiB.
Before:
F25138992: image.png <https://reviews.llvm.org/F25138992>
After:
F25138976: image.png <https://reviews.llvm.org/F25138976>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D137101
Files:
lld/COFF/DebugTypes.cpp
llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h
llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
llvm/lib/DebugInfo/CodeView/TypeHashing.cpp
Index: llvm/lib/DebugInfo/CodeView/TypeHashing.cpp
===================================================================
--- llvm/lib/DebugInfo/CodeView/TypeHashing.cpp
+++ llvm/lib/DebugInfo/CodeView/TypeHashing.cpp
@@ -9,7 +9,7 @@
#include "llvm/DebugInfo/CodeView/TypeHashing.h"
#include "llvm/DebugInfo/CodeView/TypeIndexDiscovery.h"
-#include "llvm/Support/SHA1.h"
+#include "llvm/Support/BLAKE3.h"
using namespace llvm;
using namespace llvm::codeview;
@@ -35,7 +35,7 @@
ArrayRef<GloballyHashedType> PreviousIds) {
SmallVector<TiReference, 4> Refs;
discoverTypeIndices(RecordData, Refs);
- SHA1 S;
+ TruncatedBLAKE3<8> S;
S.init();
uint32_t Off = 0;
S.update(RecordData.take_front(sizeof(RecordPrefix)));
@@ -76,6 +76,6 @@
auto TrailingBytes = RecordData.drop_front(Off);
S.update(TrailingBytes);
- std::array<uint8_t, 20> Hash = S.final();
- return {ArrayRef<uint8_t>(Hash).take_back(8)};
+ std::array<uint8_t, 8> Hash = S.final();
+ return {ArrayRef<uint8_t>(Hash)};
}
Index: llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -760,7 +760,7 @@
OS.AddComment("Section Version");
OS.emitInt16(0);
OS.AddComment("Hash Algorithm");
- OS.emitInt16(uint16_t(GlobalTypeHashAlg::SHA1_8));
+ OS.emitInt16(uint16_t(GlobalTypeHashAlg::BLAKE3));
TypeIndex TI(TypeIndex::FirstNonSimpleIndex);
for (const auto &GHR : TypeTable.hashes()) {
Index: llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h
===================================================================
--- llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h
+++ llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h
@@ -61,7 +61,8 @@
enum class GlobalTypeHashAlg : uint16_t {
SHA1 = 0, // standard 20-byte SHA1 hash
- SHA1_8 // last 8-bytes of standard SHA1 hash
+ SHA1_8, // last 8-bytes of standard SHA1 hash
+ BLAKE3, // trucated 8-bytes BLAKE3
};
/// A globally hashed type represents a hash value that is sufficient to
Index: lld/COFF/DebugTypes.cpp
===================================================================
--- lld/COFF/DebugTypes.cpp
+++ lld/COFF/DebugTypes.cpp
@@ -280,7 +280,7 @@
debugH = debugH.drop_front(sizeof(object::debug_h_header));
return header->Magic == COFF::DEBUG_HASHES_SECTION_MAGIC &&
header->Version == 0 &&
- header->HashAlgorithm == uint16_t(GlobalTypeHashAlg::SHA1_8) &&
+ header->HashAlgorithm == uint16_t(GlobalTypeHashAlg::BLAKE3) &&
(debugH.size() % 8 == 0);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137101.472031.patch
Type: text/x-patch
Size: 2671 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221031/806c9466/attachment.bin>
More information about the llvm-commits
mailing list