[llvm] [Instrumentation] Avoid repeated hash lookups (NFC) (PR #129988)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 5 21:55:29 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/129988.diff
1 Files Affected:
- (modified) llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp (+7-5)
``````````diff
diff --git a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
index 5ad07e83d1273..ef7b0bb125dc9 100644
--- a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
+++ b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
@@ -1517,9 +1517,10 @@ void PGOUseFunc::populateCoverage(IndexedInstrProfReader *PGOReader) {
CoveredBlocksToProcess.pop();
for (auto *BB : InverseDependencies[CoveredBlock]) {
// If CoveredBlock is covered then BB is covered.
- if (Coverage[BB])
+ auto &Cov = Coverage[BB];
+ if (Cov)
continue;
- Coverage[BB] = true;
+ Cov = true;
CoveredBlocksToProcess.push(BB);
}
}
@@ -1563,14 +1564,15 @@ void PGOUseFunc::populateCoverage(IndexedInstrProfReader *PGOReader) {
// successors, e.g., when a block calls a function that may call exit(). In
// those cases, BFI could find its successor to be covered while BCI could
// find its successor to be dead.
- if (Coverage[&BB] == IsBlockDead(BB).value_or(false)) {
+ auto &Cov = Coverage[&BB];
+ if (Cov == IsBlockDead(BB).value_or(false)) {
LLVM_DEBUG(
dbgs() << "Found inconsistent block covearge for " << BB.getName()
- << ": BCI=" << (Coverage[&BB] ? "Covered" : "Dead") << " BFI="
+ << ": BCI=" << (Cov ? "Covered" : "Dead") << " BFI="
<< (IsBlockDead(BB).value() ? "Dead" : "Covered") << "\n");
++NumCorruptCoverage;
}
- if (Coverage[&BB])
+ if (Cov)
++NumCoveredBlocks;
}
if (PGOVerifyBFI && NumCorruptCoverage) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/129988
More information about the llvm-commits
mailing list