From 0542b3e2e3cc045589de706a3219c4ca64da962f Mon Sep 17 00:00:00 2001 From: "@evian_hill" Date: Tue, 20 Jul 2021 16:10:57 +0800 Subject: [PATCH 1/2] update ssa after storepre --- src/mapleall/maple_me/include/me_store_pre.h | 15 ++++++++++++++- src/mapleall/maple_me/src/me_store_pre.cpp | 8 ++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/mapleall/maple_me/include/me_store_pre.h b/src/mapleall/maple_me/include/me_store_pre.h index 783e4e6d94..8ed4bfa962 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; + const MapleMap *> &CandsForSSAUpdate() const { + 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 81e8fa6a69..88448565e8 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); } -- Gitee From a27c8e46c8c845a698fdadbe4b56a3af82cb8a43 Mon Sep 17 00:00:00 2001 From: "@evian_hill" Date: Tue, 20 Jul 2021 16:10:57 +0800 Subject: [PATCH 2/2] update ssa after storepre --- src/mapleall/maple_me/include/me_store_pre.h | 15 ++++++++++++++- src/mapleall/maple_me/src/me_store_pre.cpp | 8 ++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/mapleall/maple_me/include/me_store_pre.h b/src/mapleall/maple_me/include/me_store_pre.h index 783e4e6d94..f5884ad9c8 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 81e8fa6a69..88448565e8 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); } -- Gitee