Skip to content

Commit 8839ba4

Browse files
[Instrumentation] Avoid repeated hash lookups (NFC) (#129988)
Co-authored-by: Nikita Popov <[email protected]>
1 parent 93b3cba commit 8839ba4

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1517,9 +1517,10 @@ void PGOUseFunc::populateCoverage(IndexedInstrProfReader *PGOReader) {
15171517
CoveredBlocksToProcess.pop();
15181518
for (auto *BB : InverseDependencies[CoveredBlock]) {
15191519
// If CoveredBlock is covered then BB is covered.
1520-
if (Coverage[BB])
1520+
bool &Cov = Coverage[BB];
1521+
if (Cov)
15211522
continue;
1522-
Coverage[BB] = true;
1523+
Cov = true;
15231524
CoveredBlocksToProcess.push(BB);
15241525
}
15251526
}
@@ -1563,14 +1564,15 @@ void PGOUseFunc::populateCoverage(IndexedInstrProfReader *PGOReader) {
15631564
// successors, e.g., when a block calls a function that may call exit(). In
15641565
// those cases, BFI could find its successor to be covered while BCI could
15651566
// find its successor to be dead.
1566-
if (Coverage[&BB] == IsBlockDead(BB).value_or(false)) {
1567+
const bool &Cov = Coverage[&BB];
1568+
if (Cov == IsBlockDead(BB).value_or(false)) {
15671569
LLVM_DEBUG(
15681570
dbgs() << "Found inconsistent block covearge for " << BB.getName()
1569-
<< ": BCI=" << (Coverage[&BB] ? "Covered" : "Dead") << " BFI="
1571+
<< ": BCI=" << (Cov ? "Covered" : "Dead") << " BFI="
15701572
<< (IsBlockDead(BB).value() ? "Dead" : "Covered") << "\n");
15711573
++NumCorruptCoverage;
15721574
}
1573-
if (Coverage[&BB])
1575+
if (Cov)
15741576
++NumCoveredBlocks;
15751577
}
15761578
if (PGOVerifyBFI && NumCorruptCoverage) {

0 commit comments

Comments
 (0)