[llvm] [BOLT] Set call to continuation count in pre-aggregated profile (PR #109486)
Maksim Panchenko via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 30 16:56:05 PDT 2024
================
@@ -774,42 +774,86 @@ bool DataAggregator::doInterBranch(BinaryFunction *FromFunc,
}
bool DataAggregator::doBranch(uint64_t From, uint64_t To, uint64_t Count,
- uint64_t Mispreds) {
- bool IsReturn = false;
- auto handleAddress = [&](uint64_t &Addr, bool IsFrom) -> BinaryFunction * {
- if (BinaryFunction *Func = getBinaryFunctionContainingAddress(Addr)) {
- Addr -= Func->getAddress();
- if (IsFrom) {
- auto checkReturn = [&](auto MaybeInst) {
- IsReturn = MaybeInst && BC->MIB->isReturn(*MaybeInst);
- };
- if (Func->hasInstructions())
- checkReturn(Func->getInstructionAtOffset(Addr));
- else
- checkReturn(Func->disassembleInstructionAtOffset(Addr));
- }
+ uint64_t Mispreds, bool IsPreagg) {
+ // Returns whether \p Offset in \p Func contains a return instruction.
+ auto checkReturn = [&](const BinaryFunction &Func, const uint64_t Offset) {
+ auto isReturn = [&](auto MI) { return MI && BC->MIB->isReturn(*MI); };
+ return Func.hasInstructions()
+ ? isReturn(Func.getInstructionAtOffset(Offset))
+ : isReturn(Func.disassembleInstructionAtOffset(Offset));
+ };
- if (BAT)
- Addr = BAT->translate(Func->getAddress(), Addr, IsFrom);
+ // Returns whether \p Offset in \p Func corresponds to a call continuation
+ // fallthrough block.
+ auto checkCallCont = [&](BinaryFunction &Func, const uint64_t Offset) {
+ // Note the use of MCInstrAnalysis: no call continuation for a tail call.
+ auto isCall = [&](auto MI) { return MI && BC->MIA->isCall(*MI); };
+
+ // No call continuation at a function start.
+ if (!Offset)
+ return false;
+
+ // FIXME: support BAT case where the function might be in empty state
----------------
maksfb wrote:
Perhaps we should add secondary entry point and EH info to BAT then. It's important enough from CFG point of view.
https://github.com/llvm/llvm-project/pull/109486
More information about the llvm-commits
mailing list