Skip to content

Commit

Permalink
[NFC][SimplifyCFG] SinkCommonCodeFromPredecessors(): count number of …
Browse files Browse the repository at this point in the history
…instruction "blocks" actually sunk

Out of all the times the function was called,
how many times did we actually sink anything?
  • Loading branch information
LebedevRI committed Jul 15, 2020
1 parent 9ed65c7 commit 3fc1def
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions llvm/lib/Transforms/Utils/SimplifyCFG.cpp
Expand Up @@ -147,6 +147,8 @@ STATISTIC(
NumLookupTablesHoles,
"Number of switch instructions turned into lookup tables (holes checked)");
STATISTIC(NumTableCmpReuses, "Number of reused switch table lookup compares");
STATISTIC(NumSinkCommonCode,
"Number of common instruction 'blocks' sunk down to the end block");
STATISTIC(NumSinkCommonInstrs,
"Number of common instructions sunk down to the end block");
STATISTIC(NumSpeculations, "Number of speculative executed instructions");
Expand Down Expand Up @@ -1880,7 +1882,8 @@ static bool SinkCommonCodeFromPredecessors(BasicBlock *BB) {
// sink presuming a later value will also be sunk, but stop half way through
// and never actually sink it which means we produce more PHIs than intended.
// This is unlikely in practice though.
for (unsigned SinkIdx = 0; SinkIdx != ScanIdx; ++SinkIdx) {
unsigned SinkIdx = 0;
for (; SinkIdx != ScanIdx; ++SinkIdx) {
LLVM_DEBUG(dbgs() << "SINK: Sink: "
<< *UnconditionalPreds[0]->getTerminator()->getPrevNode()
<< "\n");
Expand All @@ -1899,11 +1902,14 @@ static bool SinkCommonCodeFromPredecessors(BasicBlock *BB) {
LLVM_DEBUG(
dbgs()
<< "SINK: stopping here, failed to actually sink instruction!\n");
return Changed;
break;
}

NumSinkCommonInstrs++;
Changed = true;
}
if (SinkIdx != 0)
++NumSinkCommonCode;
return Changed;
}

Expand Down

0 comments on commit 3fc1def

Please sign in to comment.