diff --git a/src/mapleall/maple_me/include/me_store_pre.h b/src/mapleall/maple_me/include/me_store_pre.h index 783e4e6d9449ef7e408bf9376aa7bff20a133186..f5884ad9c87a82e97dcfba0df4b56d0fa8142154 100644 --- a/src/mapleall/maple_me/include/me_store_pre.h +++ b/src/mapleall/maple_me/include/me_store_pre.h @@ -22,10 +22,15 @@ class MeStorePre : public MeSSUPre { public: MeStorePre(MeFunction &f, Dominance &dom, AliasClass &ac, MemPool &memPool, bool enabledDebug) : MeSSUPre(f, dom, memPool, kStorePre, enabledDebug), aliasClass(&ac), curTemp(nullptr), - bbCurTempMap(spreAllocator.Adapter()) {} + bbCurTempMap(spreAllocator.Adapter()), + candsForSSAUpdate(spreAllocator.Adapter()) {} virtual ~MeStorePre() = default; + MapleMap *> &CandsForSSAUpdate() { + return candsForSSAUpdate; + } + private: inline bool IsJavaLang() const { return mirModule->IsJavaModule(); @@ -46,10 +51,18 @@ class MeStorePre : public MeSSUPre { bbCurTempMap.clear(); } + void AddCandsForSSAUpdate(OStIdx ostIdx, BBId bbId) { + if (candsForSSAUpdate[ostIdx] == nullptr) { + candsForSSAUpdate[ostIdx] = spreMp->New>(spreAllocator.Adapter()); + } + candsForSSAUpdate[ostIdx]->insert(bbId); + } + AliasClass *aliasClass; // step 6 code motion RegMeExpr *curTemp; // the preg for the RHS of inserted stores MapleUnorderedMap bbCurTempMap; // map bb to curTemp version + MapleMap *> candsForSSAUpdate; }; class MeDoStorePre : public MeFuncPhase { diff --git a/src/mapleall/maple_me/src/me_store_pre.cpp b/src/mapleall/maple_me/src/me_store_pre.cpp index 81e8fa6a6981e1a670c0965c5f20bc3d94a7dd2e..88448565e8614ccf460c8f63cba9dc6d6f602db5 100644 --- a/src/mapleall/maple_me/src/me_store_pre.cpp +++ b/src/mapleall/maple_me/src/me_store_pre.cpp @@ -13,6 +13,7 @@ * See the Mulan PSL v2 for more details. */ #include "me_store_pre.h" +#include "me_ssa_update.h" namespace maple { // ================ Step 6: Code Motion ================ @@ -159,6 +160,7 @@ void MeStorePre::CodeMotion() { } else { insertBB->InsertMeStmtBefore(curStmt, newDass); } + AddCandsForSSAUpdate(lhsVar->GetOstIdx(), insertBB->GetBBId()); } } // pass 2 only doing deletion @@ -375,6 +377,12 @@ AnalysisResult *MeDoStorePre::Run(MeFunction *func, MeFuncResultMgr *m, ModuleRe } MeStorePre storePre(*func, *dom, *aliasClass, *NewMemPool(), DEBUGFUNC(func)); storePre.ApplySSUPre(); + auto &candsForSSAUpdate = storePre.CandsForSSAUpdate(); + if (!candsForSSAUpdate.empty()) { + MemPool *mp = NewMemPool(); + MeSSAUpdate ssaUpdator(*func, *func->GetMeSSATab(), *dom, candsForSSAUpdate, *mp); + ssaUpdator.Run(); + } if (DEBUGFUNC(func)) { func->Dump(false); }