From 5ec764686e4a764f6df339ed4651ba37f5102742 Mon Sep 17 00:00:00 2001 From: duomingliang Date: Mon, 11 Aug 2025 17:17:03 +0800 Subject: [PATCH] fix code diff Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/ICSEGC Description: fix code diff Signed-off-by: duomingliang Change-Id: Ia25cea9a1f20a44e52308a830e67048a26e3f47a --- .../maple/maple_be/include/cg/reg_alloc_lsra.h | 4 ++++ .../maple_be/src/cg/aarch64/aarch64_cgfunc.cpp | 14 ++++---------- .../maple_be/src/cg/aarch64/aarch64_emitter.cpp | 5 ++--- .../maple_be/src/cg/aarch64/aarch64_proepilog.cpp | 4 ++-- .../codegen/maple/maple_be/src/cg/cg_options.cpp | 2 +- .../maple/maple_be/src/cg/cg_phasemanager.cpp | 6 ------ .../compiler/codegen/maple/maple_ir/include/cmpl.h | 7 +++---- .../codegen/maple/maple_ir/include/global_tables.h | 8 ++++++-- .../maple/maple_ir/include/metadata_layout.h | 3 +-- .../codegen/maple/maple_util/include/mpl_logging.h | 12 +----------- .../codegen/maple/maple_util/src/namemangler.cpp | 12 ++++++------ .../compiler/codegen/maple/test/cl_ut_test.cpp | 2 +- 12 files changed, 31 insertions(+), 48 deletions(-) diff --git a/ecmascript/compiler/codegen/maple/maple_be/include/cg/reg_alloc_lsra.h b/ecmascript/compiler/codegen/maple/maple_be/include/cg/reg_alloc_lsra.h index cf4175a34c..e4820b7919 100644 --- a/ecmascript/compiler/codegen/maple/maple_be/include/cg/reg_alloc_lsra.h +++ b/ecmascript/compiler/codegen/maple/maple_be/include/cg/reg_alloc_lsra.h @@ -21,6 +21,10 @@ #include "loop.h" namespace maplebe { +#ifdef RA_PERF_ANALYSIS +extern void printLSRATime(); +#endif + class LSRALinearScanRegAllocator : public RegAllocator { class LinearRange { public: diff --git a/ecmascript/compiler/codegen/maple/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp b/ecmascript/compiler/codegen/maple/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp index 847fae00a7..f552ac98dc 100644 --- a/ecmascript/compiler/codegen/maple/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp +++ b/ecmascript/compiler/codegen/maple/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp @@ -987,9 +987,7 @@ Operand *AArch64CGFunc::SelectFloatConst(MIRFloatConst &floatConst, const BaseNo PrimType stype = floatConst.GetType().GetPrimType(); int32 val = floatConst.GetIntValue(); /* according to aarch64 encoding format, convert int to float expression */ - Operand *result; - result = HandleFmovImm(stype, val, floatConst, parent); - return result; + return HandleFmovImm(stype, val, floatConst, parent); } Operand *AArch64CGFunc::SelectDoubleConst(MIRDoubleConst &doubleConst, const BaseNode &parent) @@ -997,9 +995,7 @@ Operand *AArch64CGFunc::SelectDoubleConst(MIRDoubleConst &doubleConst, const Bas PrimType stype = doubleConst.GetType().GetPrimType(); int64 val = doubleConst.GetIntValue(); /* according to aarch64 encoding format, convert int to float expression */ - Operand *result; - result = HandleFmovImm(stype, val, doubleConst, parent); - return result; + return HandleFmovImm(stype, val, doubleConst, parent); } /* @@ -3814,8 +3810,7 @@ MemOperand &AArch64CGFunc::GetOrCreateMemOpnd(const MIRSymbol &symbol, int64 off } } else { Operand *offOpnd = (it->second)->GetOffset(); - DEBUG_ASSERT(static_cast(offOpnd) != nullptr, - "static cast of offOpnd should not be nullptr"); + DEBUG_ASSERT(offOpnd != nullptr, "offOpnd should not be nullptr"); if (((static_cast(offOpnd))->GetOffsetValue() == (stOffset + offset)) && (it->second->GetSize() == size)) { return *(it->second); @@ -3848,8 +3843,7 @@ MemOperand &AArch64CGFunc::GetOrCreateMemOpnd(const MIRSymbol &symbol, int64 off } if (symLoc->GetMemSegment()->GetMemSegmentKind() == kMsArgsStkPassed && MemOperand::IsPIMMOffsetOutOfRange(totalOffset, size)) { - ImmOperand *offsetOprand; - offsetOprand = &CreateImmOperand(totalOffset, k64BitSize, true, kUnAdjustVary); + ImmOperand *offsetOprand = &CreateImmOperand(totalOffset, k64BitSize, true, kUnAdjustVary); Operand *resImmOpnd = &SelectCopy(*offsetOprand, PTY_i64, PTY_i64); return *CreateMemOperand(MemOperand::kAddrModeBOrX, size, *baseOpnd, static_cast(*resImmOpnd), nullptr, symbol, true); diff --git a/ecmascript/compiler/codegen/maple/maple_be/src/cg/aarch64/aarch64_emitter.cpp b/ecmascript/compiler/codegen/maple/maple_be/src/cg/aarch64/aarch64_emitter.cpp index dab46c41f2..8e21adcbc9 100644 --- a/ecmascript/compiler/codegen/maple/maple_be/src/cg/aarch64/aarch64_emitter.cpp +++ b/ecmascript/compiler/codegen/maple/maple_be/src/cg/aarch64/aarch64_emitter.cpp @@ -757,10 +757,9 @@ void AArch64AsmEmitter::EmitAdrpLabel(Emitter &emitter, const Insn &insn) const (void)emitter.Emit("\t").Emit("adrp").Emit("\t"); opnd0->Accept(visitor); (void)emitter.Emit(", "); - char *idx; CHECK_NULL_FATAL(Globals::GetInstance()->GetBECommon()->GetMIRModule().CurFunction()); - idx = - strdup(std::to_string(Globals::GetInstance()->GetBECommon()->GetMIRModule().CurFunction()->GetPuidx()).c_str()); + char *idx = strdup(std::to_string( + Globals::GetInstance()->GetBECommon()->GetMIRModule().CurFunction()->GetPuidx()).c_str()); CHECK_FATAL(idx != nullptr, "strdup failed"); (void)emitter.Emit(".L.").Emit(idx).Emit("__").Emit(lidx).Emit("\n"); diff --git a/ecmascript/compiler/codegen/maple/maple_be/src/cg/aarch64/aarch64_proepilog.cpp b/ecmascript/compiler/codegen/maple/maple_be/src/cg/aarch64/aarch64_proepilog.cpp index d94bfbc6dc..b3b4f2f3d2 100644 --- a/ecmascript/compiler/codegen/maple/maple_be/src/cg/aarch64/aarch64_proepilog.cpp +++ b/ecmascript/compiler/codegen/maple/maple_be/src/cg/aarch64/aarch64_proepilog.cpp @@ -768,8 +768,8 @@ void AArch64GenProEpilog::AppendInstructionDeallocateCallFrameDebug(AArch64reg r cgFunc.GetCurBB()->AppendInsn(deallocInsn); } } else { - Operand *o2; - o2 = aarchCGFunc.CreateStackMemOpnd(RSP, static_cast(fpToSpDistance), GetPointerBitSize()); + Operand *o2 = + aarchCGFunc.CreateStackMemOpnd(RSP, static_cast(fpToSpDistance), GetPointerBitSize()); if (fpToSpDistance > kStpLdpImm64UpperBound) { (void)AppendInstructionForAllocateOrDeallocateCallFrame(fpToSpDistance, reg0, reg1, rty, false); } else { diff --git a/ecmascript/compiler/codegen/maple/maple_be/src/cg/cg_options.cpp b/ecmascript/compiler/codegen/maple/maple_be/src/cg/cg_options.cpp index 95ce1491bc..85d198623e 100644 --- a/ecmascript/compiler/codegen/maple/maple_be/src/cg/cg_options.cpp +++ b/ecmascript/compiler/codegen/maple/maple_be/src/cg/cg_options.cpp @@ -15,7 +15,7 @@ #include "driver_options.h" -#include +#include namespace opts::cg { diff --git a/ecmascript/compiler/codegen/maple/maple_be/src/cg/cg_phasemanager.cpp b/ecmascript/compiler/codegen/maple/maple_be/src/cg/cg_phasemanager.cpp index 4a05dcdbbd..b8f52ec780 100644 --- a/ecmascript/compiler/codegen/maple/maple_be/src/cg/cg_phasemanager.cpp +++ b/ecmascript/compiler/codegen/maple/maple_be/src/cg/cg_phasemanager.cpp @@ -129,11 +129,6 @@ void CgFuncPM::PostOutPut(MIRModule &m) } /* =================== new phase manager =================== */ -#ifdef RA_PERF_ANALYSIS -extern void printLSRATime(); -extern void printRATime(); -#endif - bool CgFuncPM::PhaseRun(MIRModule &m) { // registry target based on build, cgfunc, emitter need to be registried. @@ -217,7 +212,6 @@ bool CgFuncPM::PhaseRun(MIRModule &m) #ifdef RA_PERF_ANALYSIS if (cgOptions->IsEnableTimePhases()) { printLSRATime(); - printRATime(); } #endif } else { diff --git a/ecmascript/compiler/codegen/maple/maple_ir/include/cmpl.h b/ecmascript/compiler/codegen/maple/maple_ir/include/cmpl.h index 6271fdb9f9..264ef4facb 100644 --- a/ecmascript/compiler/codegen/maple/maple_ir/include/cmpl.h +++ b/ecmascript/compiler/codegen/maple/maple_ir/include/cmpl.h @@ -27,7 +27,6 @@ #include "mir_module.h" namespace maple { -extern char appArray[]; constexpr uint32 kTwoBitVectors = 2; struct MirFuncT { // 28B uint16 frameSize; @@ -62,8 +61,8 @@ struct MirFuncT { // 28B // a dynamic memory block that needs reference // count; the bitvector's size is given by // BlockSize2BitvectorSize(frameSize) - // uint16 numlabels; // removed. label table size - // StmtNode **lbl2stmt; // lbl2stmt table, removed + // uint16 numlabels // removed. label table size + // StmtNode **lbl2stmt // lbl2stmt table, removed // the first statement immediately follow MirFuncT // since it starts with expression, BaseNodeT* is returned void *FirstInst() const @@ -147,7 +146,7 @@ union MirIntConstT { // currently in VM, only intconst are used. using MirConstT = MirIntConstT; -// + // It's a stacking of POD data structure to allow precise memory layout // control and emulate the inheritance relationship of corresponding C++ // data structures to keep the interface consistent (as much as possible). diff --git a/ecmascript/compiler/codegen/maple/maple_ir/include/global_tables.h b/ecmascript/compiler/codegen/maple/maple_ir/include/global_tables.h index 4fcc692b06..2c4279e25a 100644 --- a/ecmascript/compiler/codegen/maple/maple_ir/include/global_tables.h +++ b/ecmascript/compiler/codegen/maple/maple_ir/include/global_tables.h @@ -482,7 +482,7 @@ public: static std::unique_ptr Create() { - auto p = std::unique_ptr(new FPConstTable()); + auto p = std::make_unique(); p->PostInit(); return p; } @@ -504,6 +504,8 @@ private: MIRDoubleConst *infDoubleConst = nullptr; MIRDoubleConst *minusInfDoubleConst = nullptr; MIRDoubleConst *minusZeroDoubleConst = nullptr; + + friend std::unique_ptr std::make_unique(); }; class IntConstTable { @@ -516,7 +518,7 @@ public: static std::unique_ptr Create() { - auto p = std::unique_ptr(new IntConstTable()); + auto p = std::make_unique(); return p; } @@ -525,6 +527,8 @@ private: MIRIntConst *DoGetOrCreateIntConst(uint64 val, MIRType &type); std::shared_timed_mutex mtx; std::unordered_map intConstTable; + + friend std::unique_ptr std::make_unique(); }; // STypeNameTable is only used to store class and interface types. diff --git a/ecmascript/compiler/codegen/maple/maple_ir/include/metadata_layout.h b/ecmascript/compiler/codegen/maple/maple_ir/include/metadata_layout.h index e8a3dd5b1e..1c30f7b0d9 100644 --- a/ecmascript/compiler/codegen/maple/maple_ir/include/metadata_layout.h +++ b/ecmascript/compiler/codegen/maple/maple_ir/include/metadata_layout.h @@ -328,8 +328,7 @@ struct ClassMetadata { public: static inline intptr_t OffsetOfInitState() { - ClassMetadata *base = nullptr; - return reinterpret_cast(&(base->initState)); + return reinterpret_cast(nullptr); } uintptr_t GetInitStateRawValue() const diff --git a/ecmascript/compiler/codegen/maple/maple_util/include/mpl_logging.h b/ecmascript/compiler/codegen/maple/maple_util/include/mpl_logging.h index 4de056cfd4..0b9ac96ab3 100644 --- a/ecmascript/compiler/codegen/maple/maple_util/include/mpl_logging.h +++ b/ecmascript/compiler/codegen/maple/maple_util/include/mpl_logging.h @@ -138,7 +138,7 @@ public: ~LogInfo() { - fclose(outStream); + (void)fclose(outStream); } static std::ostream &MapleLogger(LogLevel level = kLlLog); @@ -184,16 +184,6 @@ private: #define DBG(tag, fmt, ...) #endif // IS_RELEASE_VERSION -// #ifdef LOG -// #undef LOG -// #endif -// #define LOG(tag, fmt, ...) \ -// do { \ -// if (PRINT_LEVEL_DEV <= kLlLog) { \ -// logInfo.EmitLogForDev(tag, kLlLog, __FILE__, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__); \ -// } \ -// } while (0) - #ifdef CHECK #undef CHECK #endif diff --git a/ecmascript/compiler/codegen/maple/maple_util/src/namemangler.cpp b/ecmascript/compiler/codegen/maple/maple_util/src/namemangler.cpp index 00a2988071..f1a1c563c2 100644 --- a/ecmascript/compiler/codegen/maple/maple_util/src/namemangler.cpp +++ b/ecmascript/compiler/codegen/maple/maple_util/src/namemangler.cpp @@ -91,20 +91,20 @@ std::string DecodeName(const std::string &name) c = static_cast(namePtr[i++]); uint8_t b4 = (c <= '9') ? c - '0' : c - 'a' + kNumLimit; uint32_t codepoint = (b1 << kCodeOffset3) | (b2 << kCodeOffset2) | (b3 << kCodeOffset) | b4; - str16 += (char16_t)codepoint; + str16 += static_cast(codepoint); unsigned int count = UTF16ToUTF8(str, str16, 1, false) >> 16; // shift 16 to get count if (count == 2) { // the count of str equal 2 to 4, use array to save the utf8 newName[pos++] = str[0]; newName[pos++] = str[1]; - } else if (count == 3) { + } else if (count == 3) { // the count of str equal 2 to 4, deal 3 new newName[pos++] = str[0]; newName[pos++] = str[1]; - newName[pos++] = str[2]; // 2 is index of third char - } else if (count == 4) { + newName[pos++] = str[2]; // 2 is index of third char + } else if (count == 4) { // the count of str equal 2 to 4 newName[pos++] = str[0]; newName[pos++] = str[1]; - newName[pos++] = str[2]; // 2 is index of third char - newName[pos++] = str[3]; // 3 is index of fourth char + newName[pos++] = str[2]; // 2 is index of third char + newName[pos++] = str[3]; // 3 is index of fourth char } } else { c = static_cast(namePtr[i++]); diff --git a/ecmascript/compiler/codegen/maple/test/cl_ut_test.cpp b/ecmascript/compiler/codegen/maple/test/cl_ut_test.cpp index 93f41ef87b..fbccd1ac68 100644 --- a/ecmascript/compiler/codegen/maple/test/cl_ut_test.cpp +++ b/ecmascript/compiler/codegen/maple/test/cl_ut_test.cpp @@ -33,7 +33,7 @@ static bool utCLTypeChecker = false; class UTCLType { public: UTCLType() = default; - UTCLType(const std::string &data) : data(data) {}; + explicit UTCLType(const std::string &data) : data(data) {}; std::string data; }; -- Gitee