Skip to content

Commit b01e25d

Browse files
[llvm] Call hash_combine_range with ranges (NFC) (#136511)
1 parent f87109f commit b01e25d

23 files changed

+51
-76
lines changed

llvm/include/llvm/ADT/ArrayRef.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ namespace llvm {
562562
/// @}
563563

564564
template <typename T> hash_code hash_value(ArrayRef<T> S) {
565-
return hash_combine_range(S.begin(), S.end());
565+
return hash_combine_range(S);
566566
}
567567

568568
// Provide DenseMapInfo for ArrayRefs.

llvm/include/llvm/ADT/Hashing.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ template <typename... Ts> hash_code hash_value(const std::tuple<Ts...> &arg) {
649649
// infrastructure is available.
650650
template <typename T>
651651
hash_code hash_value(const std::basic_string<T> &arg) {
652-
return hash_combine_range(arg.begin(), arg.end());
652+
return hash_combine_range(arg);
653653
}
654654

655655
template <typename T> hash_code hash_value(const std::optional<T> &arg) {

llvm/include/llvm/Analysis/IRSimilarityIdentifier.h

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -263,37 +263,35 @@ struct IRInstructionData
263263
OperTypes.push_back(V->getType());
264264

265265
if (isa<CmpInst>(ID.Inst))
266-
return llvm::hash_combine(
267-
llvm::hash_value(ID.Inst->getOpcode()),
268-
llvm::hash_value(ID.Inst->getType()),
269-
llvm::hash_value(ID.getPredicate()),
270-
llvm::hash_combine_range(OperTypes.begin(), OperTypes.end()));
266+
return llvm::hash_combine(llvm::hash_value(ID.Inst->getOpcode()),
267+
llvm::hash_value(ID.Inst->getType()),
268+
llvm::hash_value(ID.getPredicate()),
269+
llvm::hash_combine_range(OperTypes));
271270

272271
if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(ID.Inst)) {
273272
// To hash intrinsics, we use the opcode, and types like the other
274273
// instructions, but also, the Intrinsic ID, and the Name of the
275274
// intrinsic.
276275
Intrinsic::ID IntrinsicID = II->getIntrinsicID();
277-
return llvm::hash_combine(
278-
llvm::hash_value(ID.Inst->getOpcode()),
279-
llvm::hash_value(ID.Inst->getType()), llvm::hash_value(IntrinsicID),
280-
llvm::hash_value(*ID.CalleeName),
281-
llvm::hash_combine_range(OperTypes.begin(), OperTypes.end()));
276+
return llvm::hash_combine(llvm::hash_value(ID.Inst->getOpcode()),
277+
llvm::hash_value(ID.Inst->getType()),
278+
llvm::hash_value(IntrinsicID),
279+
llvm::hash_value(*ID.CalleeName),
280+
llvm::hash_combine_range(OperTypes));
282281
}
283282

284283
if (isa<CallInst>(ID.Inst)) {
285284
std::string FunctionName = *ID.CalleeName;
286-
return llvm::hash_combine(
287-
llvm::hash_value(ID.Inst->getOpcode()),
288-
llvm::hash_value(ID.Inst->getType()),
289-
llvm::hash_value(ID.Inst->getType()), llvm::hash_value(FunctionName),
290-
llvm::hash_combine_range(OperTypes.begin(), OperTypes.end()));
285+
return llvm::hash_combine(llvm::hash_value(ID.Inst->getOpcode()),
286+
llvm::hash_value(ID.Inst->getType()),
287+
llvm::hash_value(ID.Inst->getType()),
288+
llvm::hash_value(FunctionName),
289+
llvm::hash_combine_range(OperTypes));
291290
}
292291

293-
return llvm::hash_combine(
294-
llvm::hash_value(ID.Inst->getOpcode()),
295-
llvm::hash_value(ID.Inst->getType()),
296-
llvm::hash_combine_range(OperTypes.begin(), OperTypes.end()));
292+
return llvm::hash_combine(llvm::hash_value(ID.Inst->getOpcode()),
293+
llvm::hash_value(ID.Inst->getType()),
294+
llvm::hash_combine_range(OperTypes));
297295
}
298296

299297
IRInstructionDataList *IDL = nullptr;

llvm/include/llvm/ProfileData/SampleProf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ using SampleContextFrames = ArrayRef<SampleContextFrame>;
506506

507507
struct SampleContextFrameHash {
508508
uint64_t operator()(const SampleContextFrameVector &S) const {
509-
return hash_combine_range(S.begin(), S.end());
509+
return hash_combine_range(S);
510510
}
511511
};
512512

llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,7 @@ struct SpecSig {
119119
}
120120

121121
friend hash_code hash_value(const SpecSig &S) {
122-
return hash_combine(hash_value(S.Key),
123-
hash_combine_range(S.Args.begin(), S.Args.end()));
122+
return hash_combine(hash_value(S.Key), hash_combine_range(S.Args));
124123
}
125124
};
126125

llvm/lib/CodeGen/MIRVRegNamerUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ std::string VRegRenamer::getInstructionOpcodeHash(MachineInstr &MI) {
131131
MIOperands.push_back((unsigned)Op->getFailureOrdering());
132132
}
133133

134-
auto HashMI = hash_combine_range(MIOperands.begin(), MIOperands.end());
134+
auto HashMI = hash_combine_range(MIOperands);
135135
OS << format_hex_no_prefix(HashMI, 16, true);
136136
return OS.str();
137137
}

