From d681ceb369e7ee19fd065df0a9e36e6f9e8608c9 Mon Sep 17 00:00:00 2001 From: fye Date: Thu, 12 Jan 2023 14:19:06 -0800 Subject: [PATCH] PGO: cfg misc fixes --- src/mapleall/maple_be/src/cg/cg_cfg.cpp | 7 +++++++ src/mapleall/maple_me/src/me_cfg.cpp | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/mapleall/maple_be/src/cg/cg_cfg.cpp b/src/mapleall/maple_be/src/cg/cg_cfg.cpp index d29ea8c596..a2d73f6220 100644 --- a/src/mapleall/maple_be/src/cg/cg_cfg.cpp +++ b/src/mapleall/maple_be/src/cg/cg_cfg.cpp @@ -885,6 +885,13 @@ void CGCFG::UpdatePredsSuccsAfterSplit(BB &pred, BB &succ, BB &newBB) const { } } } + if (cgFunc->GetFunction().GetFuncProfData() != nullptr) { + newBB.InitEdgeProfFreq(); + FreqType newBBFreq = pred.GetEdgeProfFreq(succ); + newBB.SetProfFreq(newBBFreq); + pred.SetEdgeProfFreq(&newBB, newBBFreq); + newBB.SetEdgeProfFreq(&succ, newBBFreq); + } } #if TARGAARCH64 diff --git a/src/mapleall/maple_me/src/me_cfg.cpp b/src/mapleall/maple_me/src/me_cfg.cpp index c532c305c5..5b9c1a56cd 100644 --- a/src/mapleall/maple_me/src/me_cfg.cpp +++ b/src/mapleall/maple_me/src/me_cfg.cpp @@ -1941,14 +1941,14 @@ void MeCFG::ConstructBBFreqFromStmtFreq() { if ((*bIt)->IsEmpty()) continue; StmtNode &first = (*bIt)->GetFirst(); StmtNode &last = (*bIt)->GetLast(); - if (funcData->stmtFreqs.count(first.GetStmtID()) >= 0) { + if (funcData->stmtFreqs.count(first.GetStmtID()) > 0) { (*bIt)->SetFrequency(funcData->stmtFreqs[first.GetStmtID()]); - } else if (funcData->stmtFreqs.count(last.GetStmtID()) >= 0) { + } else if (funcData->stmtFreqs.count(last.GetStmtID()) > 0) { (*bIt)->SetFrequency(funcData->stmtFreqs[last.GetStmtID()]); } else { bool foundFreq = false; for (StmtNode &stmt : (*bIt)->GetStmtNodes()) { - if (funcData->stmtFreqs.count(stmt.GetStmtID()) >= 0) { + if (funcData->stmtFreqs.count(stmt.GetStmtID()) > 0) { (*bIt)->SetFrequency(funcData->stmtFreqs[stmt.GetStmtID()]); foundFreq = true; break; -- Gitee