[llvm] r260197 - Refactor PGO function naming and MD5 hashing support out of ProfileData

Joerg Sonnenberger via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 9 02:07:16 PST 2016


On Tue, Feb 09, 2016 at 05:12:44AM -0000, Teresa Johnson via llvm-commits wrote:
> @@ -65,6 +66,18 @@ private:
>    const uint8_t *body(ArrayRef<uint8_t> Data);
>  };
>  
> +/// Helper to compute and return a 64-bit MD5 Hash of a given string.
> +inline uint64_t MD5Hash(StringRef Str) {
> +  MD5 Hash;
> +  Hash.update(Str);
> +  llvm::MD5::MD5Result Result;
> +  Hash.final(Result);
> +  // Return the least significant 8 bytes. Our MD5 implementation returns the
> +  // result in little endian, so we may need to swap bytes.
> +  using namespace llvm::support;
> +  return endian::read<uint64_t, little, unaligned>(Result);
> +}
> +
>  }
>  
>  #endif

If you want to comment on what MD5Hash is doing, at least make it
something sane please. There is nothing like a 64-bit MD5 Hash, but
something like "the 64 least significant bits of the MD5 hash".

Joerg


More information about the llvm-commits mailing list