From 9fb7571e8e9de9af7f3dce6d0fc270cdc7b29e38 Mon Sep 17 00:00:00 2001 From: Fred Chow Date: Wed, 28 Jul 2021 19:16:05 -0700 Subject: [PATCH] Added me options -dserunslimit -hdserunslimit -hproprunslimit t0 help triage -O3 problems --- src/mapleall/maple_me/include/bb.h | 1 - src/mapleall/maple_me/include/me_function.h | 4 ++ src/mapleall/maple_me/include/me_option.h | 3 ++ src/mapleall/maple_me/src/lfo_iv_canon.cpp | 6 +-- src/mapleall/maple_me/src/me_dse.cpp | 25 ++++++---- src/mapleall/maple_me/src/me_hdse.cpp | 13 +++-- src/mapleall/maple_me/src/me_irmap_build.cpp | 10 ++-- src/mapleall/maple_me/src/me_option.cpp | 47 ++++++++++++++++++- src/mapleall/maple_me/src/me_prop.cpp | 7 +++ .../maple_me/src/me_value_range_prop.cpp | 6 +-- 10 files changed, 97 insertions(+), 25 deletions(-) diff --git a/src/mapleall/maple_me/include/bb.h b/src/mapleall/maple_me/include/bb.h index 4c1f38b4a1..7f9104c475 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 4f00c31927..27b753a5a2 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 7ae67045d6..504812d1c8 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 2584cb6a89..8a76b352af 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 d9f293fa5b..327484c665 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 995ad3fbd5..cd343b71dd 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 25aed97994..0b516fd77a 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 84f999b407..8ab096b807 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 f251cc88bd..78c4940346 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 a792a5583d..f5fb13b1af 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); -- Gitee