Skip to content
27 changes: 20 additions & 7 deletions bolt/lib/Profile/DataAggregator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -804,9 +804,13 @@ bool DataAggregator::doBranch(uint64_t From, uint64_t To, uint64_t Count,
};

BinaryFunction *FromFunc = handleAddress(From, /*IsFrom=*/true);
// Ignore returns.
if (IsReturn)
return true;
// Record returns as call->call continuation fall-through.
if (IsReturn) {
LBREntry First{To - 1, To - 1, false};
LBREntry Second{To, To, false};
return doTrace(First, Second, Count);
}

BinaryFunction *ToFunc = handleAddress(To, /*IsFrom=*/false);
if (!FromFunc && !ToFunc)
return false;
Expand All @@ -826,10 +830,19 @@ bool DataAggregator::doTrace(const LBREntry &First, const LBREntry &Second,
BinaryFunction *ToFunc = getBinaryFunctionContainingAddress(Second.From);
if (!FromFunc || !ToFunc) {
LLVM_DEBUG({
dbgs() << "Out of range trace starting in " << FromFunc->getPrintName()
<< formatv(" @ {0:x}", First.To - FromFunc->getAddress())
<< " and ending in " << ToFunc->getPrintName()
<< formatv(" @ {0:x}\n", Second.From - ToFunc->getAddress());
dbgs() << "Out of range trace starting in ";
if (FromFunc)
dbgs() << formatv("{0} @ {1:x}", *FromFunc,
First.To - FromFunc->getAddress());
else
dbgs() << Twine::utohexstr(First.To);
dbgs() << " and ending in ";
if (ToFunc)
dbgs() << formatv("{0} @ {1:x}", *ToFunc,
Second.From - ToFunc->getAddress());
else
dbgs() << Twine::utohexstr(Second.From);
dbgs() << '\n';
});
NumLongRangeTraces += Count;
return false;
Expand Down
21 changes: 21 additions & 0 deletions bolt/test/X86/Inputs/callcont-fallthru.preagg
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
B ffffffff81e01006 401194 8 0
B 401180 401199 98482 96
B 401199 401166 99542 0
B 401177 401130 102776 0
B 401135 40117c 103204 0
B 401186 40118b 1022983 0
B 401194 40117c 1021645 1
F 40117c 401135 1161
F 40117c 401180 92267
F 40118b 401194 991002
F 40117c 401186 968072
F 40118b 401186 11468
F 401130 401135 100015
F 401166 401177 96992
F 401199 401199 96168
F 40117c ffffffff81e01006 7
F 401199 401180 1140
F 401194 ffffffff81e01006 1
F 40117c 401194 11522
F 401166 401199 1151
F 401130 401177 1154
Loading