diff --git a/lld/COFF/DebugTypes.cpp b/lld/COFF/DebugTypes.cpp --- a/lld/COFF/DebugTypes.cpp +++ b/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); } diff --git a/llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h b/llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h --- a/llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h +++ b/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 diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp --- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp +++ b/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()) { diff --git a/llvm/lib/DebugInfo/CodeView/TypeHashing.cpp b/llvm/lib/DebugInfo/CodeView/TypeHashing.cpp --- a/llvm/lib/DebugInfo/CodeView/TypeHashing.cpp +++ b/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 PreviousIds) { SmallVector 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 Hash = S.final(); - return {ArrayRef(Hash).take_back(8)}; + std::array Hash = S.final(); + return {ArrayRef(Hash)}; }