diff --git a/src/bin/maple b/src/bin/maple index b2ae281b2f91d7c5e40d5a1102f177a826b882dc..329f6efcae996c7881406a1f8d5c56225b71f29a 100755 Binary files a/src/bin/maple and b/src/bin/maple differ diff --git a/src/deplibs/libmplutil.a b/src/deplibs/libmplutil.a index 5b358fb12d955ccd30ccf5780eb762b634450d90..e910dbeb345bd7e6f6fccfa0872d6a74ed1a46bf 100644 Binary files a/src/deplibs/libmplutil.a and b/src/deplibs/libmplutil.a differ diff --git a/src/maple_be/include/cg/cgfunc.h b/src/maple_be/include/cg/cgfunc.h index b9c5384562beba4a599340b0ff51309bba80e7d3..f8e83145a58b32771e8419a06a84d407e0b9f1dd 100644 --- a/src/maple_be/include/cg/cgfunc.h +++ b/src/maple_be/include/cg/cgfunc.h @@ -246,6 +246,7 @@ class CGFunc { virtual void ClearUnreachableGotInfos(BB &bb) { (void)bb; }; + virtual void SplitStrLdrPair() {} LabelIdx CreateLabel(); virtual Operand &CreateFPImmZero(PrimType primType) = 0; diff --git a/src/maple_be/include/cg/datainfo.h b/src/maple_be/include/cg/datainfo.h index 5a0c8ea7cc62ef04e9af2ed5ccfc94d26c1ae490..92b75d224dda6851416d2fa610ae9cf4b777e9b6 100644 --- a/src/maple_be/include/cg/datainfo.h +++ b/src/maple_be/include/cg/datainfo.h @@ -14,6 +14,10 @@ */ #ifndef MAPLEBE_INCLUDE_CG_DATAINFO_H #define MAPLEBE_INCLUDE_CG_DATAINFO_H +#include "maple_string.h" +#include "common_utils.h" +#include "mempool.h" +#include "mempool_allocator.h" namespace maplebe { class DataInfo { diff --git a/src/maple_be/src/cg/cgfunc.cpp b/src/maple_be/src/cg/cgfunc.cpp index 924f24a1f14bdcf8f056d55bb9da81e9b91ab8bd..471530bae3c2ce484eadfbc0d89d5760d3ead627 100644 --- a/src/maple_be/src/cg/cgfunc.cpp +++ b/src/maple_be/src/cg/cgfunc.cpp @@ -1072,6 +1072,7 @@ void CGFunc::HandleFunction() { MarkCleanupEntryBB(); DetermineReturnTypeofCall(); theCFG->UnreachCodeAnalysis(); + SplitStrLdrPair(); if (CGOptions::IsLazyBinding() && !GetCG()->IsLibcore()) { ProcessLazyBinding(); } diff --git a/src/maple_be/src/cg/emit.cpp b/src/maple_be/src/cg/emit.cpp index 0ac48233439456ffaffd255e1d8d338269754393..c8607cf92459b9b45002ed9ee942b099162ebf32 100644 --- a/src/maple_be/src/cg/emit.cpp +++ b/src/maple_be/src/cg/emit.cpp @@ -868,7 +868,7 @@ void Emitter::EmitAddrofSymbolConst(const MIRSymbol &mirSymbol, MIRConst &elemCo if (symAddrSym->IsReflectionFieldsInfoCompact() || symAddrSym->IsReflectionMethodsInfoCompact()) { /* Mark the least significant bit as 1 for compact fieldinfo */ - Emit(" + ").Emit(kDataRefIsCompact); + Emit(" + ").Emit(MethodFieldRef::kMethodFieldRefIsCompact); } } else if (mirSymbol.IsReflectionClassInfo()) { if ((idx == static_cast(ClassProperty::kItab)) || diff --git a/src/maple_driver/src/file_utils.cpp b/src/maple_driver/src/file_utils.cpp index a1bb625c75780be6b190226045ee9f0484350301..50ed9dfe9db83257fa71fda08b8d09fcd520cad2 100644 --- a/src/maple_driver/src/file_utils.cpp +++ b/src/maple_driver/src/file_utils.cpp @@ -37,7 +37,7 @@ const std::string kFileSeperatorStr = kFileSeperatorLinuxStyleStr; std::string FileUtils::GetRealPath(const std::string &filePath) { #ifdef _WIN32 - char *path; + char *path = nullptr; if (filePath.size() > PATH_MAX || !PathCanonicalize(path, filePath.c_str())) { CHECK_FATAL(false, "invalid file path"); } diff --git a/src/maple_ir/include/global_tables.h b/src/maple_ir/include/global_tables.h index d3c8a5b5074b1568f048c4d37dbc46ebfaa8e474..f4b70e0b771563da6c5eff18b261e0410691d82a 100644 --- a/src/maple_ir/include/global_tables.h +++ b/src/maple_ir/include/global_tables.h @@ -56,8 +56,8 @@ class UStrIdxHash { }; class IntConstKey { - friend class IntConstHash; - friend class IntConstCmp; + friend class IntConstHash; + friend class IntConstCmp; public: IntConstKey(int64 v, uint64 id) : val(v), tyidxFieldID(id) {} private: diff --git a/src/maple_ir/include/metadata_layout.h b/src/maple_ir/include/metadata_layout.h index 80415011d73cdc5572847f2fcefb5d191aa00397..22bf2902c199d758c5e97687f7c2b4ba292c9b95 100644 --- a/src/maple_ir/include/metadata_layout.h +++ b/src/maple_ir/include/metadata_layout.h @@ -27,7 +27,7 @@ using MetaRef = uintptr_t; // consistent iwth reffield_t in address.h #endif // USE_32BIT_REF // DataRefOffset aims to represent a reference to data in maple file, which is already an offset. -// DataRefOffset is meant to have pointer size and aligned to at least 4 bytes. +// DataRefOffset is meant to have pointer size. // All Xx32 data types defined in this file aim to use 32 bits to save 64-bit address, and thus are // specific for 64-bit platforms. struct DataRefOffset32 { @@ -40,15 +40,12 @@ struct DataRefOffset32 { inline void SetRawValue(int64_t value); }; -struct DataRefOffset64 { +struct DataRefOffsetPtr { intptr_t refOffset; template inline void SetDataRef(T ref); template inline T GetDataRef() const; - inline bool IsCompact() const; - template - inline T GetCompactData() const; inline int64_t GetRawValue() const; inline void SetRawValue(int64_t value); }; @@ -57,7 +54,7 @@ struct DataRefOffset { #ifdef USE_32BIT_REF DataRefOffset32 refOffset; #else - DataRefOffset64 refOffset; + DataRefOffsetPtr refOffset; #endif template inline void SetDataRef(T ref); @@ -66,20 +63,39 @@ struct DataRefOffset { inline int64_t GetRawValue() const; inline void SetRawValue(int64_t value); }; + +struct MethodFieldRef { + // MethodFieldRef aims to represent a reference to fields/methods in maple file, which is already an offset. + // also, offset LSB may set 1, to indicate that it is compact fields/methods. + enum MethodFieldRefFormat { + kMethodFieldRefIsCompact = 1, + }; + DataRefOffsetPtr refOffset; + template + inline void SetDataRef(T ref); + template + inline T GetDataRef() const; + inline bool IsCompact() const; + template + inline T GetCompactData() const; + inline int64_t GetRawValue() const; + inline void SetRawValue(int64_t value); +}; + /* DataRef aims for reference to data in maple file (generated by maple compiler) and is aligned to at least 4 bytes. Perhaps MDataRef is more fit, still DataRef is chosen to make it common. DataRef allows 4 formats of value: 0. "label_name" for direct reference - 1. "label_name - . + 1" for historical compact metadata reference + 1. "label_name - . + 1" for padding unused 2. "label_name - . + 2" for reference in offset format 3. "indirect.label_name - . + 3" for indirect reference this format aims to support lld which does not support expression "global_symbol - ." DataRef is self-decoded by also encoding the format and is defined for binary compatibility. - If no compatibility problem is involved, DataRefOffset64 is preferred. + If no compatibility problem is involved, DataRefOffsetPtr is preferred. */ enum DataRefFormat { kDataRefIsDirect = 0, // must be 0 - kDataRefIsCompact = 1, // read-only + kDataRefPadding = 1, // unused kDataRefIsOffset = 2, kDataRefIsIndirect = 3, // read-only kDataRefBitMask = 3, @@ -210,8 +226,8 @@ struct MethodDesc { // update aarch64rtsupport.h if you modify this definition. struct ClassMetadataRO { MByteRef className; - DataRefOffset64 fields; // point to info of fields - DataRefOffset64 methods; // point to info of methods + MethodFieldRef fields; // point to info of fields + MethodFieldRef methods; // point to info of methods union { // Element classinfo of array, others parent classinfo DataRef superclass; DataRef componentClass; @@ -317,7 +333,7 @@ struct ClassMetadata { // NOte 2: C should be of jclass/ClassMetata* type template static inline void MRTSetMetadataShadow(M *meta, C cls) { - meta->shadow = (MetaRef)(uintptr_t)cls; + meta->shadow = static_cast(reinterpret_cast(cls)); } #endif // METADATA_LAYOUT_H diff --git a/src/maple_ir/include/mir_type.h b/src/maple_ir/include/mir_type.h index 2796df3369741d5b644bcf678ccce9a10f6e7dce..688856536dee71e77a5b74d15beef8cd4b3b2019 100644 --- a/src/maple_ir/include/mir_type.h +++ b/src/maple_ir/include/mir_type.h @@ -1459,7 +1459,7 @@ class MIRFuncType : public MIRType { constexpr uint8 idxShift = 6; size_t hIdx = (static_cast(retTyIdx) << idxShift) + (typeKind << kShiftNumOfTypeKind); size_t size = paramTypeList.size(); - hIdx += (size ? (static_cast(paramTypeList[0]) + size) : 0) << 4; + hIdx += (size ? (static_cast(paramTypeList[0]) + size) : 0) << 4; // shift bit is 4 return hIdx % kTypeHashLength; } @@ -1557,9 +1557,10 @@ class MIRInstantVectorType : public MIRType { } size_t GetHashIndex() const override { + constexpr uint8 idxShift = 3; uint32 hIdx = typeKind << kShiftNumOfTypeKind; for (const TypePair &typePair : instantVec) { - hIdx += static_cast(typePair.first + typePair.second) << 3; + hIdx += static_cast(typePair.first + typePair.second) << idxShift; } return hIdx % kTypeHashLength; } @@ -1600,7 +1601,7 @@ class MIRGenericInstantType : public MIRInstantVectorType { constexpr uint8 idxShift = 2; uint32 hIdx = (static_cast(genericTyIdx) << idxShift) + (typeKind << kShiftNumOfTypeKind); for (const TypePair &typePair : instantVec) { - hIdx += static_cast(typePair.first + typePair.second) << 3; + hIdx += static_cast(typePair.first + typePair.second) << 3; // shift bit is 3 } return hIdx % kTypeHashLength; } diff --git a/src/maple_ir/src/global_tables.cpp b/src/maple_ir/src/global_tables.cpp index c79abe988e4cad1e81ebaa7208a093ca0f0b40fc..f521c25c1ca433b0f656e2c905d8abf1e57a06af 100644 --- a/src/maple_ir/src/global_tables.cpp +++ b/src/maple_ir/src/global_tables.cpp @@ -205,7 +205,7 @@ void FPConstTable::PostInit() { } MIRIntConst *IntConstTable::GetOrCreateIntConst(int64 val, MIRType &type, uint32 fieldID) { - uint64 idid = static_cast(type.GetTypeIndex()) + (static_cast(fieldID) << 32); + uint64 idid = static_cast(type.GetTypeIndex()) + (static_cast(fieldID) << 32); // shift bit is 32 IntConstKey key(val, idid); if (intConstTable.find(key) != intConstTable.end()) { return intConstTable[key]; diff --git a/src/maple_me/include/dominance.h b/src/maple_me/include/dominance.h index 47059c88b2a871f86af6b9dc85a2fa8136faa296..5fd6c0ca408272882ab9ed37428483fe0668d6d3 100644 --- a/src/maple_me/include/dominance.h +++ b/src/maple_me/include/dominance.h @@ -193,7 +193,7 @@ class Dominance : public AnalysisResult { void PostOrderWalk(const BB &bb, int32 &pid, std::vector &visitedMap); BB *Intersect(BB &bb1, const BB &bb2) const; bool CommonEntryBBIsPred(const BB &bb) const; - void PdomPostOrderWalk(BB &bb, int32 &pid, std::vector &visitedMap); + void PdomPostOrderWalk(const BB &bb, int32 &pid, std::vector &visitedMap); BB *PdomIntersect(BB &bb1, const BB &bb2); MapleAllocator domAllocator; // stores the analysis results diff --git a/src/maple_me/include/me_abco.h b/src/maple_me/include/me_abco.h index 86b99635352462d25259c9acb520540965d9cd14..652acd12b7c28f14c492ca3af84c09850cbb8915 100644 --- a/src/maple_me/include/me_abco.h +++ b/src/maple_me/include/me_abco.h @@ -176,7 +176,7 @@ class DefPoint { } } - void Dump(IRMap &irMap) { + void Dump(const IRMap &irMap) { LogInfo::MapleLogger() << "New Def : " << '\n'; if (defKind == kDefByPi) { value.pi->Dump(&irMap); @@ -226,19 +226,19 @@ class MeABC { bool IsLegal(MeStmt &meStmt); void ABCCollectArrayExpr(MeStmt &meStmt, MeExpr &meExpr, bool isUpdate = false); void CollectCareInsns(); - bool ExistedPiNode(BB &bb, BB &parentBB, VarMeExpr &rhs); + bool ExistedPiNode(BB &bb, BB &parentBB, const VarMeExpr &rhs); void CreatePhi(VarMeExpr &rhs, BB &dfBB); - VarMeExpr *CreateNewPiExpr(MeExpr &opnd); + VarMeExpr *CreateNewPiExpr(const MeExpr &opnd); void CreateNewPiStmt(VarMeExpr *lhs, MeExpr &rhs, BB &bb, MeStmt &generatedBy, bool isToken); void CreateNewPiStmt(VarMeExpr *lhs, MeExpr &rhs, MeStmt &generatedBy); MeExpr *ReplaceMeExprExpr(MeExpr &origExpr, MeExpr &oldVar, MeExpr &repExpr); MeExpr *NewMeExpr(MeExpr &meExpr); bool ReplaceMeExprStmtOpnd(uint32 opndID, MeStmt &meStmt, MeExpr &oldVar, MeExpr &newVar, bool update); bool ReplaceStmtWithNewVar(MeStmt &meStmt, MeExpr &oldVar, MeExpr &newVar, bool update); - bool IsVirtualVar(VarMeExpr &var, SSATab &ssaTab) const; + bool IsVirtualVar(const VarMeExpr &var, const SSATab &ssaTab) const; ESSABaseNode *GetOrCreateRHSNode(MeExpr &expr); void BuildPhiInGraph(MeVarPhiNode &phi); - void BuildSoloPiInGraph(PiassignMeStmt &piMeStmt); + void BuildSoloPiInGraph(const PiassignMeStmt &piMeStmt); bool BuildArrayCheckInGraph(MeStmt &meStmt); bool BuildBrMeStmtInGraph(MeStmt &meStmt); bool BuildAssignInGraph(MeStmt &meStmt); @@ -249,7 +249,7 @@ class MeABC { void AddCarePhi(MeVarPhiNode &defP); void BuildInequalityGraph(); void FindRedundantABC(MeStmt &meStmt, NaryMeExpr &naryMeExpr); - void InitNewStartPoint(MeStmt &meStmt, NaryMeExpr &nMeExpr); + void InitNewStartPoint(const MeStmt &meStmt, const NaryMeExpr &nMeExpr); void DeleteABC(); bool CleanABCInStmt(MeStmt &meStmt, NaryMeExpr &naryMeExpr); MeExpr *ReplaceArrayExpr(MeExpr &rhs, MeExpr &naryMeExpr, MeStmt *ivarStmt); diff --git a/src/maple_me/include/me_analyze_rc.h b/src/maple_me/include/me_analyze_rc.h index 76075bd813b681d3d03d8709f0697739c2fafef6..6b28c2915be600fa3c0731110273756e563a3779 100644 --- a/src/maple_me/include/me_analyze_rc.h +++ b/src/maple_me/include/me_analyze_rc.h @@ -76,7 +76,7 @@ class AnalyzeRC { UnaryMeStmt *CreateIncrefZeroVersion(const OriginalSt &ost); DassignMeStmt *CreateDassignInit(OriginalSt &ost, BB &bb); void TraverseStmt(BB &bb); - bool NeedDecRef(RCItem &rcItem, MeExpr &expr) const; + bool NeedDecRef(const RCItem &rcItem, MeExpr &expr) const; bool NeedDecRef(IvarMeExpr &ivar) const; bool NeedDecRef(const VarMeExpr &var) const; diff --git a/src/maple_me/include/me_delegate_rc.h b/src/maple_me/include/me_delegate_rc.h index e7e955e04c215b2bcf41fd93642608eefe535346..40526cc8f94126cc54f09ce1fa18663f73893e8d 100644 --- a/src/maple_me/include/me_delegate_rc.h +++ b/src/maple_me/include/me_delegate_rc.h @@ -47,8 +47,8 @@ class DelegateRC { void CollectUseCounts(const MeExpr &expr); void FindAndDecrUseCount(const VarMeExpr &rhsVar, const MeExpr &expr, int32 &remainingUses) const; bool MayThrowException(const MeStmt &stmt) const; - bool ContainAllTheUses(VarMeExpr &rhsVar, const MeStmt &fromStmt, const MeStmt &toStmt) const; - RegMeExpr *RHSTempDelegated(MeExpr &rhs, MeStmt &useStmt); + bool ContainAllTheUses(const VarMeExpr &rhsVar, const MeStmt &fromStmt, const MeStmt &toStmt) const; + RegMeExpr *RHSTempDelegated(MeExpr &rhs, const MeStmt &useStmt); bool FinalRefNoRC(const MeExpr &expr) const; void SetCantDelegate(const MapleMap &meVarPhiList); void SaveDerefedOrCopiedVst(const MeExpr *expr); diff --git a/src/maple_me/include/me_loop_analysis.h b/src/maple_me/include/me_loop_analysis.h index 9ef5673613dceed3f73414b8cc600b9f23af90aa..8ca13ddee35cfd37cf220587b2580329675d60c8 100644 --- a/src/maple_me/include/me_loop_analysis.h +++ b/src/maple_me/include/me_loop_analysis.h @@ -29,7 +29,7 @@ struct LoopDesc { BB *tail; BB *preheader; BB *latch; - MapleMap*> inloopBB2exitBBs; + MapleMap*> inloopBB2exitBBs; MapleSet loopBBs; LoopDesc *parent; // points to its closest nesting loop uint32 nestDepth; // the nesting depth @@ -50,28 +50,30 @@ struct LoopDesc { return false; } - void InsertInloopBB2exitBBs(BB &key, BB &value) { - if (inloopBB2exitBBs.find(&key) == inloopBB2exitBBs.end()) { - inloopBB2exitBBs[&key] = alloc->GetMemPool()->New>(alloc->Adapter()); - inloopBB2exitBBs[&key]->push_back(&value); + void InsertInloopBB2exitBBs(const BB &bb, BB &value) { + BBId key = bb.GetBBId(); + if (inloopBB2exitBBs.find(key) == inloopBB2exitBBs.end()) { + inloopBB2exitBBs[key] = alloc->GetMemPool()->New>(alloc->Adapter()); + inloopBB2exitBBs[key]->push_back(&value); } else { - auto it = find(inloopBB2exitBBs[&key]->begin(), inloopBB2exitBBs[&key]->end(), &value); - if (it == inloopBB2exitBBs[&key]->end()) { - inloopBB2exitBBs[&key]->push_back(&value); + auto it = find(inloopBB2exitBBs[key]->begin(), inloopBB2exitBBs[key]->end(), &value); + if (it == inloopBB2exitBBs[key]->end()) { + inloopBB2exitBBs[key]->push_back(&value); } } } - void ReplaceInloopBB2exitBBs(BB &key, BB &oldValue, BB &value) { - CHECK_FATAL(inloopBB2exitBBs.find(&key) != inloopBB2exitBBs.end(), "key must exits"); - auto mapIt = inloopBB2exitBBs[&key]; + void ReplaceInloopBB2exitBBs(const BB &bb, BB &oldValue, BB &value) { + BBId key = bb.GetBBId(); + CHECK_FATAL(inloopBB2exitBBs.find(key) != inloopBB2exitBBs.end(), "key must exits"); + auto mapIt = inloopBB2exitBBs[key]; auto it = find(mapIt->begin(), mapIt->end(), &oldValue); - CHECK_FATAL(it != inloopBB2exitBBs[&key]->end(), "old Vvalue must exits"); + CHECK_FATAL(it != inloopBB2exitBBs[key]->end(), "old Vvalue must exits"); *it = &value; - CHECK_FATAL(find(inloopBB2exitBBs[&key]->begin(), inloopBB2exitBBs[&key]->end(), &value) != - inloopBB2exitBBs[&key]->end(), "replace fail"); - CHECK_FATAL(find(inloopBB2exitBBs[&key]->begin(), inloopBB2exitBBs[&key]->end(), &oldValue) == - inloopBB2exitBBs[&key]->end(), "replace fail"); + CHECK_FATAL(find(inloopBB2exitBBs[key]->begin(), inloopBB2exitBBs[key]->end(), &value) != + inloopBB2exitBBs[key]->end(), "replace fail"); + CHECK_FATAL(find(inloopBB2exitBBs[key]->begin(), inloopBB2exitBBs[key]->end(), &oldValue) == + inloopBB2exitBBs[key]->end(), "replace fail"); } void SetHasTryBB(bool has) { diff --git a/src/maple_me/include/me_loop_canon.h b/src/maple_me/include/me_loop_canon.h index b02414be4abc5eda8d3b5f43c9d2e1867af75f4f..a22061dca1930493f7ec6911d769b5c00aaf244c 100644 --- a/src/maple_me/include/me_loop_canon.h +++ b/src/maple_me/include/me_loop_canon.h @@ -33,11 +33,11 @@ class MeDoLoopCanon : public MeFuncPhase { private: using Key = std::pair; - std::map> heads; + std::map> heads; void Convert(MeFunction &func, BB &bb, BB &pred, MapleMap &swapSuccs); bool NeedConvert(BB &bb, BB &pred, MapleAllocator &alloc, MapleMap &swapSuccs) const; - void FindHeadBBs(MeFunction &func, Dominance &dom, BB *bb); - bool IsDoWhileLoop(const LoopDesc &loop) const; + void FindHeadBBs(MeFunction &func, Dominance &dom, const BB *bb); + bool IsDoWhileLoop(MeFunction &func, const LoopDesc &loop) const; void Merge(MeFunction &func); void AddPreheader(MeFunction &func); void InsertNewExitBB(MeFunction &func, LoopDesc &loop); diff --git a/src/maple_me/include/ssa.h b/src/maple_me/include/ssa.h index 3c69addc4a41898563222f0fb18f918a291c1f55..573665b0a1b9803458b13b647df9b651e3cb7fbc 100644 --- a/src/maple_me/include/ssa.h +++ b/src/maple_me/include/ssa.h @@ -1,5 +1,5 @@ /* - * Copyright (c) [2019] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2019-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. @@ -95,7 +95,7 @@ class SSA { void RenameMustDefs(const StmtNode &stmt, BB &defBB); void RenameExpr(BaseNode &expr); void RenameUses(StmtNode &stmt); - void RenamePhiUseInSucc(BB &bb); + void RenamePhiUseInSucc(const BB &bb); void RenameMayUses(BaseNode &node); MapleAllocator &GetSSAAlloc() { diff --git a/src/maple_me/src/dominance.cpp b/src/maple_me/src/dominance.cpp index e3cd899b8f787ed3ea4033ee359f875cb3868817..095303afb2c1e48fd68460a5b580e95871d9a97d 100644 --- a/src/maple_me/src/dominance.cpp +++ b/src/maple_me/src/dominance.cpp @@ -175,7 +175,7 @@ bool Dominance::Dominate(const BB &bb1, const BB &bb2) { } /* ================= for PostDominance ================= */ -void Dominance::PdomPostOrderWalk(BB &bb, int32 &pid, std::vector &visitedMap) { +void Dominance::PdomPostOrderWalk(const BB &bb, int32 &pid, std::vector &visitedMap) { ASSERT(bb.GetBBId() < visitedMap.size(), "index out of range in Dominance::PdomPostOrderWalk"); if (bbVec[bb.GetBBId()] == nullptr) { return; diff --git a/src/maple_me/src/me_abco.cpp b/src/maple_me/src/me_abco.cpp index be461616916c3067d4be18cef7fe48b76332a492..68829714dc9f5d3df30b4b1c135e6d6366c406b4 100644 --- a/src/maple_me/src/me_abco.cpp +++ b/src/maple_me/src/me_abco.cpp @@ -75,13 +75,13 @@ bool MeABC::IsLegal(MeStmt &meStmt) { return true; } -VarMeExpr *MeABC::CreateNewPiExpr(MeExpr &opnd) { +VarMeExpr *MeABC::CreateNewPiExpr(const MeExpr &opnd) { if (opnd.GetMeOp() == kMeOpConst) { return nullptr; } CHECK_FATAL(opnd.GetMeOp() == kMeOpVar, "must be"); SSATab &ssaTab = irMap->GetSSATab(); - OriginalSt *ost = ssaTab.GetOriginalStFromID(static_cast(&opnd)->GetOStIdx()); + OriginalSt *ost = ssaTab.GetOriginalStFromID(static_cast(&opnd)->GetOStIdx()); CHECK_NULL_FATAL(ost); CHECK_FATAL(!ost->IsVolatile(), "must be"); VarMeExpr *var = irMap->NewInPool(irMap->GetExprID(), ost->GetIndex(), @@ -186,7 +186,7 @@ bool MeABC::ExistedPhiNode(BB &bb, VarMeExpr &rhs) { return bb.GetMevarPhiList().find(rhs.GetOStIdx()) != bb.GetMevarPhiList().end(); } -bool MeABC::ExistedPiNode(BB &bb, BB &parentBB, VarMeExpr &rhs) { +bool MeABC::ExistedPiNode(BB &bb, BB &parentBB, const VarMeExpr &rhs) { MapleMap> &piList = bb.GetPiList(); auto it = piList.find(&parentBB); if (it == piList.end()) { @@ -599,7 +599,7 @@ void MeABC::RemoveExtraNodes() { memPoolCtrler.DeleteMemPool(memPool); } -bool MeABC::IsVirtualVar(VarMeExpr &var, SSATab &ssaTab) const { +bool MeABC::IsVirtualVar(const VarMeExpr &var, const SSATab &ssaTab) const { const OriginalSt *ost = ssaTab.GetOriginalStFromID(var.GetOStIdx()); return ost->GetIndirectLev() > 0; } @@ -640,7 +640,7 @@ void MeABC::BuildPhiInGraph(MeVarPhiNode &phi) { } } -void MeABC::BuildSoloPiInGraph(PiassignMeStmt &piMeStmt) { +void MeABC::BuildSoloPiInGraph(const PiassignMeStmt &piMeStmt) { VarMeExpr *piLHS = piMeStmt.GetLHS(); VarMeExpr *piRHS = piMeStmt.GetRHS(); AddUseDef(*piRHS); @@ -1297,7 +1297,7 @@ void MeABC::DeleteABC() { } } -void MeABC::InitNewStartPoint(MeStmt &meStmt, NaryMeExpr &nMeExpr) { +void MeABC::InitNewStartPoint(const MeStmt &meStmt, const NaryMeExpr &nMeExpr) { careMeStmts.clear(); careMePhis.clear(); carePoints.clear(); diff --git a/src/maple_me/src/me_analyze_rc.cpp b/src/maple_me/src/me_analyze_rc.cpp index 86accbec2ef5c5cdf8638ab2a5c85b3e1b7db53d..19bdbf8a9e4b63163ef8e02ca06d946d71b5e189 100644 --- a/src/maple_me/src/me_analyze_rc.cpp +++ b/src/maple_me/src/me_analyze_rc.cpp @@ -59,7 +59,7 @@ // information is lost after a pointer is promoted to preg. Because it is run // after EPRE phase, there can be regassign's and regread's of ref type but // they will not cause decref or incref insertion. - +// // if number of live localrefvars is more than this limit at a return, we will // not insert the intrinsiccall to CLEANUP_LOCALREFVARS namespace { @@ -330,7 +330,7 @@ void AnalyzeRC::OptimizeRC() { } } -bool AnalyzeRC::NeedDecRef(RCItem &rcItem, MeExpr &expr) const { +bool AnalyzeRC::NeedDecRef(const RCItem &rcItem, MeExpr &expr) const { CHECK_FATAL((rcItem.nonLocal || rcItem.noAlias), "OptimizeRC: local pointers cannot have alias"); // see if the decref can be optimized away if (rcItem.nonLocal) { diff --git a/src/maple_me/src/me_delegate_rc.cpp b/src/maple_me/src/me_delegate_rc.cpp index 32adaae4f48e25f27a1d27bf132793f03e985ccd..d7d03109ad9447b9f7a842503f2ce86bef815074 100644 --- a/src/maple_me/src/me_delegate_rc.cpp +++ b/src/maple_me/src/me_delegate_rc.cpp @@ -263,7 +263,7 @@ bool DelegateRC::MayThrowException(const MeStmt &stmt) const { // rhsvar, so it can be assumed that tostmt does not contain any use; this check // make use of verStUseCounts in its determination. In addition, if it comes // across any stmt that can raise exception, also return false. -bool DelegateRC::ContainAllTheUses(VarMeExpr &rhsVar, const MeStmt &fromStmt, const MeStmt &toStmt) const { +bool DelegateRC::ContainAllTheUses(const VarMeExpr &rhsVar, const MeStmt &fromStmt, const MeStmt &toStmt) const { int32 remainingUses = static_cast(verStUseCounts[rhsVar.GetVstIdx()]) - 1; for (MeStmt *cur = fromStmt.GetPrev(); cur != &toStmt; cur = cur->GetPrev()) { // do not count decref operands @@ -285,7 +285,7 @@ bool DelegateRC::ContainAllTheUses(VarMeExpr &rhsVar, const MeStmt &fromStmt, co } // return the RegMeExpr node to replace the original temp; nullptr if not successful -RegMeExpr *DelegateRC::RHSTempDelegated(MeExpr &rhs, MeStmt &useStmt) { +RegMeExpr *DelegateRC::RHSTempDelegated(MeExpr &rhs, const MeStmt &useStmt) { if (rhs.GetMeOp() != kMeOpVar) { return nullptr; } diff --git a/src/maple_me/src/me_loop_canon.cpp b/src/maple_me/src/me_loop_canon.cpp index 7f3ceafea18d1a26806d395b35033bb04885627f..0a5f2a1492d6216fb19a78c7313e7f7c98a0c091 100644 --- a/src/maple_me/src/me_loop_canon.cpp +++ b/src/maple_me/src/me_loop_canon.cpp @@ -262,7 +262,7 @@ void MeDoLoopCanon::ExecuteLoopCanon(MeFunction &func, MeFuncResultMgr &m, Domin } // Only when backege or preheader is not try bb, update head map. -void MeDoLoopCanon::FindHeadBBs(MeFunction &func, Dominance &dom, BB *bb) { +void MeDoLoopCanon::FindHeadBBs(MeFunction &func, Dominance &dom, const BB *bb) { if (bb == nullptr || bb == func.GetCommonExitBB()) { return; } @@ -277,12 +277,12 @@ void MeDoLoopCanon::FindHeadBBs(MeFunction &func, Dominance &dom, BB *bb) { for (BB *pred : bb->GetPred()) { // add backege bb if (dom.Dominate(*bb, *pred)) { - if (heads.find(bb) != heads.end()) { - heads[bb].push_back(pred); + if (heads.find(bb->GetBBId()) != heads.end()) { + heads[bb->GetBBId()].push_back(pred); } else { std::vector tails; tails.push_back(pred); - heads[bb] = tails; + heads[bb->GetBBId()] = tails; } } } @@ -296,7 +296,7 @@ void MeDoLoopCanon::FindHeadBBs(MeFunction &func, Dominance &dom, BB *bb) { // merge backedges with the same headBB void MeDoLoopCanon::Merge(MeFunction &func) { for (auto iter = heads.begin(); iter != heads.end(); ++iter) { - BB *head = iter->first; + BB *head = func.GetBBFromID(iter->first); auto *latchBB = func.NewBasicBlock(); latchBB->SetAttributes(kBBAttrArtificial); latchBB->SetKind(kBBFallthru); @@ -340,7 +340,7 @@ void MeDoLoopCanon::Merge(MeFunction &func) { void MeDoLoopCanon::AddPreheader(MeFunction &func) { for (auto iter = heads.begin(); iter != heads.end(); ++iter) { - BB *head = iter->first; + BB *head = func.GetBBFromID(iter->first); std::vector preds; for (BB *pred : head->GetPred()) { // FindHeadBBs has filtered out this possibility. @@ -400,7 +400,7 @@ void MeDoLoopCanon::AddPreheader(MeFunction &func) { void MeDoLoopCanon::InsertNewExitBB(MeFunction &func, LoopDesc &loop) { for (auto pair : loop.inloopBB2exitBBs) { - BB *curBB = pair.first; + BB *curBB = func.GetBBFromID(pair.first); for (auto succBB : *pair.second) { bool needNewExitBB = false; for (auto pred : succBB->GetPred()) { @@ -476,7 +476,7 @@ void MeDoLoopCanon::InsertExitBB(MeFunction &func, LoopDesc &loop) { } void MeDoLoopCanon::SplitCondGotBB(MeFunction &func, LoopDesc &loop) { - auto exitBB = loop.inloopBB2exitBBs.begin()->first; + auto exitBB = func.GetBBFromID(loop.inloopBB2exitBBs.begin()->first); StmtNode *lastStmt = &(exitBB->GetStmtNodes().back()); if (lastStmt->GetOpCode() != OP_brfalse && lastStmt->GetOpCode() != OP_brtrue && lastStmt->GetOpCode() != OP_switch) { CHECK_FATAL(false, "must be OP_brfalse, OP_brtrue or OP_switch"); @@ -522,13 +522,13 @@ void MeDoLoopCanon::SplitCondGotBB(MeFunction &func, LoopDesc &loop) { newFallthru->AddSucc(*exitBB); } -bool MeDoLoopCanon::IsDoWhileLoop(const LoopDesc &loop) const { +bool MeDoLoopCanon::IsDoWhileLoop(MeFunction &func, const LoopDesc &loop) const { for (auto succ : loop.head->GetSucc()) { if (!loop.Has(*succ)) { return false; } } - auto exitBB = loop.inloopBB2exitBBs.begin()->first; + auto exitBB = func.GetBBFromID(loop.inloopBB2exitBBs.begin()->first); for (auto pred : exitBB->GetPred()) { if (!loop.Has(*pred)) { return false; @@ -564,7 +564,7 @@ void MeDoLoopCanon::ExecuteLoopNormalization(MeFunction &func, MeFuncResultMgr loop->SetIsCanonicalLoop(true); } if (loop->inloopBB2exitBBs.size() == 1 && loop->inloopBB2exitBBs.begin()->second->size() == 1 && - IsDoWhileLoop(*loop)) { + IsDoWhileLoop(func, *loop)) { SplitCondGotBB(func, *loop); } } diff --git a/src/maple_me/src/ssa.cpp b/src/maple_me/src/ssa.cpp index ee56c57e5e4d998b261d873187c60c38fd7aa418..927e736e619624a0f910e30e833a9c65d5480e19 100644 --- a/src/maple_me/src/ssa.cpp +++ b/src/maple_me/src/ssa.cpp @@ -131,7 +131,7 @@ void SSA::RenameUses(StmtNode &stmt) { } } -void SSA::RenamePhiUseInSucc(BB &bb) { +void SSA::RenamePhiUseInSucc(const BB &bb) { for (BB *succBB : bb.GetSucc()) { // find index of bb in succ_bb->pred[] size_t index = 0; diff --git a/src/maple_util/include/muid.h b/src/maple_util/include/muid.h index ec75ae339bb6fd718bb2a3693998c4638a455e6d..c5f46227ebd484595642d188e6af50eb143ea772 100644 --- a/src/maple_util/include/muid.h +++ b/src/maple_util/include/muid.h @@ -59,7 +59,8 @@ struct MuidContext { unsigned char buffer[kGroupSize]; }; -struct MUID { +class MUID { + public: union { #ifdef USE_64BIT_MUID uint64_t raw; diff --git a/src/maple_util/include/utils.h b/src/maple_util/include/utils.h index 8d447d0e827d5a5773855e33badf479ef6ebf70d..b6dd340220b8744cf0d06f7e62c13912916fdf4b 100644 --- a/src/maple_util/include/utils.h +++ b/src/maple_util/include/utils.h @@ -113,6 +113,5 @@ struct lbit_field { template constexpr uint64_t lbit_field_v = bit_field::value; - }} // namespace maple::utils #endif // MAPLE_UTIL_INCLUDE_UTILS_H diff --git a/src/maple_util/include/utils/iterator.h b/src/maple_util/include/utils/iterator.h index 293b5cf5242102e68d53d85e978f929307566a53..6f8e42912888aad3431ffddd7075567c1d75f7d7 100644 --- a/src/maple_util/include/utils/iterator.h +++ b/src/maple_util/include/utils/iterator.h @@ -18,7 +18,6 @@ #include "meta.h" namespace maple { namespace utils { - template struct mpl_iterator_traits { using iterator_category = typename std::iterator_traits::iterator_category; diff --git a/src/maple_util/include/utils/meta.h b/src/maple_util/include/utils/meta.h index 514e7adeca3fe0987138869bc386b9fa8b639f74..b2ce82cf79a0bd5c955954a4fb7c8db719a817d6 100644 --- a/src/maple_util/include/utils/meta.h +++ b/src/maple_util/include/utils/meta.h @@ -17,7 +17,6 @@ #include namespace maple { namespace utils { - template struct meta_and : std::conditional_t {}; @@ -109,6 +108,5 @@ struct is_ncv_same template >> constexpr bool is_ncv_same_v = is_ncv_same::value; } - }} #endif //MAPLE_UTIL_INCLUDE_UTILS_META_H diff --git a/src/maple_util/include/utils/ref_vector.h b/src/maple_util/include/utils/ref_vector.h index 4a1e5da2b6de94225f4adba4017f56601395c0fa..31c47178e3d4c84465c11a806b5a43d7296fb9f9 100644 --- a/src/maple_util/include/utils/ref_vector.h +++ b/src/maple_util/include/utils/ref_vector.h @@ -24,7 +24,6 @@ // to check nullptr, it will make the code more confusion and hard to maintain. // Based on that, the ref_vector picks up the meaning of keeping objects' reference, it won't destory any of its // elements or require to check null(Never to be nullptr). - namespace maple { namespace utils { class ref_vector_tag; template diff --git a/src/mpl2mpl/src/muid_replacement.cpp b/src/mpl2mpl/src/muid_replacement.cpp index d7eb9029cba8ee3e35dbaecc0a312ae959cbcc24..e2e2519b1e3739b1e7fe4d643204f76edfdca2b2 100644 --- a/src/mpl2mpl/src/muid_replacement.cpp +++ b/src/mpl2mpl/src/muid_replacement.cpp @@ -733,7 +733,6 @@ void MUIDReplacement::GenerateRangeTable() { rangeTabConst->PushBack(entryConst); } // Please refer to mrt/compiler-rt/include/mpl_linker.h for the layout - std::vector workList = { funcDefTabSym, funcDefOrigTabSym, diff --git a/src/mpl2mpl/src/reflection_analysis.cpp b/src/mpl2mpl/src/reflection_analysis.cpp index 723bb59e05bc70a9312240809aafd4cec23a658e..1cbc28961f73baffcb21a768c889c9a8878e5cdb 100644 --- a/src/mpl2mpl/src/reflection_analysis.cpp +++ b/src/mpl2mpl/src/reflection_analysis.cpp @@ -1219,10 +1219,10 @@ void ReflectionAnalysis::GenAnnotation(std::map &idxNumMap, std::strin PragmaKind paragKind, const std::string ¶gName, TyIdx fieldTypeIdx, std::map *paramnumArray, int *paramIndex) { int annoNum = 0; - std::string cmpString = ""; for (MIRPragma *prag : classType.GetPragmaVec()) { - cmpString = (paragKind == kPragmaVar) ? NameMangler::DecodeName(GlobalTables::GetStrTable().GetStringFromStrIdx( - prag->GetStrIdx())) : GlobalTables::GetStrTable().GetStringFromStrIdx(prag->GetStrIdx()); + std::string cmpString = (paragKind == kPragmaVar) ? NameMangler::DecodeName( + GlobalTables::GetStrTable().GetStringFromStrIdx(prag->GetStrIdx())) : + GlobalTables::GetStrTable().GetStringFromStrIdx(prag->GetStrIdx()); bool validTypeFlag = false; if (prag->GetTyIdxEx() == fieldTypeIdx || fieldTypeIdx == invalidIdx) { validTypeFlag = true;