[llvm] [StructuralHash] Global Variable (PR #118412)
Ellis Hoag via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 2 19:36:50 PST 2024
================
@@ -65,19 +65,44 @@ class StructuralHashImpl {
}
}
- stable_hash hashAPInt(const APInt &I) {
+ static stable_hash hashAPInt(const APInt &I) {
SmallVector<stable_hash> Hashes;
Hashes.emplace_back(I.getBitWidth());
auto RawVals = ArrayRef<uint64_t>(I.getRawData(), I.getNumWords());
Hashes.append(RawVals.begin(), RawVals.end());
return stable_hash_combine(Hashes);
}
- stable_hash hashAPFloat(const APFloat &F) {
+ static stable_hash hashAPFloat(const APFloat &F) {
return hashAPInt(F.bitcastToAPInt());
}
- stable_hash hashGlobalValue(const GlobalValue *GV) {
+ static stable_hash hashGlobalVariable(const GlobalVariable &GVar) {
+ if (!GVar.hasInitializer())
+ return hashGlobalValue(&GVar);
+
+ // Hash the contents of a string.
+ if (GVar.getName().starts_with(".str"))
----------------
ellishg wrote:
This seems like a weird way to detect if a GV is a string. Is there a better way? Could we check if the type if `[* x i8]` or something?
https://github.com/llvm/llvm-project/pull/118412
More information about the llvm-commits
mailing list