diff --git a/src/mapleall/maple_me/include/me_option.h b/src/mapleall/maple_me/include/me_option.h index 736c9792b0977a713fb3ee1a21f7e5ea5b4c5c61..a711e16cee6fd5660d59c1ca308a28f140b33671 100644 --- a/src/mapleall/maple_me/include/me_option.h +++ b/src/mapleall/maple_me/include/me_option.h @@ -84,6 +84,7 @@ class MeOption : public MapleDriverOptionBase { static uint32 threads; static bool ignoreInferredRetType; static uint32 pregRenameLimit; + static uint32 rename2pregLimit; static uint32 delRcPULimit; static uint32 profileBBHotRate; static uint32 profileBBColdRate; diff --git a/src/mapleall/maple_me/include/me_rename2preg.h b/src/mapleall/maple_me/include/me_rename2preg.h index d4859c40040978240fc698f90287a5d80a993da8..bab487a25ae08cb028babd53777ad62333a731fa 100644 --- a/src/mapleall/maple_me/include/me_rename2preg.h +++ b/src/mapleall/maple_me/include/me_rename2preg.h @@ -69,6 +69,8 @@ class SSARename2Preg { MapleVector parm_used_vec; // if parameter is not used, it's false, otherwise true // if the parameter got promoted, the nth of func->mirFunc->_formal is the nth of reg_formal_vec, otherwise nullptr; MapleVector reg_formal_vec; + public: + uint32 rename2pregCount = 0; }; class MeDoSSARename2Preg : public MeFuncPhase { diff --git a/src/mapleall/maple_me/src/hdse.cpp b/src/mapleall/maple_me/src/hdse.cpp index 496220c494ec7ac0065ad5eb1c452dc302e35a80..77eb53cbe371f6288aef615f67c6938259986dc2 100644 --- a/src/mapleall/maple_me/src/hdse.cpp +++ b/src/mapleall/maple_me/src/hdse.cpp @@ -440,6 +440,7 @@ void HDSE::MarkSingleUseLive(MeExpr &meExpr) { auto *base = static_cast(meExpr).GetBase(); MarkSingleUseLive(*base); VarMeExpr *mu = static_cast(meExpr).GetMu(); + workList.push_front(mu); if (mu->GetDefBy() != kDefByNo) { MapleMap *chiList = GenericGetChiListFromVarMeExpr(*mu); if (chiList != nullptr) { diff --git a/src/mapleall/maple_me/src/me_option.cpp b/src/mapleall/maple_me/src/me_option.cpp index 2d2459e9f92c69fed8abd3e07bd8b0f2d6944bb9..d96728e7a707da93ec04d9a3f3c69ecdac991395 100644 --- a/src/mapleall/maple_me/src/me_option.cpp +++ b/src/mapleall/maple_me/src/me_option.cpp @@ -53,6 +53,7 @@ uint32 MeOption::eprePULimit = UINT32_MAX; uint32 MeOption::lpreLimit = UINT32_MAX; uint32 MeOption::lprePULimit = UINT32_MAX; uint32 MeOption::pregRenameLimit = UINT32_MAX; +uint32 MeOption::rename2pregLimit = UINT32_MAX; uint32 MeOption::profileBBHotRate = 10; uint32 MeOption::profileBBColdRate = 99; bool MeOption::noDelegateRC = false; @@ -148,6 +149,7 @@ enum OptionIndex { kLpreLimit, kLprepulLimit, kPregreNameLimit, + kRename2pregLimit, kDelrcpuLimit, kProfileBBHotRate, kProfileBBColdRate, @@ -535,6 +537,16 @@ const Descriptor kUsage[] = { " \t--pregrenamelimit=NUM\n", "me", {} }, + { kRename2pregLimit, + 0, + "", + "rename2preglimit", + kBuildTypeExperimental, + kArgCheckPolicyRequired, + " --rename2preglimit \tApply Rename-to-Preg optimization only up to NUM times\n" + " \t--rename2preglimit=NUM\n", + "me", + {} }, { kDelrcpuLimit, 0, "", @@ -1188,6 +1200,9 @@ bool MeOption::SolveOptions(const std::vector &opts, bool i case kPregreNameLimit: pregRenameLimit = std::stoul(opt.Args(), nullptr); break; + case kRename2pregLimit: + rename2pregLimit = std::stoul(opt.Args(), nullptr); + break; case kDelrcpuLimit: delRcPULimit = std::stoul(opt.Args(), nullptr); break; diff --git a/src/mapleall/maple_me/src/me_rename2preg.cpp b/src/mapleall/maple_me/src/me_rename2preg.cpp index 4bcf7bb3b98310bf117b91a2cc17812c6491e703..36412f4c86622969fc54bfb7c5968cc69eea0b29 100644 --- a/src/mapleall/maple_me/src/me_rename2preg.cpp +++ b/src/mapleall/maple_me/src/me_rename2preg.cpp @@ -16,6 +16,7 @@ #include "me_rename2preg.h" #include "mir_builder.h" #include "me_irmap.h" +#include "me_option.h" // This phase mainly renames the variables to pseudo register. // Only non-ref-type variables (including parameters) with no alias are @@ -74,6 +75,9 @@ RegMeExpr *SSARename2Preg::RenameVar(const VarMeExpr *varmeexpr) { if (ty->GetKind() != kTypeScalar && ty->GetKind() != kTypePointer) { return nullptr; } + if (rename2pregCount >= MeOption::rename2pregLimit) { + return nullptr; + } curtemp = meirmap->CreateRegMeExpr(*ty); OriginalSt *pregOst = ssaTab->GetOriginalStTable().CreatePregOriginalSt(curtemp->GetRegIdx(), func->GetMirFunc()->GetPuidx()); @@ -87,11 +91,12 @@ RegMeExpr *SSARename2Preg::RenameVar(const VarMeExpr *varmeexpr) { reg_formal_vec[parmindex] = curtemp; } } + rename2pregCount++; if (DEBUGFUNC(func)) { ost->Dump(); LogInfo::MapleLogger() << "(ost idx " << ost->GetIndex() << ") renamed to "; pregOst->Dump(); - LogInfo::MapleLogger() << std::endl; + LogInfo::MapleLogger() << " (count: " << rename2pregCount << ")" << std::endl; } return curtemp; }