diff --git a/src/bin/jbc2mpl b/src/bin/jbc2mpl index cb8383274363bb38961c5bdfe264c1c3efeb3e44..645946380534ef3a3be7e099bf1858066df552a5 100755 Binary files a/src/bin/jbc2mpl and b/src/bin/jbc2mpl differ diff --git a/src/bin/maple b/src/bin/maple index 5f52c5e53e589b5fde42fee0a60b10501dd23ee2..a51e7ca5fd023f18b588e6bc1f37fc25554bbb4d 100755 Binary files a/src/bin/maple and b/src/bin/maple differ diff --git a/src/maple_me/include/hdse.h b/src/maple_me/include/hdse.h index 59bbf7b7c81523849b44a5d1f8997a585d0ae6f0..e24897a15a1ec73d25bdb6dbcbe668ed8df633f4 100644 --- a/src/maple_me/include/hdse.h +++ b/src/maple_me/include/hdse.h @@ -53,14 +53,14 @@ class HDSE { void MarkMuListRequired(MapleMap &); void MarkChiNodeRequired(ChiMeNode &chiNode); bool ExprNonDeletable(MeExpr &expr); - bool StmtMustRequired(const MeStmt &stmt, BB &bb); + bool StmtMustRequired(const MeStmt &stmt, const BB &bb); void MarkStmtRequired(MeStmt &stmt); bool HasNonDeletableExpr(const MeStmt &stmt); void MarkStmtUseLive(MeStmt &meStmt); void MarkSingleUseLive(MeExpr &meExpr); void MarkControlDependenceLive(BB &bb); void MarkLastBranchStmtInBBRequired(BB &bb); - void MarkLastStmtInPDomBBRequired(BB &bb); + void MarkLastStmtInPDomBBRequired(const BB &bb); void MarkLastUnconditionalGotoInPredBBRequired(BB &bb); void MarkVarDefByStmt(VarMeExpr &varMeExpr); void MarkRegDefByStmt(RegMeExpr ®MeExpr); diff --git a/src/maple_me/include/me_cond_based.h b/src/maple_me/include/me_cond_based.h index 614cead1d7a19985d90850affbc882c96eb34d71..e78903c8d1840b2e55fffbbb0f9cdc371a1035b9 100644 --- a/src/maple_me/include/me_cond_based.h +++ b/src/maple_me/include/me_cond_based.h @@ -33,9 +33,9 @@ class MeCondBased { } private: - bool NullValueFromOneTestCond(VarMeExpr&, BB&, BB&, bool); - bool PointerWasDereferencedBefore(VarMeExpr&, UnaryMeStmt&, BB*); - bool PointerWasDereferencedRightAfter(VarMeExpr&, UnaryMeStmt&); + bool NullValueFromOneTestCond(const VarMeExpr&, BB&, BB&, bool); + bool PointerWasDereferencedBefore(VarMeExpr&, const UnaryMeStmt&, BB*); + bool PointerWasDereferencedRightAfter(VarMeExpr&, const UnaryMeStmt&); bool IsIreadWithTheBase(VarMeExpr&, MeExpr&); bool StmtHasDereferencedBase(MeStmt&, VarMeExpr&); diff --git a/src/maple_me/include/me_inequality_graph.h b/src/maple_me/include/me_inequality_graph.h index e10d129d82e562eeeee8180da1d25f36a880e3df..6a4903a154ff8a166011d4fd002400935d1efb8c 100644 --- a/src/maple_me/include/me_inequality_graph.h +++ b/src/maple_me/include/me_inequality_graph.h @@ -1,5 +1,5 @@ /* - * Copyright (c) [2019] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2020] Huawei Technologies Co.,Ltd.All rights reserved. * * OpenArkCompiler is licensed under the Mulan PSL v1. * You can use this software according to the terms and conditions of the Mulan PSL v1. @@ -173,17 +173,7 @@ class ESSABaseNode { } }; ESSABaseNode(int i, MeExpr *expr, ESSANodeKind k) : id(i), meExpr(expr), kind(k) {} - virtual ~ESSABaseNode() { - // delete edges - for (auto iter = inWithConstEdge.begin(); iter != inWithConstEdge.end(); ++iter) { - delete iter->second; - iter->second = nullptr; - } - for (auto iter = inWithVarEdge.begin(); iter != inWithVarEdge.end(); ++iter) { - delete iter->second; - iter->second = nullptr; - } - } + virtual ~ESSABaseNode() = default; virtual const MeExpr &GetMeExpr() const { return *meExpr; @@ -225,6 +215,10 @@ class ESSABaseNode { inWithVarEdge.insert(std::pair(&node, &e)); } + virtual void InsertEdges(std::unique_ptr e) { + edges.push_back(std::move(e)); + } + virtual std::string GetExprID() const { CHECK_FATAL(meExpr != nullptr, "must be"); return std::to_string(meExpr->GetExprID()); @@ -238,6 +232,7 @@ class ESSABaseNode { int id; MeExpr *meExpr; ESSANodeKind kind; + std::vector> edges; std::multimap outWithConstEdge; std::multimap outWithVarEdge; std::multimap inWithConstEdge; @@ -276,12 +271,7 @@ class ESSAArrayNode : public ESSABaseNode { class ESSAPhiNode : public ESSABaseNode { public: explicit ESSAPhiNode(int i, MeExpr &e) : ESSABaseNode(i, &e, kPhiNode) {} - ~ESSAPhiNode() { - for (auto pair : inPhiNodes) { - delete pair.second; - pair.second = nullptr; - } - } + ~ESSAPhiNode() = default; const std::vector &GetPhiOpnds() const { return phiOpnds; @@ -316,21 +306,9 @@ class InequalityGraph { public: explicit InequalityGraph(MeFunction &func) : meFunction(&func) { nodeCount = 0; - ESSAConstNode *node = new ESSAConstNode(GetValidID(), 0); - constNodes[0] = node; - } - ~InequalityGraph() { - // delete nodes - for (auto iter = varNodes.begin(); iter != varNodes.end(); ++iter) { - delete iter->second; - iter->second = nullptr; - } - - for (auto iter = constNodes.begin(); iter != constNodes.end(); ++iter) { - delete iter->second; - iter->second = nullptr; - } + constNodes[0] = std::make_unique(GetValidID(), 0); } + ~InequalityGraph() = default; ESSAConstNode *GetOrCreateConstNode(int value); ESSAVarNode *GetOrCreateVarNode(MeExpr &meExpr); @@ -354,13 +332,14 @@ class InequalityGraph { InequalEdge *HasEdge(ESSABaseNode &from, ESSABaseNode &to, InequalEdge &type) const; std::string GetName(ESSABaseNode &node, IRMap &irMap) const; std::string GetName(const MeExpr &meExpr, IRMap &irMap) const; - void DumpDotNodes(IRMap &irMap, std::ostream &out, DumpType dumpType, std::map nodes) const; + void DumpDotNodes(IRMap &irMap, std::ostream &out, DumpType dumpType, + const std::map> &nodes) const; void DumpDotEdges(IRMap &irMap, const std::pair &map, std::ostream &out, std::string &from) const; MeFunction *meFunction; - std::map varNodes; - std::map constNodes; + std::map> varNodes; + std::map> constNodes; int nodeCount; }; diff --git a/src/maple_me/src/hdse.cpp b/src/maple_me/src/hdse.cpp index fa1a9e197b88ba326ba74ecea4d0abb7a6e3164e..27736486c0d91fdd26cf0536c353da11dd1af082 100644 --- a/src/maple_me/src/hdse.cpp +++ b/src/maple_me/src/hdse.cpp @@ -259,7 +259,7 @@ void HDSE::MarkLastUnconditionalGotoInPredBBRequired(BB &bb) { } } -void HDSE::MarkLastStmtInPDomBBRequired(BB &bb) { +void HDSE::MarkLastStmtInPDomBBRequired(const BB &bb) { CHECK(bb.GetBBId() < postDom.GetPdomFrontierSize(), "index out of range in HDSE::MarkLastStmtInPDomBBRequired"); for (BBId cdBBId : postDom.GetPdomFrontierItem(bb.GetBBId())) { BB *cdBB = bbVec[cdBBId]; @@ -364,7 +364,7 @@ void HDSE::MarkStmtRequired(MeStmt &meStmt) { MarkControlDependenceLive(*meStmt.GetBB()); } -bool HDSE::StmtMustRequired(const MeStmt &meStmt, BB &bb) { +bool HDSE::StmtMustRequired(const MeStmt &meStmt, const BB &bb) { Opcode op = meStmt.GetOp(); // special opcode cannot be eliminated if (IsStmtMustRequire(op) || op == OP_comment) { diff --git a/src/maple_me/src/me_abco.cpp b/src/maple_me/src/me_abco.cpp index e075aafdb9b184d42ae4b39baccf1562245a26f5..c249437d0e4b9d0fd995c43a487d1adbd26ce10e 100644 --- a/src/maple_me/src/me_abco.cpp +++ b/src/maple_me/src/me_abco.cpp @@ -13,6 +13,10 @@ * See the Mulan PSL v1 for more details. */ #include "me_abco.h" + +// This phase removes redundant array bounds checks. +// ABCD: Eliminating Array Bounds Checks on Demand. +// Rastislav Bodik, Rajiv Gupta, Vivek Sarkar. namespace maple { bool MeABC::kDebug = false; constexpr int kNumOpnds = 2; diff --git a/src/maple_me/src/me_cfg.cpp b/src/maple_me/src/me_cfg.cpp index 751461fd8735ba7ea8ec00493d75e2b0f2029773..7acdcc3141db5a0cce1830305c3eb7853ee20081 100644 --- a/src/maple_me/src/me_cfg.cpp +++ b/src/maple_me/src/me_cfg.cpp @@ -575,6 +575,9 @@ void MeCFG::ConvertMeregphiList2IdentityAssigns(BB &meBB) const { // used only after DSE because it looks at live field of VersionSt void MeCFG::ConvertPhis2IdentityAssigns(BB &meBB) const { + if (meBB.IsEmpty()) { + return; + } ConvertPhiList2IdentityAssigns(meBB); ConvertMevarPhiList2IdentityAssigns(meBB); ConvertMeregphiList2IdentityAssigns(meBB); diff --git a/src/maple_me/src/me_cond_based_opt.cpp b/src/maple_me/src/me_cond_based_opt.cpp index 69342e23bce8c651ef485bd9a52aff8e7ae7368e..90204d006acf9729bd2b6722542f1118fa8abdd1 100644 --- a/src/maple_me/src/me_cond_based_opt.cpp +++ b/src/maple_me/src/me_cond_based_opt.cpp @@ -36,7 +36,7 @@ namespace maple { // check if varmeexpr is under the condition varmeexpr == 0 when expectedEq0 is true, // or varmeexpr != 0 if expectedEq0 is false -bool MeCondBased::NullValueFromOneTestCond(VarMeExpr &varMeExpr, BB &cdBB, BB &bb, bool expectedEq0) { +bool MeCondBased::NullValueFromOneTestCond(const VarMeExpr &varMeExpr, BB &cdBB, BB &bb, bool expectedEq0) { auto &meStmts = cdBB.GetMeStmts(); if (meStmts.empty()) { return false; @@ -140,7 +140,7 @@ bool MeCondBased::StmtHasDereferencedBase(MeStmt &stmt, VarMeExpr &var) { return false; } -bool MeCondBased::PointerWasDereferencedBefore(VarMeExpr &var, UnaryMeStmt &assertMeStmt, BB *bb) { +bool MeCondBased::PointerWasDereferencedBefore(VarMeExpr &var, const UnaryMeStmt &assertMeStmt, BB *bb) { // If var is defined in the function, let BBx be the BB that defines var. // If var is not defined, then let BBx be the function entry BB. // Let BBy be the current BB that contains the assertnonnull. @@ -180,7 +180,7 @@ bool MeCondBased::PointerWasDereferencedBefore(VarMeExpr &var, UnaryMeStmt &asse return false; } -bool MeCondBased::PointerWasDereferencedRightAfter(VarMeExpr &var, UnaryMeStmt &assertMeStmt) { +bool MeCondBased::PointerWasDereferencedRightAfter(VarMeExpr &var, const UnaryMeStmt &assertMeStmt) { // assertnonnull(var) // t = iread(var, 0) // we can safely delete assertnonnull(var) diff --git a/src/maple_me/src/me_inequality_graph.cpp b/src/maple_me/src/me_inequality_graph.cpp index ce64b20ec6a8e4617528d178af6caf2d937c89ae..5eea6597c15a86cbb64748a2ea75f1dff9b73995 100644 --- a/src/maple_me/src/me_inequality_graph.cpp +++ b/src/maple_me/src/me_inequality_graph.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) [2019] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2020] Huawei Technologies Co.,Ltd.All rights reserved. * * OpenArkCompiler is licensed under the Mulan PSL v1. * You can use this software according to the terms and conditions of the Mulan PSL v1. @@ -17,36 +17,39 @@ namespace maple { ESSAConstNode *InequalityGraph::GetOrCreateConstNode(int value) { if (HasNode(value)) { - return static_cast(constNodes[value]); + return static_cast(constNodes[value].get()); } - ESSAConstNode *newConstNode = new ESSAConstNode(GetValidID(), value); + std::unique_ptr newConstNode = std::make_unique(GetValidID(), value); CHECK_FATAL(newConstNode != nullptr, "new failed"); - constNodes[value] = newConstNode; - return newConstNode; + ESSAConstNode *newConst = newConstNode.get(); + constNodes[value] = std::move(newConstNode); + return newConst; } ESSAVarNode *InequalityGraph::GetOrCreateVarNode(MeExpr &meExpr) { if (HasNode(meExpr)) { - return static_cast(varNodes[meExpr.GetExprID()]); + return static_cast(varNodes[meExpr.GetExprID()].get()); } CHECK_FATAL(meExpr.GetMeOp() == kMeOpVar || meExpr.GetMeOp() == kMeOpIvar, "meExpr must be VarMeExpr"); - ESSAVarNode *newVarNode = new ESSAVarNode(GetValidID(), meExpr); + std::unique_ptr newVarNode = std::make_unique(GetValidID(), meExpr); CHECK_FATAL(newVarNode != nullptr, "new failed"); - varNodes[meExpr.GetExprID()] = newVarNode; - return newVarNode; + ESSAVarNode *newVar = newVarNode.get(); + varNodes[meExpr.GetExprID()] = std::move(newVarNode); + return newVar; } ESSAPhiNode *InequalityGraph::GetOrCreatePhiNode(MeVarPhiNode &phiNode) { MeExpr *expr = phiNode.GetLHS(); CHECK_FATAL(expr != nullptr, "meExpr phiNode must has lhs"); if (HasNode(*expr)) { - return static_cast(varNodes[expr->GetExprID()]); + return static_cast(varNodes[expr->GetExprID()].get()); } CHECK_FATAL(expr->GetMeOp() == kMeOpVar, "meExpr must be VarMeExpr"); - ESSAPhiNode *newPhiNode = new ESSAPhiNode(GetValidID(), *expr); + std::unique_ptr newPhiNode = std::make_unique(GetValidID(), *expr); CHECK_FATAL(newPhiNode != nullptr, "new failed"); newPhiNode->SetPhiOpnds(phiNode.GetOpnds()); - varNodes[expr->GetExprID()] = newPhiNode; + ESSAPhiNode *newPhi = newPhiNode.get(); + varNodes[expr->GetExprID()] = std::move(newPhiNode); for (VarMeExpr *phiRHS : phiNode.GetOpnds()) { ESSABaseNode *rhs = nullptr; if (phiRHS->GetDefBy() != kDefByPhi) { @@ -55,22 +58,23 @@ namespace maple { MeVarPhiNode *defPhi = &(phiRHS->GetDefPhi()); rhs = GetOrCreatePhiNode(*defPhi); } - AddPhiEdge(*rhs, *newPhiNode, EdgeType::kUpper); - AddPhiEdge(*newPhiNode, *rhs, EdgeType::kLower); + AddPhiEdge(*rhs, *newPhi, EdgeType::kUpper); + AddPhiEdge(*newPhi, *rhs, EdgeType::kLower); } - CHECK_FATAL(newPhiNode->GetPhiOpnds().size() == newPhiNode->GetInPhiEdgeMap().size(), "must be"); - return newPhiNode; + CHECK_FATAL(newPhi->GetPhiOpnds().size() == newPhi->GetInPhiEdgeMap().size(), "must be"); + return newPhi; } ESSAArrayNode *InequalityGraph::GetOrCreateArrayNode(MeExpr &meExpr) { if (HasNode(meExpr)) { - return static_cast(varNodes[meExpr.GetExprID()]); + return static_cast(varNodes[meExpr.GetExprID()].get()); } CHECK_FATAL(meExpr.GetMeOp() == kMeOpVar, "meExpr must be VarMeExpr"); - ESSAArrayNode *newArrayNode = new ESSAArrayNode(GetValidID(), meExpr); + std::unique_ptr newArrayNode = std::make_unique(GetValidID(), meExpr); CHECK_FATAL(newArrayNode != nullptr, "new failed"); - varNodes[meExpr.GetExprID()] = newArrayNode; - return newArrayNode; + ESSAArrayNode *newArray = newArrayNode.get(); + varNodes[meExpr.GetExprID()] = std::move(newArrayNode); + return newArray; } InequalEdge *InequalityGraph::AddEdge(ESSABaseNode &from, ESSABaseNode &to, int value, EdgeType type) { @@ -79,24 +83,28 @@ namespace maple { if (edge != nullptr) { return edge; } - edge = new InequalEdge(value, type); - CHECK_FATAL(edge != nullptr, "new failed"); - from.InsertOutWithConstEdgeMap(to, *edge); - to.InsertInWithConstEdgeMap(from, *edge); - return edge; + std::unique_ptr e = std::make_unique(value, type); + InequalEdge *ePtr = e.get(); + CHECK_FATAL(e != nullptr, "new failed"); + from.InsertOutWithConstEdgeMap(to, *e); + to.InsertInWithConstEdgeMap(from, *e); + from.InsertEdges(std::move(e)); + return ePtr; } void InequalityGraph::AddPhiEdge(ESSABaseNode &from, ESSABaseNode &to, EdgeType type) { - InequalEdge *edge = new InequalEdge(0, type); + std::unique_ptr edge = std::make_unique(0, type); CHECK_FATAL(edge != nullptr, "new failed"); if (type == EdgeType::kUpper) { from.InsertOutWithConstEdgeMap(to, *edge); CHECK_FATAL(to.GetKind() == kPhiNode, "must be"); static_cast(to).InsertInPhiEdgeMap(from, *edge); + from.InsertEdges(std::move(edge)); } else { CHECK_FATAL(from.GetKind() == kPhiNode, "must be"); static_cast(from).InsertOutPhiEdgeMap(to, *edge); to.InsertInWithConstEdgeMap(from, *edge); + from.InsertEdges(std::move(edge)); } } @@ -105,10 +113,11 @@ namespace maple { if (HasEdge(from, to, tmpEdge)) { return; } - InequalEdge *edge = new InequalEdge(value, positive, type); + std::unique_ptr edge = std::make_unique(value, positive, type); CHECK_FATAL(edge != nullptr, "new failed"); from.InsertOutWithVarEdgeMap(to, *edge); to.InsertInWithVarEdgeMap(from, *edge); + from.InsertEdges(std::move(edge)); } bool InequalityGraph::HasNode(MeExpr &meExpr) const { @@ -122,9 +131,9 @@ namespace maple { void InequalityGraph::ConnectTrivalEdge() { int32 prevValue = 0; ESSABaseNode* prevNode = nullptr; - for (auto pair : constNodes) { + for (auto &pair : constNodes) { int32 value = pair.first; - ESSABaseNode* node = pair.second; + ESSABaseNode* node = pair.second.get(); if (prevNode == nullptr) { prevValue = value; prevNode = node; @@ -247,12 +256,12 @@ namespace maple { } void InequalityGraph::DumpDotNodes(IRMap &irMap, std::ostream &out, DumpType dumpType, - std::map nodes) const { + const std::map> &nodes) const { for (auto iter = nodes.begin(); iter != nodes.end(); ++iter) { std::string from = GetName(*(iter->second), irMap); out << "\"" << from << "\";\n"; - for (auto iterConstEdges = iter->second->GetOutWithConstEdgeMap().begin(); - iterConstEdges != iter->second->GetOutWithConstEdgeMap().end(); ++iterConstEdges) { + for (auto iterConstEdges = iter->second.get()->GetOutWithConstEdgeMap().begin(); + iterConstEdges != iter->second.get()->GetOutWithConstEdgeMap().end(); ++iterConstEdges) { EdgeType edgeType = iterConstEdges->second->GetEdgeType(); if (dumpType == kDumpNone) { DumpDotEdges(irMap, *iterConstEdges, out, from); @@ -264,8 +273,8 @@ namespace maple { DumpDotEdges(irMap, *iterConstEdges, out, from); } } - if (iter->second->GetKind() == kPhiNode) { - auto *phiNode = static_cast(iter->second); + if (iter->second.get()->GetKind() == kPhiNode) { + auto *phiNode = static_cast(iter->second.get()); for (auto iterConstEdges = phiNode->GetOutPhiEdgeMap().begin(); iterConstEdges != phiNode->GetOutPhiEdgeMap().end(); ++iterConstEdges) { EdgeType edgeType = iterConstEdges->second->GetEdgeType(); @@ -282,8 +291,8 @@ namespace maple { } } } - for (auto iterVarEdges = iter->second->GetOutWithVarEdgeMap().begin(); - iterVarEdges != iter->second->GetOutWithVarEdgeMap().end(); ++iterVarEdges) { + for (auto iterVarEdges = iter->second.get()->GetOutWithVarEdgeMap().begin(); + iterVarEdges != iter->second.get()->GetOutWithVarEdgeMap().end(); ++iterVarEdges) { EdgeType edgeType = iterVarEdges->second->GetEdgeType(); if (dumpType == kDumpNone) { DumpDotEdges(irMap, *iterVarEdges, out, from); @@ -327,10 +336,9 @@ namespace maple { } bool ABCD::DemandProve(ESSABaseNode &aNode, ESSABaseNode &bNode, EdgeType eType) { - InequalEdge *e = eType == kUpper ? new InequalEdge(kUpperBound, eType) : new InequalEdge(kLowerBound, eType); + std::unique_ptr e = std::make_unique(eType == kUpper ? kUpperBound : kLowerBound, eType); active.clear(); - ProveResult res = Prove(aNode, bNode, *e); - delete(e); + ProveResult res = Prove(aNode, bNode, *e.get()); return res == kTrue; } diff --git a/src/maple_me/src/me_rename2preg.cpp b/src/maple_me/src/me_rename2preg.cpp index 5511ba97a9d66d04ce05b384eaa9da07778a21d2..e2a4d2e81e37660bee07793c2efc4f9c74e2f184 100644 --- a/src/maple_me/src/me_rename2preg.cpp +++ b/src/maple_me/src/me_rename2preg.cpp @@ -147,7 +147,7 @@ class FormalRenaming final { } } - void Rename(MIRBuilder &irBuilder) { + void Rename(const MIRBuilder &irBuilder) { for (size_t i = 0; i < irFunc.GetFormalCount(); ++i) { if (!paramUsed[i]) { // in this case, the paramter is not used by any statement, promote it diff --git a/src/maple_me/src/ssa_epre.cpp b/src/maple_me/src/ssa_epre.cpp index 21f75ecffff41df8ca85a0546523e1c393aad711..a0ca7bada54c62ba4a89ce609b2515af79f56293 100644 --- a/src/maple_me/src/ssa_epre.cpp +++ b/src/maple_me/src/ssa_epre.cpp @@ -180,7 +180,7 @@ MeExpr *SSAEPre::PhiOpndFromRes(MeRealOcc *realZ, size_t j) { MapleVector &opnds = naryMeExpr->GetOpnds(); for (size_t i = 0; i < opnds.size(); i++) { MeExpr *retOpnd = GetReplaceMeExpr(opnds[i], ePhiBB, j); - if (retOpnd) { + if (retOpnd != nullptr) { opnds[i] = retOpnd; } } @@ -232,7 +232,7 @@ void SSAEPre::ComputeVarAndDfPhis() { MapleVector &opnds = naryMeExpr->GetOpnds(); for (size_t i = 0; i < opnds.size(); i++) { MeExpr *kidExpr = opnds[i]; - if (kidExpr) { + if (kidExpr != nullptr) { SetVarPhis(kidExpr); } } diff --git a/src/maple_me/src/ssa_pre.cpp b/src/maple_me/src/ssa_pre.cpp index b77ae598f5f23340f2c4b56cb16629764f7978df..71d3c41b7728641bf82e993f72c11efe6e7e6f32 100644 --- a/src/maple_me/src/ssa_pre.cpp +++ b/src/maple_me/src/ssa_pre.cpp @@ -229,7 +229,7 @@ void SSAPre::CodeMotion() { curTemp = nullptr; curLocalRefVar = nullptr; temp2LocalRefVarMap.clear(); - reBuiltOccIndex = workList.size(); // so we know the elements added due to rebuilding + reBuiltOccIndex = static_cast(workList.size()); // so we know the elements added due to rebuilding for (MeOccur *occ : allOccs) { switch (occ->GetOccType()) { case kOccReal: { @@ -633,7 +633,7 @@ void SSAPre::ResetDS(MePhiOpndOcc *phiOpnd) { return; } MeOccur *defOcc = phiOpnd->GetDef(); - if (!defOcc || defOcc->GetOccType() != kOccPhiocc) { + if (defOcc == nullptr || defOcc->GetOccType() != kOccPhiocc) { return; } auto *defPhiOcc = static_cast(defOcc); @@ -880,7 +880,7 @@ void SSAPre::Rename2() { MeRealOcc *realOcc = workCand->GetRealOcc(*it); rename2Set.erase(it); MeOccur *defOcc = realOcc->GetDef(); - if (!defOcc || defOcc->GetOccType() != kOccPhiocc) { + if (defOcc == nullptr || defOcc->GetOccType() != kOccPhiocc) { CHECK_FATAL(false, "should be def by phiOcc"); } auto *defPhiOcc = static_cast(defOcc); @@ -976,7 +976,7 @@ void SSAPre::SetVarPhis(MeExpr *meExpr) { } } else { MeRegPhiNode *phiMeNode = static_cast(meExpr)->GetMeRegPhiDef(); - if (phiMeNode) { + if (phiMeNode != nullptr) { BBId defBbId = phiMeNode->GetDefBB()->GetBBId(); CHECK(defBbId < dom->GetDtDfnSize(), "defBbId.idx out of range in SSAPre::SetVarPhis"); if (varPhiDfns.find(dom->GetDtDfnItem(defBbId)) == varPhiDfns.end() && ScreenPhiBB(defBbId)) { @@ -1217,7 +1217,7 @@ bool SSAPre::DefVarDominateOcc(MeExpr *meExpr, MeOccur *meOcc) { } case kDefByChi: { MeStmt *meStmt = varMeExpr->GetDefChi().GetBase(); - if (!meStmt) { + if (meStmt == nullptr) { return true; // it's a original variable dominate everything } BB *defBB = meStmt->GetBB();