forked from OSchip/llvm-project
[BOLT] Fix profile for multi-entry functions
Summary: When we read profile for functions, we initialize counts for entry blocks first, and then populate counts for all blocks based on incoming edges. During the second phase we ignore the entry blocks because we expect them to be already initialized. For the primary entry at offset 0 it's the correct thing to do, since we treat all incoming branches as calls or tail calls. However, for secondary entries we only consider external edges to be from calls and don't increase entry count if an edge originates from inside the function. Thus we need to update the secondary entry basic block counts with internal edges too. (cherry picked from FBD6836817)
This commit is contained in:
parent
304c8ba80a
commit
d114ef1fa5
|
@ -366,8 +366,10 @@ void BinaryFunction::postProcessProfile() {
|
|||
for (auto *BB : BasicBlocks) {
|
||||
auto SuccBIIter = BB->branch_info_begin();
|
||||
for (auto Succ : BB->successors()) {
|
||||
if (!Succ->isEntryPoint() &&
|
||||
SuccBIIter->Count != BinaryBasicBlock::COUNT_NO_PROFILE)
|
||||
// All incoming edges to the primary entry have been accounted for, thus
|
||||
// we skip the update here.
|
||||
if (SuccBIIter->Count != BinaryBasicBlock::COUNT_NO_PROFILE &&
|
||||
Succ != BasicBlocks.front())
|
||||
Succ->setExecutionCount(Succ->getExecutionCount() + SuccBIIter->Count);
|
||||
++SuccBIIter;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue