diff --git a/src/mapleall/maple_driver/include/option_parser.h b/src/mapleall/maple_driver/include/option_parser.h index c76ee4edc80bbc53cdaa259df1fb53291717371d..42782f63b7d49fda9d4a5c8fb00cbf4565c57d0a 100644 --- a/src/mapleall/maple_driver/include/option_parser.h +++ b/src/mapleall/maple_driver/include/option_parser.h @@ -82,7 +82,8 @@ enum Level { kLevelZero = 0, kLevelOne = 1, kLevelTwo = 2, - kLevelThree = 3 + kLevelThree = 3, + kLevelFour = 4 }; } // namespace mapleOption #endif // MAPLE_UTIL_INCLUDE_OPTION_PARSER_H diff --git a/src/mapleall/maple_me/include/me_option.h b/src/mapleall/maple_me/include/me_option.h index bf0c3d75ac6065c41cddc8a99ef90d7887ca2261..762a5d9c11c59b73edeebd00ecb230db100b53e3 100644 --- a/src/mapleall/maple_me/include/me_option.h +++ b/src/mapleall/maple_me/include/me_option.h @@ -169,6 +169,7 @@ class MeOption : public MapleDriverOptionBase { static uint32 hpropRunsLimit; static bool loopVec; static bool seqVec; + static uint8 rematLevel; #if MIR_JAVA static std::string acquireFuncName; static std::string releaseFuncName; diff --git a/src/mapleall/maple_me/src/me_option.cpp b/src/mapleall/maple_me/src/me_option.cpp index abcdce417b77c3c0117fa6866574694dec2b8f3b..51babf3488afc1b090295bfdc13a1b8ed2c817ee 100644 --- a/src/mapleall/maple_me/src/me_option.cpp +++ b/src/mapleall/maple_me/src/me_option.cpp @@ -113,6 +113,7 @@ 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 bool MeOption::loopVec = true; bool MeOption::seqVec = true; +uint8 MeOption::rematLevel = 2; #if MIR_JAVA std::string MeOption::acquireFuncName = "Landroid/location/LocationManager;|requestLocationUpdates|"; std::string MeOption::releaseFuncName = "Landroid/location/LocationManager;|removeUpdates|"; @@ -236,6 +237,7 @@ enum OptionIndex { kHpropRunsLimit, kLoopVec, kSeqVec, + kRematLevel, }; const Descriptor kUsage[] = { @@ -1199,6 +1201,20 @@ const Descriptor kUsage[] = { " --warning=level \t--warning=level\n", "me", {} }, + { kRematLevel, + 0, + "", + "remat", + kBuildTypeExperimental, + kArgCheckPolicyRequired, + " --remat \tEnable rematerialization during register allocation\n" + " \t 0: no rematerialization (default)\n" + " \t >= 1: rematerialize constants\n" + " \t >= 2: rematerialize addresses\n" + " \t >= 3: rematerialize local dreads\n" + " \t >= 4: rematerialize global dreads\n", + "me", + {} }, #endif { kUnknown, 0, @@ -1592,6 +1608,9 @@ bool MeOption::SolveOptions(const std::vector &opts, bool i case kSeqVec: seqVec = (opt.Type() == kEnable); break; + case kRematLevel: + rematLevel = std::stoul(opt.Args(), nullptr); + break; #if MIR_JAVA case kMeAcquireFunc: acquireFuncName = opt.Args(); diff --git a/src/mapleall/maple_me/src/me_ssa_lpre.cpp b/src/mapleall/maple_me/src/me_ssa_lpre.cpp index d5f80859e60b4e8d3bb896de8974d244184079c5..c8adc6a91acfb990bffd72df7871323de9628417 100644 --- a/src/mapleall/maple_me/src/me_ssa_lpre.cpp +++ b/src/mapleall/maple_me/src/me_ssa_lpre.cpp @@ -350,10 +350,12 @@ void MeSSALPre::BuildWorkListExpr(MeStmt &meStmt, int32 seqStmt, MeExpr &meExpr, if (!MeOption::lpre4Address) { break; } - auto *addrOfMeExpr = static_cast(&meExpr); - const OriginalSt *ost = ssaTab->GetOriginalStFromID(addrOfMeExpr->GetOstIdx()); - if (ost->IsLocal()) { // skip lpre for stack addresses as they are cheap and need keep for rc - break; + if (MeOption::rematLevel < mapleOption::kLevelTwo) { + auto *addrOfMeExpr = static_cast(&meExpr); + const OriginalSt *ost = ssaTab->GetOriginalStFromID(addrOfMeExpr->GetOstIdx()); + if (ost->IsLocal()) { // skip lpre for stack addresses as they are cheap and need keep for rc + break; + } } (void)CreateRealOcc(meStmt, seqStmt, meExpr, false); break;