diff --git a/src/mapleall/maple_me/include/me_cfg.h b/src/mapleall/maple_me/include/me_cfg.h index 380f5a2a58b042b9f3702dd2da3e3aab72dd18b8..9e57184ac213a3f584e293410b2625205a78182e 100644 --- a/src/mapleall/maple_me/include/me_cfg.h +++ b/src/mapleall/maple_me/include/me_cfg.h @@ -362,6 +362,6 @@ MAPLE_MODULE_PHASE_DECLARE_END MAPLE_FUNC_PHASE_DECLARE_BEGIN(MECfgVerifyFrequency, MeFunction) MAPLE_FUNC_PHASE_DECLARE_END -void GdbDumpToFile(MeCFG *cfg, bool dumpEdgeFreq); +void GdbDumpToFile(const MeCFG &cfg, bool dumpEdgeFreq); } // namespace maple #endif // MAPLE_ME_INCLUDE_ME_CFG_H diff --git a/src/mapleall/maple_me/src/lfo_loop_vec.cpp b/src/mapleall/maple_me/src/lfo_loop_vec.cpp index b44c1fe97b831e90a902bc09326a81b81419e9d8..189a49ec6e56fcb3456f5b6a1f4b3ffdb9cd8e6b 100644 --- a/src/mapleall/maple_me/src/lfo_loop_vec.cpp +++ b/src/mapleall/maple_me/src/lfo_loop_vec.cpp @@ -1528,6 +1528,10 @@ void LoopVectorization::VectorizeReductionStmt(StmtNode *stmt, LoopTransPlan *tp StmtNode *copyStmt = stmt->CloneTree(*codeMPAlloc); IntrinsicopNode *intrnvecSum = GenSumVecStmt(regReadlhsvec, regReadlhsvec->GetPrimType()); copyStmt->GetRHS()->SetOpnd(intrnvecSum, 1); + FuncProfInfo *profData = mirFunc->GetFuncProfData(); + if (profData) { + profData->CopyStmtFreq(copyStmt->GetStmtID(), stmt->GetStmtID()); + } tp->vecInfo->afterLoopStmts.push_back(copyStmt); doloopbody->RemoveStmt(stmt); } diff --git a/src/mapleall/maple_me/src/me_critical_edge.cpp b/src/mapleall/maple_me/src/me_critical_edge.cpp index fd97bb2452e55a003cecf55c0b7ee4b1c39d2599..dc52c67bc2e4e60aa27f8800ab94fb3fa6e19b87 100644 --- a/src/mapleall/maple_me/src/me_critical_edge.cpp +++ b/src/mapleall/maple_me/src/me_critical_edge.cpp @@ -304,15 +304,6 @@ bool MESplitCEdge::PhaseRun(maple::MeFunction &f) { bool enableDebug = DEBUGFUNC_NEWPM(f); MeSplitCEdge mscedge = MeSplitCEdge(enableDebug); mscedge.SplitCriticalEdgeForMeFunc(f); - if (Options::profileUse) { - if ((f.IsPme() || f.IsLfo()) && f.GetPreMeFunc()) { - // new inserted BB break cached while/if label information and IR layout - f.GetPreMeFunc()->label2IfInfo.clear(); - f.GetPreMeFunc()->label2WhileInfo.clear(); - f.GetPreMeFunc()->pmeCreatedIfLabelSet.clear(); - f.GetPreMeFunc()->pmeCreatedWhileLabelSet.clear(); - } - } if (f.GetCfg()->UpdateCFGFreq() && (f.GetCfg()->DumpIRProfileFile())) { f.GetCfg()->DumpToFile("after-splitcriticaledge", false, true); } diff --git a/src/mapleall/maple_me/src/me_loop_unrolling.cpp b/src/mapleall/maple_me/src/me_loop_unrolling.cpp index ef62b92744fa156399366b05c067fcae7ac401c9..bb2f79e8539dc9b6f44adfbad2904dedb85d79a2 100644 --- a/src/mapleall/maple_me/src/me_loop_unrolling.cpp +++ b/src/mapleall/maple_me/src/me_loop_unrolling.cpp @@ -487,9 +487,15 @@ bool LoopUnrolling::SplitCondGotoBB() { for (auto *bb : exitBB->GetSucc()) { bb->ReplacePred(exitBB, newCondGotoBB); + if (profValid) { + newCondGotoBB->GetSuccFreq().push_back(0); + } } exitBB->AddSucc(*newCondGotoBB); + if (profValid) { + exitBB->GetSuccFreq().push_back(0); + } exitBB->RemoveMeStmt(lastStmt); newCondGotoBB->InsertMeStmtLastBr(lastStmt); return true; diff --git a/src/mapleall/maple_me/src/me_value_range_prop.cpp b/src/mapleall/maple_me/src/me_value_range_prop.cpp index 11e582d32f710b526923e61df8833aa76eeec61c..93ea6b8eb53b6592ec57fc5b38374e904b05cf7b 100644 --- a/src/mapleall/maple_me/src/me_value_range_prop.cpp +++ b/src/mapleall/maple_me/src/me_value_range_prop.cpp @@ -3985,13 +3985,12 @@ bool ValueRangePropagation::RemoveTheEdgeOfPredBB( uint64 edgeFreq = 0; if (func.GetCfg()->UpdateCFGFreq()) { edgeFreq = pred.GetSuccFreq()[index]; - ASSERT(bb.GetFrequency() >= edgeFreq, "sanity check"); } pred.RemoveSucc(bb); pred.AddSucc(*newBB, index); newBB->AddSucc(trueBranch); if (func.GetCfg()->UpdateCFGFreq()) { - if (bb.GetFrequency() > edgeFreq) { + if (bb.GetFrequency() >= edgeFreq) { bb.SetFrequency(static_cast(bb.GetFrequency() - edgeFreq)); bb.UpdateEdgeFreqs(); } diff --git a/src/mapleall/maple_me/src/optimizeCFG.cpp b/src/mapleall/maple_me/src/optimizeCFG.cpp index 5a5d02ec196abac42f978ef1431cca5112673fd5..a6c6826b3179a0ea3d79cdf05656f67e78b0a1a2 100644 --- a/src/mapleall/maple_me/src/optimizeCFG.cpp +++ b/src/mapleall/maple_me/src/optimizeCFG.cpp @@ -1157,10 +1157,6 @@ bool OptimizeBB::RemoveSuccFromNoReturnBB() { cfg->GetCommonExitBB()->AddExit(*currBB); currBB->SetAttributes(kBBAttrIsExit); ResetBBRunAgain(); - // add edge Frequency to exitbb - if (cfg->UpdateCFGFreq()) { - currBB->PushBackSuccFreq(0); - } return true; } return false; diff --git a/src/mapleall/maple_me/src/pme_emit.cpp b/src/mapleall/maple_me/src/pme_emit.cpp index 5a9fa5e4c4df2f3144703bf4552c267b16146bbc..d5cf1e015ecdf1806c05ab326150012cb9b1e0a1 100644 --- a/src/mapleall/maple_me/src/pme_emit.cpp +++ b/src/mapleall/maple_me/src/pme_emit.cpp @@ -365,6 +365,10 @@ StmtNode* PreMeEmitter::EmitPreMeStmt(MeStmt *meStmt, BaseNode *parent) { switch (meStmt->GetOp()) { case OP_dassign: { DassignMeStmt *dsmestmt = static_cast(meStmt); + if (dsmestmt->GetRHS()->GetMeOp() == kMeOpVar && + static_cast(dsmestmt->GetRHS())->GetOst() == dsmestmt->GetLHS()->GetOst()) { + return nullptr; // identity assignment introduced by LFO + } DassignNode *dass = codeMP->New(); MIRSymbol *sym = dsmestmt->GetLHS()->GetOst()->GetMIRSymbol(); dass->SetStIdx(sym->GetStIdx()); @@ -968,6 +972,10 @@ uint32 PreMeEmitter::Raise2PreMeIf(uint32 curJ, BlockNode *curBlk) { MeStmt *mestmt = curbb->GetFirstMe(); while (mestmt->GetOp() != OP_brfalse && mestmt->GetOp() != OP_brtrue) { StmtNode *stmt = EmitPreMeStmt(mestmt, curBlk); + if (stmt == nullptr) { + mestmt = mestmt->GetNext(); + continue; + } UpdateStmtInfo(*mestmt, *stmt, *curBlk, curbb->GetFrequency()); curBlk->AddStatement(stmt); if (GetFuncProfData() && diff --git a/src/mapleall/maple_me/src/seqvec.cpp b/src/mapleall/maple_me/src/seqvec.cpp index d9788f6c0a7442c68ce60554606682396d11a0af..1feb9978d1c031fcc6334d626b2c905ff9ce5701 100644 --- a/src/mapleall/maple_me/src/seqvec.cpp +++ b/src/mapleall/maple_me/src/seqvec.cpp @@ -572,7 +572,10 @@ void SeqVectorize::MergeIassigns(MapleVector &cands) { blockParent->InsertBefore(iassign, dupScalarStmt); iassign->SetRHS(regreadNode); if (Options::profileUse && mirFunc->GetFuncProfData()) { - mirFunc->GetFuncProfData()->CopyStmtFreq(dupScalarStmt->GetStmtID(), iassign->GetStmtID()); + std::unordered_map &stmtFreqs = mirFunc->GetFuncProfData()->stmtFreqs; + if (stmtFreqs.find(iassign->GetStmtID()) != stmtFreqs.end()) { + mirFunc->GetFuncProfData()->CopyStmtFreq(dupScalarStmt->GetStmtID(), iassign->GetStmtID()); + } } } else if (iassign->GetRHS()->GetOpCode() == OP_iread) { // rhs is iread