Skip to content

Commit 68d1ec1

Browse files
committed
Address comments from boomanaiden154
1 parent f1060da commit 68d1ec1

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

llvm/lib/IR/StructuralHash.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ class StructuralHashImpl {
2828

2929
bool DetailedHash;
3030

31+
const stable_hash GlobalHeaderHash = stable_hash_name("Global Header");
32+
const stable_hash FunctionHeaderHash = stable_hash_name("Function Header");
33+
const stable_hash BlockHeaderHash = stable_hash_name("Block Header");
34+
3135
// This will produce different values on 32-bit and 64-bit systens as
3236
// hash_combine returns a size_t. However, this is only used for
3337
// detailed hashing which, in-tree, only needs to distinguish between
@@ -130,7 +134,7 @@ class StructuralHashImpl {
130134

131135
SmallVector<stable_hash> Hashes;
132136
Hashes.emplace_back(Hash);
133-
Hashes.emplace_back(stable_hash_name("Function Header"));
137+
Hashes.emplace_back(FunctionHeaderHash);
134138

135139
Hashes.emplace_back(F.isVarArg());
136140
Hashes.emplace_back(F.arg_size());
@@ -149,7 +153,7 @@ class StructuralHashImpl {
149153
// This random value acts as a block header, as otherwise the partition of
150154
// opcodes into BBs wouldn't affect the hash, only the order of the
151155
// opcodes
152-
Hashes.emplace_back(stable_hash_name("Block Header"));
156+
Hashes.emplace_back(BlockHeaderHash);
153157
for (auto &Inst : *BB)
154158
Hashes.emplace_back(hashInstruction(Inst));
155159

@@ -170,7 +174,7 @@ class StructuralHashImpl {
170174
return;
171175
SmallVector<stable_hash> Hashes;
172176
Hashes.emplace_back(Hash);
173-
Hashes.emplace_back(stable_hash_name("Global Header"));
177+
Hashes.emplace_back(GlobalHeaderHash);
174178
Hashes.emplace_back(GV.getValueType()->getTypeID());
175179

176180
// Update the combined hash in place.

0 commit comments

Comments
 (0)