[llvm] [BOLT] Introduce profile-use-std-hash (PR #74253)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 3 13:28:26 PST 2023
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff e315bf25a843582de39257e1345408a10dc08224 1ded354afb256fff255871696333e9e9fad3f0a3 -- bolt/include/bolt/Core/BinaryFunction.h bolt/include/bolt/Profile/ProfileYAMLMapping.h bolt/lib/Core/BinaryFunction.cpp bolt/lib/Passes/IdenticalCodeFolding.cpp bolt/lib/Profile/StaleProfileMatching.cpp bolt/lib/Profile/YAMLProfileReader.cpp bolt/lib/Profile/YAMLProfileWriter.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/bolt/include/bolt/Core/BinaryFunction.h b/bolt/include/bolt/Core/BinaryFunction.h
index 944755168c..40206b8aee 100644
--- a/bolt/include/bolt/Core/BinaryFunction.h
+++ b/bolt/include/bolt/Core/BinaryFunction.h
@@ -2241,8 +2241,7 @@ public:
/// The caller can change this via passing \p OperandHashFunc function.
/// The return result of this function will be mixed with internal hash.
size_t computeHash(
- bool UseDFS = false,
- bool UseStdHash = false,
+ bool UseDFS = false, bool UseStdHash = false,
OperandHashFuncTy OperandHashFunc = [](const MCOperand &) {
return std::string();
}) const;
diff --git a/bolt/lib/Core/BinaryFunction.cpp b/bolt/lib/Core/BinaryFunction.cpp
index ed350e06e7..044777cf91 100644
--- a/bolt/lib/Core/BinaryFunction.cpp
+++ b/bolt/lib/Core/BinaryFunction.cpp
@@ -3652,7 +3652,8 @@ size_t BinaryFunction::computeHash(bool UseDFS, bool UseStdHash,
for (const BinaryBasicBlock *BB : Order)
HashString.append(hashBlock(BC, *BB, OperandHashFunc));
- return Hash = UseStdHash ? std::hash<std::string>{}(HashString) : llvm::xxh3_64bits(HashString);
+ return Hash = UseStdHash ? std::hash<std::string>{}(HashString)
+ : llvm::xxh3_64bits(HashString);
}
void BinaryFunction::insertBasicBlocks(
diff --git a/bolt/lib/Passes/IdenticalCodeFolding.cpp b/bolt/lib/Passes/IdenticalCodeFolding.cpp
index 7d6ed6f807..f4b1b50db9 100644
--- a/bolt/lib/Passes/IdenticalCodeFolding.cpp
+++ b/bolt/lib/Passes/IdenticalCodeFolding.cpp
@@ -360,9 +360,9 @@ void IdenticalCodeFolding::runOnFunctions(BinaryContext &BC) {
// Pre-compute hash before pushing into hashtable.
// Hash instruction operands to minimize hash collisions.
- BF.computeHash(opts::ICFUseDFS, /*UseStdHash=*/false, [&BC](const MCOperand &Op) {
- return hashInstOperand(BC, Op);
- });
+ BF.computeHash(
+ opts::ICFUseDFS, /*UseStdHash=*/false,
+ [&BC](const MCOperand &Op) { return hashInstOperand(BC, Op); });
};
ParallelUtilities::PredicateTy SkipFunc = [&](const BinaryFunction &BF) {
diff --git a/bolt/lib/Profile/StaleProfileMatching.cpp b/bolt/lib/Profile/StaleProfileMatching.cpp
index 3f027bb4ba..fce47dcebc 100644
--- a/bolt/lib/Profile/StaleProfileMatching.cpp
+++ b/bolt/lib/Profile/StaleProfileMatching.cpp
@@ -241,11 +241,13 @@ void BinaryFunction::computeBlockHashes(bool UseStdHash) const {
// Hashing complete instructions.
std::string InstrHashStr = hashBlock(
BC, *BB, [&](const MCOperand &Op) { return hashInstOperand(BC, Op); });
- uint64_t InstrHash = UseStdHash ? std::hash<std::string>{}(InstrHashStr) : llvm::xxh3_64bits(InstrHashStr);
+ uint64_t InstrHash = UseStdHash ? std::hash<std::string>{}(InstrHashStr)
+ : llvm::xxh3_64bits(InstrHashStr);
BlendedHashes[I].InstrHash = (uint16_t)InstrHash;
// Hashing opcodes.
std::string OpcodeHashStr = hashBlockLoose(BC, *BB);
- OpcodeHashes[I] = UseStdHash ? std::hash<std::string>{}(OpcodeHashStr) : llvm::xxh3_64bits(OpcodeHashStr);
+ OpcodeHashes[I] = UseStdHash ? std::hash<std::string>{}(OpcodeHashStr)
+ : llvm::xxh3_64bits(OpcodeHashStr);
BlendedHashes[I].OpcodeHash = (uint16_t)OpcodeHashes[I];
}
diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp
index 9ae52f3df6..4a44eb64b4 100644
--- a/bolt/lib/Profile/YAMLProfileReader.cpp
+++ b/bolt/lib/Profile/YAMLProfileReader.cpp
@@ -104,7 +104,8 @@ bool YAMLProfileReader::parseFunctionProfile(
FuncRawBranchCount += YamlSI.Count;
BF.setRawBranchCount(FuncRawBranchCount);
- if (!opts::IgnoreHash && YamlBF.Hash != BF.computeHash(IsDFSOrder, IsStdHash)) {
+ if (!opts::IgnoreHash &&
+ YamlBF.Hash != BF.computeHash(IsDFSOrder, IsStdHash)) {
if (opts::Verbosity >= 1)
errs() << "BOLT-WARNING: function hash mismatch\n";
ProfileMatched = false;
``````````
</details>
https://github.com/llvm/llvm-project/pull/74253
More information about the llvm-commits
mailing list