[all-commits] [llvm/llvm-project] 330268: [Support/Hash functions] Change the `final()` and ...

Argyrios Kyrtzidis via All-commits all-commits at lists.llvm.org
Tue Apr 5 21:38:22 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 330268ba346b679af786879d8f696c8c412a40eb
      https://github.com/llvm/llvm-project/commit/330268ba346b679af786879d8f696c8c412a40eb
  Author: Argyrios Kyrtzidis <kyrtzidis at apple.com>
  Date:   2022-04-05 (Tue, 05 Apr 2022)

  Changed paths:
    M bolt/lib/Core/DebugData.cpp
    M clang/include/clang/Basic/Module.h
    M clang/lib/Serialization/ASTWriter.cpp
    M lld/MachO/SyntheticSections.cpp
    M llvm/include/llvm/Support/BLAKE3.h
    M llvm/include/llvm/Support/HashBuilder.h
    M llvm/include/llvm/Support/MD5.h
    M llvm/include/llvm/Support/SHA1.h
    M llvm/include/llvm/Support/SHA256.h
    M llvm/include/llvm/Support/raw_sha1_ostream.h
    M llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp
    M llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
    M llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
    M llvm/lib/DebugInfo/CodeView/TypeHashing.cpp
    M llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
    M llvm/lib/MC/MCDwarf.cpp
    M llvm/lib/MC/MCParser/AsmParser.cpp
    M llvm/lib/MC/MCParser/MasmParser.cpp
    M llvm/lib/ObjCopy/MachO/MachOWriter.cpp
    M llvm/lib/Support/BLAKE3/README.md
    M llvm/lib/Support/MD5.cpp
    M llvm/lib/Support/SHA1.cpp
    M llvm/lib/Support/SHA256.cpp
    M llvm/unittests/Support/BLAKE3Test.cpp
    M llvm/unittests/Support/HashBuilderTest.cpp
    M llvm/unittests/Support/MD5Test.cpp
    M llvm/unittests/Support/SHA256.cpp
    M llvm/unittests/Support/raw_sha1_ostream_test.cpp
    M mlir/lib/Pass/IRPrinting.cpp

  Log Message:
  -----------
  [Support/Hash functions] Change the `final()` and `result()` of the hashing functions to return an array of bytes

Returning `std::array<uint8_t, N>` is better ergonomics for the hashing functions usage, instead of a `StringRef`:

* When returning `StringRef`, client code is "jumping through hoops" to do string manipulations instead of dealing with fixed array of bytes directly, which is more natural
* Returning `std::array<uint8_t, N>` avoids the need for the hasher classes to keep a field just for the purpose of wrapping it and returning it as a `StringRef`

As part of this patch also:

* Introduce `TruncatedBLAKE3` which is useful for using BLAKE3 as the hasher type for `HashBuilder` with non-default hash sizes.
* Make `MD5Result` inherit from `std::array<uint8_t, 16>` which improves & simplifies its API.

Differential Revision: https://reviews.llvm.org/D123100




More information about the All-commits mailing list