[llvm] 77e5c0a - [AArch64][GISEL] Reduce likelihood of hash collisions for mappings in RegisterBankInfo (#87033)

via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 2 01:49:11 PDT 2024


Author: Marc Auberer
Date: 2024-04-02T10:49:06+02:00
New Revision: 77e5c0a95c54e0ca34b8e9c56c702490619b73c9

URL: https://github.com/llvm/llvm-project/commit/77e5c0a95c54e0ca34b8e9c56c702490619b73c9
DIFF: https://github.com/llvm/llvm-project/commit/77e5c0a95c54e0ca34b8e9c56c702490619b73c9.diff

LOG: [AArch64][GISEL] Reduce likelihood of hash collisions for mappings in RegisterBankInfo (#87033)

Fixes #85209

This patch removes the truncation from `hash_code` aka `size_t` down to
`unsigned`, that currently happens on DenseMap accesses in
RegisterBankInfo. This reduces the likelihood of hash collisions, as
well as the likelihood of hitting EmptyKey or TombstoneKey, the special
key values of DenseMap. This is not the ultimate solution to the
problem, but we can do it in any case.

Added: 
    

Modified: 
    llvm/include/llvm/CodeGen/RegisterBankInfo.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/CodeGen/RegisterBankInfo.h b/llvm/include/llvm/CodeGen/RegisterBankInfo.h
index 62c4a57a605d68..9704e3b1fdedd6 100644
--- a/llvm/include/llvm/CodeGen/RegisterBankInfo.h
+++ b/llvm/include/llvm/CodeGen/RegisterBankInfo.h
@@ -399,22 +399,22 @@ class RegisterBankInfo {
 
   /// Keep dynamically allocated PartialMapping in a separate map.
   /// This shouldn't be needed when everything gets TableGen'ed.
-  mutable DenseMap<unsigned, std::unique_ptr<const PartialMapping>>
+  mutable DenseMap<hash_code, std::unique_ptr<const PartialMapping>>
       MapOfPartialMappings;
 
   /// Keep dynamically allocated ValueMapping in a separate map.
   /// This shouldn't be needed when everything gets TableGen'ed.
-  mutable DenseMap<unsigned, std::unique_ptr<const ValueMapping>>
+  mutable DenseMap<hash_code, std::unique_ptr<const ValueMapping>>
       MapOfValueMappings;
 
   /// Keep dynamically allocated array of ValueMapping in a separate map.
   /// This shouldn't be needed when everything gets TableGen'ed.
-  mutable DenseMap<unsigned, std::unique_ptr<ValueMapping[]>>
+  mutable DenseMap<hash_code, std::unique_ptr<ValueMapping[]>>
       MapOfOperandsMappings;
 
   /// Keep dynamically allocated InstructionMapping in a separate map.
   /// This shouldn't be needed when everything gets TableGen'ed.
-  mutable DenseMap<unsigned, std::unique_ptr<const InstructionMapping>>
+  mutable DenseMap<hash_code, std::unique_ptr<const InstructionMapping>>
       MapOfInstructionMappings;
 
   /// Getting the minimal register class of a physreg is expensive.


        


More information about the llvm-commits mailing list