llvm/lib/CodeGen/MachineInstr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2306,7 +2306,7 @@ MachineInstrExpressionTrait::getHashValue(const MachineInstr* const &MI) {
23062306

23072307
HashComponents.push_back(hash_value(MO));
23082308
}
2309-
return hash_combine_range(HashComponents.begin(), HashComponents.end());
2309+
return hash_combine_range(HashComponents);
23102310
}
23112311

23122312
const MDNode *MachineInstr::getLocCookieMD() const {

llvm/lib/CodeGen/RegisterBankInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ hashValueMapping(const RegisterBankInfo::PartialMapping *BreakDown,
307307
SmallVector<size_t, 8> Hashes(NumBreakDowns);
308308
for (unsigned Idx = 0; Idx != NumBreakDowns; ++Idx)
309309
Hashes.push_back(hash_value(BreakDown[Idx]));
310-
return hash_combine_range(Hashes.begin(), Hashes.end());
310+
return hash_combine_range(Hashes);
311311
}
312312

313313
const RegisterBankInfo::ValueMapping &

llvm/lib/ExecutionEngine/Orc/IRPartitionLayer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ void IRPartitionLayer::emitPartition(
268268
for (const auto *GV : HashGVs) {
269269
assert(GV->hasName() && "All GVs to extract should be named by now");
270270
auto GVName = GV->getName();
271-
HC = hash_combine(HC, hash_combine_range(GVName.begin(), GVName.end()));
271+
HC = hash_combine(HC, hash_combine_range(GVName));
272272
}
273273
raw_string_ostream(SubModuleName)
274274
<< ".submodule."

llvm/lib/IR/ConstantsContext.h

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,7 @@ template <class ConstantClass> struct ConstantAggrKeyType {
322322
return true;
323323
}
324324

325-
unsigned getHash() const {
326-
return hash_combine_range(Operands.begin(), Operands.end());
327-
}
325+
unsigned getHash() const { return hash_combine_range(Operands); }
328326

329327
using TypeClass = typename ConstantInfo<ConstantClass>::TypeClass;
330328

@@ -478,10 +476,8 @@ struct ConstantExprKeyType {
478476
}
479477

480478
unsigned getHash() const {
481-
return hash_combine(
482-
Opcode, SubclassOptionalData,
483-
hash_combine_range(Ops.begin(), Ops.end()),
484-
hash_combine_range(ShuffleMask.begin(), ShuffleMask.end()), ExplicitTy);
479+
return hash_combine(Opcode, SubclassOptionalData, hash_combine_range(Ops),
480+
hash_combine_range(ShuffleMask), ExplicitTy);
485481
}
486482

487483
using TypeClass = ConstantInfo<ConstantExpr>::TypeClass;
@@ -537,9 +533,7 @@ struct ConstantPtrAuthKeyType {
537533
return true;
538534
}
539535

540-
unsigned getHash() const {
541-
return hash_combine_range(Operands.begin(), Operands.end());
542-
}
536+
unsigned getHash() const { return hash_combine_range(Operands); }
543537

544538
using TypeClass = typename ConstantInfo<ConstantPtrAuth>::TypeClass;
545539

0 commit comments

Comments
 (0)