[llvm] [StructuralHash] Global Variable (PR #118412)
Kyungwoo Lee via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 2 22:35:56 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"))
----------------
kyulee-com wrote:
Added a string condition, using `ConstantDataSequential`.
https://github.com/llvm/llvm-project/pull/118412
More information about the llvm-commits
mailing list