Skip to content

Commit 39e6559

Browse files
committed
Address comments from ellishg
1 parent 9eff590 commit 39e6559

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

llvm/include/llvm/ADT/StableHashing.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ inline StringRef get_stable_name(StringRef Name) {
6161
// Generates a consistent hash value for a given input name across different
6262
// program executions and environments. This function first converts the input
6363
// name into a stable form using the `get_stable_name` function, and then
64-
// computes a hash of this stable name.
64+
// computes a hash of this stable name. For instance, `foo.llvm.1234` would have
65+
// the same hash as `foo.llvm.5678.
6566
inline stable_hash stable_hash_name(StringRef Name) {
6667
return xxh3_64bits(get_stable_name(Name));
6768
}

llvm/lib/CodeGen/MachineStableHash.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,21 +84,21 @@ stable_hash llvm::stableHashValue(const MachineOperand &MO) {
8484
}
8585

8686
case MachineOperand::MO_MachineBasicBlock:
87-
StableHashBailingMachineBasicBlock++;
87+
++StableHashBailingMachineBasicBlock;
8888
return 0;
8989
case MachineOperand::MO_ConstantPoolIndex:
90-
StableHashBailingConstantPoolIndex++;
90+
++StableHashBailingConstantPoolIndex;
9191
return 0;
9292
case MachineOperand::MO_BlockAddress:
93-
StableHashBailingBlockAddress++;
93+
++StableHashBailingBlockAddress;
9494
return 0;
9595
case MachineOperand::MO_Metadata:
96-
StableHashBailingMetadataUnsupported++;
96+
++StableHashBailingMetadataUnsupported;
9797
return 0;
9898
case MachineOperand::MO_GlobalAddress: {
9999
const GlobalValue *GV = MO.getGlobal();
100100
if (!GV->hasName()) {
101-
StableHashBailingGlobalAddress++;
101+
++StableHashBailingGlobalAddress;
102102
return 0;
103103
}
104104
auto Name = GV->getName();
@@ -110,7 +110,7 @@ stable_hash llvm::stableHashValue(const MachineOperand &MO) {
110110
if (const char *Name = MO.getTargetIndexName())
111111
return stable_hash_combine(MO.getType(), MO.getTargetFlags(),
112112
stable_hash_name(Name), MO.getOffset());
113-
StableHashBailingTargetIndexNoName++;
113+
++StableHashBailingTargetIndexNoName;
114114
return 0;
115115
}
116116

llvm/unittests/MIR/MachineStableHashTest.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,10 @@ body: |
134134
auto *MF3 = MMI.getMachineFunction(*M->getFunction("f3"));
135135
auto *MF4 = MMI.getMachineFunction(*M->getFunction("f4"));
136136

137-
// Expect the suffix, `.llvm.{number}` to be ignored.
138-
EXPECT_EQ(stableHashValue(*MF1), stableHashValue(*MF2));
139-
// Expect the suffix, `.__uniq.{number}` to be ignored.
140-
EXPECT_EQ(stableHashValue(*MF1), stableHashValue(*MF3));
137+
EXPECT_EQ(stableHashValue(*MF1), stableHashValue(*MF2))
138+
<< "Expect the suffix, `.llvm.{number}` to be ignored.";
139+
EXPECT_EQ(stableHashValue(*MF1), stableHashValue(*MF3))
140+
<< "Expect the suffix, `.__uniq.{number}` to be ignored.";
141141
// Do not ignore `.invalid.{number}`.
142142
EXPECT_NE(stableHashValue(*MF1), stableHashValue(*MF4));
143143
}

0 commit comments

Comments
 (0)