diff --git a/src/mapleall/maple_me/include/bb.h b/src/mapleall/maple_me/include/bb.h index 4c1f38b4a131787228e876740ad9b831e805718b..7f9104c4758a335bfcfc7d62bf79b940ee1e3703 100644 --- a/src/mapleall/maple_me/include/bb.h +++ b/src/mapleall/maple_me/include/bb.h @@ -24,7 +24,6 @@ namespace maple { class MeStmt; // circular dependency exists, no other choice class MePhiNode; // circular dependency exists, no other choice -class MeRegPhiNode; // circular dependency exists, no other choice class PiassignMeStmt; // circular dependency exists, no other choice class IRMap; // circular dependency exists, no other choice enum BBKind { diff --git a/src/mapleall/maple_me/include/me_function.h b/src/mapleall/maple_me/include/me_function.h index 4f00c319278085075ef9c3d9e469ef96728ad1e7..27b753a5a2b9527625467bf824c25c0f4056fd13 100644 --- a/src/mapleall/maple_me/include/me_function.h +++ b/src/mapleall/maple_me/include/me_function.h @@ -346,6 +346,10 @@ class MeFunction : public FuncEmit { bool isLfo; LfoFunction *lfoFunc; MemPool *lfoMp; // used for lfo function + public: + uint32 dseRuns = 0; // number of times dse phase has been run + uint32 hdseRuns = 0; // number of times hdse phase has been run + uint32 hpropRuns = 0; // number of times hprop phase has been run }; } // namespace maple #endif // MAPLE_ME_INCLUDE_ME_FUNCTION_H diff --git a/src/mapleall/maple_me/include/me_option.h b/src/mapleall/maple_me/include/me_option.h index 7ae67045d6491563e62d9a723d6d0c9f6008a4d5..504812d1c858a3bc71801df4016467bc6f4f822e 100644 --- a/src/mapleall/maple_me/include/me_option.h +++ b/src/mapleall/maple_me/include/me_option.h @@ -130,6 +130,9 @@ class MeOption : public MapleDriverOptionBase { static bool doLFTR; static std::string inlineFuncList; static bool meVerify; + static uint32 dseRunsLimit; + static uint32 hdseRunsLimit; + static uint32 hpropRunsLimit; #if MIR_JAVA static std::string acquireFuncName; static std::string releaseFuncName; diff --git a/src/mapleall/maple_me/src/lfo_iv_canon.cpp b/src/mapleall/maple_me/src/lfo_iv_canon.cpp index 2584cb6a896e804791c0da193feed1575c2df184..8a76b352af05927478d4da33b9127dcf7bfb771b 100644 --- a/src/mapleall/maple_me/src/lfo_iv_canon.cpp +++ b/src/mapleall/maple_me/src/lfo_iv_canon.cpp @@ -516,13 +516,13 @@ void IVCanon::PerformIVCanon() { } AnalysisResult *DoLfoIVCanon::Run(MeFunction *func, MeFuncResultMgr *m, ModuleResultMgr *) { - Dominance *dom = static_cast(m->GetAnalysisResult(MeFuncPhase_DOMINANCE, func)); + Dominance *dom = static_cast(m->GetAnalysisResult(MeFuncPhase_DOMINANCE, func, !MeOption::quiet)); ASSERT(dom != nullptr, "dominance phase has problem"); - MeIRMap *irmap = static_cast(m->GetAnalysisResult(MeFuncPhase_IRMAPBUILD, func)); + MeIRMap *irmap = static_cast(m->GetAnalysisResult(MeFuncPhase_IRMAPBUILD, func, !MeOption::quiet)); ASSERT(irmap != nullptr, "hssamap has problem"); - IdentifyLoops *identLoops = static_cast(m->GetAnalysisResult(MeFuncPhase_MELOOP, func)); + IdentifyLoops *identLoops = static_cast(m->GetAnalysisResult(MeFuncPhase_MELOOP, func, !MeOption::quiet)); CHECK_FATAL(identLoops != nullptr, "identloops has problem"); LfoFunction *lfoFunc = func->GetLfoFunc(); diff --git a/src/mapleall/maple_me/src/me_dse.cpp b/src/mapleall/maple_me/src/me_dse.cpp index d9f293fa5baa48c05ed10622dfee6e6dcf2846d6..327484c665fdcce35b873bbd5b80e455b5df4a70 100644 --- a/src/mapleall/maple_me/src/me_dse.cpp +++ b/src/mapleall/maple_me/src/me_dse.cpp @@ -63,15 +63,22 @@ void MeDSE::RunDSE() { AnalysisResult *MeDoDSE::Run(MeFunction *func, MeFuncResultMgr *m, ModuleResultMgr *mrm) { CHECK_NULL_FATAL(func); - auto *postDom = static_cast(m->GetAnalysisResult(MeFuncPhase_DOMINANCE, func)); - CHECK_NULL_FATAL(postDom); - auto *aliasClass = static_cast(m->GetAnalysisResult(MeFuncPhase_ALIASCLASS, func)); - MeDSE dse(*func, postDom, aliasClass, DEBUGFUNC(func)); - dse.RunDSE(); - func->Verify(); - // cfg change , invalid results in MeFuncResultMgr - if (dse.UpdatedCfg()) { - m->InvalidAnalysisResult(MeFuncPhase_DOMINANCE, func); + if (func->dseRuns >= MeOption::dseRunsLimit) { + if (!MeOption::quiet) { + LogInfo::MapleLogger() << " == " << PhaseName() << " skipped\n"; + } + } else { + func->dseRuns++; + auto *postDom = static_cast(m->GetAnalysisResult(MeFuncPhase_DOMINANCE, func)); + CHECK_NULL_FATAL(postDom); + auto *aliasClass = static_cast(m->GetAnalysisResult(MeFuncPhase_ALIASCLASS, func)); + MeDSE dse(*func, postDom, aliasClass, DEBUGFUNC(func)); + dse.RunDSE(); + func->Verify(); + // cfg change , invalid results in MeFuncResultMgr + if (dse.UpdatedCfg()) { + m->InvalidAnalysisResult(MeFuncPhase_DOMINANCE, func); + } } if (func->GetMIRModule().IsCModule() && MeOption::performFSAA) { diff --git a/src/mapleall/maple_me/src/me_hdse.cpp b/src/mapleall/maple_me/src/me_hdse.cpp index 995ad3fbd5e93419e1f1089d0347f78347d8d029..cd343b71ddca73758bde902f2b3ba1579989bf77 100644 --- a/src/mapleall/maple_me/src/me_hdse.cpp +++ b/src/mapleall/maple_me/src/me_hdse.cpp @@ -168,11 +168,18 @@ void MakeEmptyTrysUnreachable(MeFunction &func) { } AnalysisResult *MeDoHDSE::Run(MeFunction *func, MeFuncResultMgr *m, ModuleResultMgr*) { - auto *postDom = static_cast(m->GetAnalysisResult(MeFuncPhase_DOMINANCE, func)); + if (func->hdseRuns >= MeOption::hdseRunsLimit) { + if (!MeOption::quiet) { + LogInfo::MapleLogger() << " == " << PhaseName() << " skipped\n"; + } + return nullptr; + } + func->hdseRuns++; + auto *postDom = static_cast(m->GetAnalysisResult(MeFuncPhase_DOMINANCE, func, !MeOption::quiet)); CHECK_NULL_FATAL(postDom); - auto *aliasClass = static_cast(m->GetAnalysisResult(MeFuncPhase_ALIASCLASS, func)); + auto *aliasClass = static_cast(m->GetAnalysisResult(MeFuncPhase_ALIASCLASS, func, !MeOption::quiet)); CHECK_NULL_FATAL(aliasClass); - auto *hMap = static_cast(m->GetAnalysisResult(MeFuncPhase_IRMAPBUILD, func)); + auto *hMap = static_cast(m->GetAnalysisResult(MeFuncPhase_IRMAPBUILD, func, !MeOption::quiet)); CHECK_NULL_FATAL(hMap); MeHDSE hdse(*func, *postDom, *hMap, aliasClass, DEBUGFUNC(func)); diff --git a/src/mapleall/maple_me/src/me_irmap_build.cpp b/src/mapleall/maple_me/src/me_irmap_build.cpp index 25aed97994f1fe37bb157227648f05a98053db65..0b516fd77afb04422f57140e0a3d8fba067c707f 100644 --- a/src/mapleall/maple_me/src/me_irmap_build.cpp +++ b/src/mapleall/maple_me/src/me_irmap_build.cpp @@ -25,11 +25,11 @@ namespace maple { AnalysisResult *MeDoIRMapBuild::Run(MeFunction *func, MeFuncResultMgr *funcResMgr, ModuleResultMgr *moduleResMgr) { (void)moduleResMgr; // get all required analysis result IRMap need, cfg, ssa may be invalid in previous phase - (void)(funcResMgr->GetAnalysisResult(MeFuncPhase_MECFG, func)); - (void)(funcResMgr->GetAnalysisResult(MeFuncPhase_SSATAB, func)); - (void)(funcResMgr->GetAnalysisResult(MeFuncPhase_ALIASCLASS, func)); - (void)(funcResMgr->GetAnalysisResult(MeFuncPhase_SSA, func)); - Dominance *dom = static_cast(funcResMgr->GetAnalysisResult(MeFuncPhase_DOMINANCE, func)); + (void)(funcResMgr->GetAnalysisResult(MeFuncPhase_MECFG, func, !MeOption::quiet)); + (void)(funcResMgr->GetAnalysisResult(MeFuncPhase_SSATAB, func, !MeOption::quiet)); + (void)(funcResMgr->GetAnalysisResult(MeFuncPhase_ALIASCLASS, func, !MeOption::quiet)); + (void)(funcResMgr->GetAnalysisResult(MeFuncPhase_SSA, func, !MeOption::quiet)); + Dominance *dom = static_cast(funcResMgr->GetAnalysisResult(MeFuncPhase_DOMINANCE, func, !MeOption::quiet)); CHECK_FATAL(dom != nullptr, "dominance phase has problem"); MemPool *irmapmp = NewMemPool(); diff --git a/src/mapleall/maple_me/src/me_option.cpp b/src/mapleall/maple_me/src/me_option.cpp index 84f999b407e9a453a5b81282c70995feb03203ba..8ab096b80712bab6dfe3baab2981a8caeff36178 100644 --- a/src/mapleall/maple_me/src/me_option.cpp +++ b/src/mapleall/maple_me/src/me_option.cpp @@ -104,6 +104,9 @@ bool MeOption::srForAdd = false; bool MeOption::doLFTR = true; std::string MeOption::inlineFuncList = ""; bool MeOption::meVerify = false; +uint32 MeOption::dseRunsLimit = 2; // dse phase run at most 2 times each PU +uint32 MeOption::hdseRunsLimit = 3; // hdse phase run at most 3 times each PU +uint32 MeOption::hpropRunsLimit = 2; // hprop phase run at most 2 times each PU #if MIR_JAVA std::string MeOption::acquireFuncName = "Landroid/location/LocationManager;|requestLocationUpdates|"; std::string MeOption::releaseFuncName = "Landroid/location/LocationManager;|removeUpdates|"; @@ -217,6 +220,9 @@ enum OptionIndex { kMeThreads, kMeIgnoreInferredRetType, kMeVerify, + kDseRunsLimit, + kHdseRunsLimit, + kHpropRunsLimit, }; const Descriptor kUsage[] = { @@ -586,7 +592,7 @@ const Descriptor kUsage[] = { "copyproplimit", kBuildTypeExperimental, kArgCheckPolicyRequired, - " --copyproplimit \tApply Rename-to-Preg optimization only up to NUM times\n" + " --copyproplimit \tApply copy propagation only up to NUM times\n" " \t--copyproplimit=NUM\n", "me", {} }, @@ -1042,6 +1048,36 @@ const Descriptor kUsage[] = { " --meverify \tenable meverify features\n", "me", {}}, + { kDseRunsLimit, + 0, + "", + "dserunslimit", + kBuildTypeExperimental, + kArgCheckPolicyNumeric, + " --dserunslimit=n \tControl number of times dse phase can be run\n" + " \t--dserunslimit=NUM\n", + "me", + {} }, + { kHdseRunsLimit, + 0, + "", + "hdserunslimit", + kBuildTypeExperimental, + kArgCheckPolicyNumeric, + " --hdserunslimit=n \tControl number of times hdse phase can be run\n" + " \t--hdserunslimit=NUM\n", + "me", + {} }, + { kHpropRunsLimit, + 0, + "", + "hproprunslimit", + kBuildTypeExperimental, + kArgCheckPolicyNumeric, + " --hproprunslimit=n \tControl number of times hprop phase can be run\n" + " \t--hproprunslimit=NUM\n", + "me", + {} }, #if MIR_JAVA { kMeAcquireFunc, 0, @@ -1469,6 +1505,15 @@ bool MeOption::SolveOptions(const std::vector &opts, bool i case kMeVerify: meVerify = (opt.Type() == kEnable); break; + case kDseRunsLimit: + dseRunsLimit = std::stoul(opt.Args(), nullptr); + break; + case kHdseRunsLimit: + hdseRunsLimit = std::stoul(opt.Args(), nullptr); + break; + case kHpropRunsLimit: + hpropRunsLimit = std::stoul(opt.Args(), nullptr); + break; #if MIR_JAVA case kMeAcquireFunc: acquireFuncName = opt.Args(); diff --git a/src/mapleall/maple_me/src/me_prop.cpp b/src/mapleall/maple_me/src/me_prop.cpp index f251cc88bdcecec678e4f0363101b94d0888839f..78c49403469679926ca227f2c2c1f95ef25e48ef 100644 --- a/src/mapleall/maple_me/src/me_prop.cpp +++ b/src/mapleall/maple_me/src/me_prop.cpp @@ -34,6 +34,13 @@ const std::set propWhiteList { namespace maple { AnalysisResult *MeDoMeProp::Run(MeFunction *func, MeFuncResultMgr *m, ModuleResultMgr*) { CHECK_NULL_FATAL(func); + if (func->hpropRuns >= MeOption::hpropRunsLimit) { + if (!MeOption::quiet) { + LogInfo::MapleLogger() << " == " << PhaseName() << " skipped\n"; + } + return nullptr; + } + func->hpropRuns++; auto *dom = static_cast(m->GetAnalysisResult(MeFuncPhase_DOMINANCE, func, !MeOption::quiet)); CHECK_NULL_FATAL(dom); auto *hMap = static_cast(m->GetAnalysisResult(MeFuncPhase_IRMAPBUILD, func, !MeOption::quiet)); 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 a792a5583dc7c0780c30641a67bc6bd2fd580128..f5fb13b1af36521484d08124eef401a6615873fc 100644 --- a/src/mapleall/maple_me/src/me_value_range_prop.cpp +++ b/src/mapleall/maple_me/src/me_value_range_prop.cpp @@ -1272,12 +1272,12 @@ void ValueRangePropagation::DealWithCondGoto(BB &bb, MeStmt &stmt) { AnalysisResult *MeDoValueRangePropagation::Run(MeFunction *func, MeFuncResultMgr *frm, ModuleResultMgr*) { CHECK_FATAL(frm != nullptr, "frm is nullptr"); - auto *dom = static_cast(frm->GetAnalysisResult(MeFuncPhase_DOMINANCE, func)); + auto *dom = static_cast(frm->GetAnalysisResult(MeFuncPhase_DOMINANCE, func, !MeOption::quiet)); CHECK_FATAL(dom != nullptr, "dominance phase has problem"); - auto *irMap = static_cast(frm->GetAnalysisResult(MeFuncPhase_IRMAPBUILD, func)); + auto *irMap = static_cast(frm->GetAnalysisResult(MeFuncPhase_IRMAPBUILD, func, !MeOption::quiet)); CHECK_FATAL(irMap != nullptr, "irMap phase has problem"); frm->InvalidAnalysisResult(MeFuncPhase_MELOOP, func); - IdentifyLoops *meLoop = static_cast(frm->GetAnalysisResult(MeFuncPhase_MELOOP, func)); + IdentifyLoops *meLoop = static_cast(frm->GetAnalysisResult(MeFuncPhase_MELOOP, func, !MeOption::quiet)); if (ValueRangePropagation::isDebug) { LogInfo::MapleLogger() << func->GetName() << "\n"; func->Dump(false);