[llvm] [BOLT] Allow pass-through blocks in YAMLProfileReader (PR #91828)
Alexander Yermolovich via llvm-commits
llvm-commits at lists.llvm.org
Mon May 13 11:20:09 PDT 2024
================
@@ -218,17 +218,29 @@ bool YAMLProfileReader::parseFunctionProfile(
continue;
}
- BinaryBasicBlock &SuccessorBB = *Order[YamlSI.Index];
- if (!BB.getSuccessor(SuccessorBB.getLabel())) {
- if (opts::Verbosity >= 1)
- errs() << "BOLT-WARNING: no successor for block " << BB.getName()
- << " that matches index " << YamlSI.Index << " or block "
- << SuccessorBB.getName() << '\n';
- ++MismatchedEdges;
- continue;
+ BinaryBasicBlock *ToBB = Order[YamlSI.Index];
+ if (!BB.getSuccessor(ToBB->getLabel())) {
+ // Allow for BOLT-removed passthrough blocks to align with DataReader
+ // behavior.
+ BinaryBasicBlock *FTSuccessor = BB.getConditionalSuccessor(false);
+ if (FTSuccessor && FTSuccessor->succ_size() == 1 &&
+ FTSuccessor->getSuccessor(ToBB->getLabel())) {
+ BinaryBasicBlock::BinaryBranchInfo &FTBI =
+ FTSuccessor->getBranchInfo(*ToBB);
+ FTBI.Count += YamlSI.Count;
+ FTBI.MispredictedCount += YamlSI.Mispreds;
+ ToBB = FTSuccessor;
+ } else {
+ if (opts::Verbosity >= 1)
+ errs() << "BOLT-WARNING: no successor for block " << BB.getName()
----------------
ayermolo wrote:
Thought we know using BC for logging?
https://github.com/llvm/llvm-project/pull/91828
More information about the llvm-commits
mailing list