Skip to content

[llvm] Use hash_combine_range with ranges (NFC) #137530

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/include/llvm/Transforms/Scalar/GVNExpression.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class BasicExpression : public Expression {

hash_code getHashValue() const override {
return hash_combine(this->Expression::getHashValue(), ValueType,
hash_combine_range(op_begin(), op_end()));
hash_combine_range(operands()));
}

// Debugging support
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -933,8 +933,7 @@ Error CoverageMapping::loadFunctionRecord(
}

// Don't create records for (filenames, function) pairs we've already seen.
auto FilenamesHash = hash_combine_range(Record.Filenames.begin(),
Record.Filenames.end());
auto FilenamesHash = hash_combine_range(Record.Filenames);
if (!RecordProvenance[FilenamesHash].insert(hash_value(OrigFuncName)).second)
return Error::success();

Expand Down
27 changes: 11 additions & 16 deletions llvm/lib/Transforms/Scalar/EarlyCSE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,11 @@ static unsigned hashCallInst(CallInst *CI) {
// Don't CSE convergent calls in different basic blocks, because they
// implicitly depend on the set of threads that is currently executing.
if (CI->isConvergent()) {
return hash_combine(
CI->getOpcode(), CI->getParent(),
hash_combine_range(CI->value_op_begin(), CI->value_op_end()));
return hash_combine(CI->getOpcode(), CI->getParent(),
hash_combine_range(CI->operand_values()));
}
return hash_combine(
CI->getOpcode(),
hash_combine_range(CI->value_op_begin(), CI->value_op_end()));
return hash_combine(CI->getOpcode(),
hash_combine_range(CI->operand_values()));
}

static unsigned getHashValueImpl(SimpleValue Val) {
Expand Down Expand Up @@ -302,12 +300,11 @@ static unsigned getHashValueImpl(SimpleValue Val) {

if (const ExtractValueInst *EVI = dyn_cast<ExtractValueInst>(Inst))
return hash_combine(EVI->getOpcode(), EVI->getOperand(0),
hash_combine_range(EVI->idx_begin(), EVI->idx_end()));
hash_combine_range(EVI->indices()));

if (const InsertValueInst *IVI = dyn_cast<InsertValueInst>(Inst))
return hash_combine(IVI->getOpcode(), IVI->getOperand(0),
IVI->getOperand(1),
hash_combine_range(IVI->idx_begin(), IVI->idx_end()));
IVI->getOperand(1), hash_combine_range(IVI->indices()));

assert((isa<CallInst>(Inst) || isa<ExtractElementInst>(Inst) ||
isa<InsertElementInst>(Inst) || isa<ShuffleVectorInst>(Inst) ||
Expand All @@ -322,7 +319,7 @@ static unsigned getHashValueImpl(SimpleValue Val) {
std::swap(LHS, RHS);
return hash_combine(
II->getOpcode(), LHS, RHS,
hash_combine_range(II->value_op_begin() + 2, II->value_op_end()));
hash_combine_range(drop_begin(II->operand_values(), 2)));
}

// gc.relocate is 'special' call: its second and third operands are
Expand All @@ -338,9 +335,8 @@ static unsigned getHashValueImpl(SimpleValue Val) {
return hashCallInst(CI);

// Mix in the opcode.
return hash_combine(
Inst->getOpcode(),
hash_combine_range(Inst->value_op_begin(), Inst->value_op_end()));
return hash_combine(Inst->getOpcode(),
hash_combine_range(Inst->operand_values()));
}

unsigned DenseMapInfo<SimpleValue>::getHashValue(SimpleValue Val) {
Expand Down Expand Up @@ -608,9 +604,8 @@ unsigned DenseMapInfo<GEPValue>::getHashValue(const GEPValue &Val) {
if (Val.ConstantOffset.has_value())
return hash_combine(GEP->getOpcode(), GEP->getPointerOperand(),
Val.ConstantOffset.value());
return hash_combine(
GEP->getOpcode(),
hash_combine_range(GEP->value_op_begin(), GEP->value_op_end()));
return hash_combine(GEP->getOpcode(),
hash_combine_range(GEP->operand_values()));
}

bool DenseMapInfo<GEPValue>::isEqual(const GEPValue &LHS, const GEPValue &RHS) {
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/Transforms/Utils/Local.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1445,9 +1445,9 @@ EliminateDuplicatePHINodesSetBasedImpl(BasicBlock *BB,
// Compute a hash value on the operands. Instcombine will likely have
// sorted them, which helps expose duplicates, but we have to check all
// the operands to be safe in case instcombine hasn't run.
return static_cast<unsigned>(hash_combine(
hash_combine_range(PN->value_op_begin(), PN->value_op_end()),
hash_combine_range(PN->block_begin(), PN->block_end())));
return static_cast<unsigned>(
hash_combine(hash_combine_range(PN->operand_values()),
hash_combine_range(PN->blocks())));
}

static unsigned getHashValue(PHINode *PN) {
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2741,8 +2741,8 @@ struct CSEDenseMapInfo {

static unsigned getHashValue(const Instruction *I) {
assert(canHandle(I) && "Unknown instruction!");
return hash_combine(I->getOpcode(), hash_combine_range(I->value_op_begin(),
I->value_op_end()));
return hash_combine(I->getOpcode(),
hash_combine_range(I->operand_values()));
}

static bool isEqual(const Instruction *LHS, const Instruction *RHS) {
Expand Down