[clang] [llvm] [CodeGen][KCFI] Allow setting type hash from xxHash64 to FNV-1a (PR #167254)

Kees Cook via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 17 13:00:17 PST 2025


================
@@ -0,0 +1,38 @@
+//===- llvm/Support/Hash.h - Hash functions --------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file provides hash functions.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_SUPPORT_HASH_H
+#define LLVM_SUPPORT_HASH_H
+
+#include "llvm/ADT/StringRef.h"
+#include <cstdint>
+
+namespace llvm {
+
+enum class KCFIHashAlgorithm { xxHash64, FNV1a };
+
+/// Parse a KCFI hash algorithm name.
+/// Returns xxHash64 if the name is not recognized.
+KCFIHashAlgorithm parseKCFIHashAlgorithm(StringRef Name);
+
+/// Convert a KCFI hash algorithm enum to its string representation.
+StringRef stringifyKCFIHashAlgorithm(KCFIHashAlgorithm Algorithm);
+
+/// Compute KCFI type ID from mangled type name.
+/// The algorithm can be xxHash64 or FNV-1a.
+uint32_t
+getKCFITypeID(StringRef MangledTypeName,
----------------
kees wrote:

Yeah, I think you're right. We already handle the "missing option" case with `parseKCFIHashAlgorithm`, so this just repeats it. I'll drop this.

https://github.com/llvm/llvm-project/pull/167254


More information about the llvm-commits mailing list