From 32d26a8abef0a5324a09d1e68ba3e43534450434 Mon Sep 17 00:00:00 2001 From: Fred Chow Date: Tue, 29 Jun 2021 12:30:54 -0700 Subject: [PATCH] When addrof is under a cvt in an actual parameter, treat it as if the address is being passed directly In rename2preg, do not promote if a symbol is marked address-taken. --- src/mapleall/maple_me/src/alias_class.cpp | 9 ++++++++- src/mapleall/maple_me/src/me_emit.cpp | 5 +++-- src/mapleall/maple_me/src/me_rename2preg.cpp | 3 +++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/mapleall/maple_me/src/alias_class.cpp b/src/mapleall/maple_me/src/alias_class.cpp index dffbafc1f1..ab5fa2b9b2 100644 --- a/src/mapleall/maple_me/src/alias_class.cpp +++ b/src/mapleall/maple_me/src/alias_class.cpp @@ -579,6 +579,9 @@ void AliasClass::SetPtrOpndNextLevNADS(const BaseNode &opnd, AliasElem *aliasEle !(opnd.GetOpCode() == OP_addrof && IsReadOnlyOst(aliasElem->GetOriginalSt()))) { aliasElem->SetNextLevNotAllDefsSeen(true); } + if (opnd.GetOpCode() == OP_cvt) { + SetPtrOpndNextLevNADS(*opnd.Opnd(0), aliasElem, hasNoPrivateDefEffect); + } } // Set aliasElem of the pointer-type opnds of a call as next_level_not_all_defines_seen @@ -1804,7 +1807,11 @@ void AliasClass::CollectMayUseForCallOpnd(const StmtNode &stmt, std::setGetPrimType(), &mirModule)) { - continue; + if (expr->GetOpCode() != OP_cvt) { + continue; + } else if (!IsPotentialAddress(static_cast(expr)->FromType(), &mirModule)) { + continue; + } } AliasInfo aInfo = CreateAliasElemsExpr(*expr); diff --git a/src/mapleall/maple_me/src/me_emit.cpp b/src/mapleall/maple_me/src/me_emit.cpp index f1f4a51483..2bea5377a9 100644 --- a/src/mapleall/maple_me/src/me_emit.cpp +++ b/src/mapleall/maple_me/src/me_emit.cpp @@ -53,8 +53,9 @@ AnalysisResult *MeDoEmit::Run(MeFunction *func, MeFuncResultMgr *m, ModuleResult // emit from mir function body func->EmitBeforeHSSA((*(func->GetMirFunc())), func->GetLaidOutBBs()); } - if (!DEBUGFUNC(func)) { - // constantfolding does not update BB's stmtNodeList, which breaks MirCFG::DumpToFile() + if (!DEBUGFUNC(func) && func->GetIRMap()) { + // constantfolding does not update BB's stmtNodeList, which breaks MirCFG::DumpToFile(); + // constantfolding also cannot work on SSANode's ConstantFold cf(func->GetMIRModule()); cf.Simplify(func->GetMirFunc()->GetBody()); } diff --git a/src/mapleall/maple_me/src/me_rename2preg.cpp b/src/mapleall/maple_me/src/me_rename2preg.cpp index 7cbfa34344..d8cace24e1 100644 --- a/src/mapleall/maple_me/src/me_rename2preg.cpp +++ b/src/mapleall/maple_me/src/me_rename2preg.cpp @@ -88,6 +88,9 @@ RegMeExpr *SSARename2Preg::RenameVar(const VarMeExpr *varmeexpr) { if (!mirst->IsLocal() || mirst->GetStorageClass() == kScPstatic || mirst->GetStorageClass() == kScFstatic) { return nullptr; } + if (ost->IsAddressTaken()) { + return nullptr; + } RegMeExpr *curtemp = nullptr; MIRType *ty = GlobalTables::GetTypeTable().GetTypeFromTyIdx(ost->GetTyIdx()); -- Gitee