Fix entry BB execution count in llvm-flo

Summary:
When we have tailcalls, the execution count for the entry point is
wrongly computed. Fix this.

(cherry picked from FBD2563112)
This commit is contained in:
Rafael Auler
2015-10-20 16:48:54 -07:00
committed by Maksim Panchenko
parent ab63ca9afb
commit dc848b5376

View File

@@ -501,6 +501,10 @@ void BinaryFunction::inferFallThroughCounts() {
for (auto &CurBB : BasicBlocks) {
auto SuccCount = CurBB.BranchInfo.begin();
for (auto Succ : CurBB.successors()) {
// Do not update execution count of the entry block (when we have tail
// calls). We already accounted for those when computing the func count.
if (Succ == &*BasicBlocks.begin())
continue;
if (SuccCount->Count != BinaryBasicBlock::COUNT_FALLTHROUGH_EDGE)
Succ->ExecutionCount += SuccCount->Count;
++SuccCount;