================ @@ -2608,6 +2612,21 @@ void WebAssemblyCFGStackify::rewriteDepthImmediates(MachineFunction &MF) { Stack.push_back(std::make_pair(&MBB, &MI)); break; + case WebAssembly::BR_IF: { + // this is the last place where we can easily calculate the branch + // probabilities. we do not emit scf-ifs, therefore, only br_ifs have + // to be annotated with branch probabilities. + if (MF.getSubtarget<WebAssemblySubtarget>().hasBranchHinting() && + MI.getParent()->hasSuccessorProbabilities()) { + const auto Prob = MBPI->getEdgeProbability( + MI.getParent(), MI.operands().begin()->getMBB()); + WebAssemblyFunctionInfo *MFI = MF.getInfo<WebAssemblyFunctionInfo>(); + assert(!MFI->BranchProbabilities.contains(&MI)); + MFI->BranchProbabilities[&MI] = Prob; + } ---------------- Lukasdoe wrote:
Update: The changes in the `CFGGraphStackify` pass are now completely reverted. Branch hints are only generated based on `br_if` instructions encountered during ASM printing, mostly based on @kripken 's earlier contribution. This change significantly reduces the memory overhead (and probably runtime overhead), since we do not store branch hints for branches that are removed by passes after `CFGStackify`. https://github.com/llvm/llvm-project/pull/146230 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits