[llvm] [StableHash] Implement stable global name for the hash computation (PR #106156)

Ellis Hoag via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 27 12:49:14 PDT 2024


================
@@ -50,6 +50,22 @@ inline stable_hash stable_hash_combine(stable_hash A, stable_hash B,
   return stable_hash_combine(Hashes);
 }
 
+// Removes suffixes introduced by LLVM from the name to enhance stability and
+// maintain closeness to the original name across different builds.
+inline StringRef get_stable_name(StringRef Name) {
+  auto [P1, S1] = Name.rsplit(".llvm.");
+  auto [P2, S2] = P1.rsplit(".__uniq.");
+  return P2;
+}
----------------
ellishg wrote:

Similar code is found in a few more place.

https://github.com/search?q=%5C%22.__uniq.%5C%22+repo%3Allvm%2Fllvm-project+path%3A*.cpp&type=code&ref=advsearch

I wonder if it makes sense to put this code somewhere so that the above functions can be replaced with it. That might be better off in a separate PR, though.

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


More information about the llvm-commits mailing list