[BOLT] Drop converting return profile to call cont (#129477)
The workaround was not implemented for BAT case, and it is no longer needed with pre-aggregated traces, alternatively, the effect can be achieved with `infer-fall-throughs` with old pre-aggregated format (branches + ranges). Test Plan: updated callcont-fallthru.s
This commit is contained in:
@@ -720,23 +720,6 @@ bool DataAggregator::doBranch(uint64_t From, uint64_t To, uint64_t Count,
|
||||
: isReturn(Func.disassembleInstructionAtOffset(Offset));
|
||||
};
|
||||
|
||||
// Returns whether \p Offset in \p Func may be a call continuation excluding
|
||||
// entry points and landing pads.
|
||||
auto checkCallCont = [&](const BinaryFunction &Func, const uint64_t Offset) {
|
||||
// No call continuation at a function start.
|
||||
if (!Offset)
|
||||
return false;
|
||||
|
||||
// FIXME: support BAT case where the function might be in empty state
|
||||
// (split fragments declared non-simple).
|
||||
if (!Func.hasCFG())
|
||||
return false;
|
||||
|
||||
// The offset should not be an entry point or a landing pad.
|
||||
const BinaryBasicBlock *ContBB = Func.getBasicBlockAtOffset(Offset);
|
||||
return ContBB && !ContBB->isEntryPoint() && !ContBB->isLandingPad();
|
||||
};
|
||||
|
||||
// Mutates \p Addr to an offset into the containing function, performing BAT
|
||||
// offset translation and parent lookup.
|
||||
//
|
||||
@@ -749,8 +732,7 @@ bool DataAggregator::doBranch(uint64_t From, uint64_t To, uint64_t Count,
|
||||
|
||||
Addr -= Func->getAddress();
|
||||
|
||||
bool IsRetOrCallCont =
|
||||
IsFrom ? checkReturn(*Func, Addr) : checkCallCont(*Func, Addr);
|
||||
bool IsRet = IsFrom && checkReturn(*Func, Addr);
|
||||
|
||||
if (BAT)
|
||||
Addr = BAT->translate(Func->getAddress(), Addr, IsFrom);
|
||||
@@ -761,24 +743,16 @@ bool DataAggregator::doBranch(uint64_t From, uint64_t To, uint64_t Count,
|
||||
NumColdSamples += Count;
|
||||
|
||||
if (!ParentFunc)
|
||||
return std::pair{Func, IsRetOrCallCont};
|
||||
return std::pair{Func, IsRet};
|
||||
|
||||
return std::pair{ParentFunc, IsRetOrCallCont};
|
||||
return std::pair{ParentFunc, IsRet};
|
||||
};
|
||||
|
||||
uint64_t ToOrig = To;
|
||||
auto [FromFunc, IsReturn] = handleAddress(From, /*IsFrom*/ true);
|
||||
auto [ToFunc, IsCallCont] = handleAddress(To, /*IsFrom*/ false);
|
||||
auto [ToFunc, _] = handleAddress(To, /*IsFrom*/ false);
|
||||
if (!FromFunc && !ToFunc)
|
||||
return false;
|
||||
|
||||
// Record call to continuation trace.
|
||||
if (NeedsConvertRetProfileToCallCont && FromFunc != ToFunc &&
|
||||
(IsReturn || IsCallCont)) {
|
||||
LBREntry First{ToOrig - 1, ToOrig - 1, false};
|
||||
LBREntry Second{ToOrig, ToOrig, false};
|
||||
return doTrace(First, Second, Count);
|
||||
}
|
||||
// Ignore returns.
|
||||
if (IsReturn)
|
||||
return true;
|
||||
@@ -1235,21 +1209,14 @@ std::error_code DataAggregator::parseAggregatedLBREntry() {
|
||||
ErrorOr<StringRef> TypeOrErr = parseString(FieldSeparator);
|
||||
if (std::error_code EC = TypeOrErr.getError())
|
||||
return EC;
|
||||
// Pre-aggregated profile with branches and fallthroughs needs to convert
|
||||
// return profile into call to continuation fall-through.
|
||||
auto Type = AggregatedLBREntry::BRANCH;
|
||||
if (TypeOrErr.get() == "B") {
|
||||
NeedsConvertRetProfileToCallCont = true;
|
||||
auto Type = AggregatedLBREntry::TRACE;
|
||||
if (LLVM_LIKELY(TypeOrErr.get() == "T")) {
|
||||
} else if (TypeOrErr.get() == "B") {
|
||||
Type = AggregatedLBREntry::BRANCH;
|
||||
} else if (TypeOrErr.get() == "F") {
|
||||
NeedsConvertRetProfileToCallCont = true;
|
||||
Type = AggregatedLBREntry::FT;
|
||||
} else if (TypeOrErr.get() == "f") {
|
||||
NeedsConvertRetProfileToCallCont = true;
|
||||
Type = AggregatedLBREntry::FT_EXTERNAL_ORIGIN;
|
||||
} else if (TypeOrErr.get() == "T") {
|
||||
// Trace is expanded into B and [Ff]
|
||||
Type = AggregatedLBREntry::TRACE;
|
||||
} else {
|
||||
reportError("expected T, B, F or f");
|
||||
return make_error_code(llvm::errc::io_error);
|
||||
|
||||
Reference in New Issue
Block a user