Explorar o código

[spirv] Improve the hashing function for function type.

Ehsan Nasiri %!s(int64=6) %!d(string=hai) anos
pai
achega
b486eb362b
Modificáronse 1 ficheiros con 5 adicións e 2 borrados
  1. 5 2
      tools/clang/include/clang/SPIRV/SpirvContext.h

+ 5 - 2
tools/clang/include/clang/SPIRV/SpirvContext.h

@@ -98,8 +98,11 @@ struct FunctionTypeMapInfo {
   static inline FunctionType *getTombstoneKey() { return nullptr; }
   static unsigned getHashValue(const FunctionType *Val) {
     // Hashing based on return type and number of function parameters.
-    return llvm::hash_combine(Val->getReturnType(),
-                              Val->getParamTypes().size());
+    auto hashCode =
+        llvm::hash_combine(Val->getReturnType(), Val->getParamTypes().size());
+    for (const SpirvType *paramType : Val->getParamTypes())
+      hashCode = llvm::hash_combine(hashCode, paramType);
+    return hashCode;
   }
   static bool isEqual(const FunctionType *LHS, const FunctionType *RHS) {
     // Either both are null, or both should have the same underlying type.