From 3a1d37d04c02590b679583d8fa4dc5f502b57afd Mon Sep 17 00:00:00 2001 From: Wen HU Date: Thu, 26 May 2022 08:46:29 -0400 Subject: [PATCH 1/2] restore enable generating cfi directives for C --- src/mapleall/maple_be/include/cg/aarch64/aarch64_phases.def | 2 +- src/mapleall/maple_be/include/cg/cgfunc.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mapleall/maple_be/include/cg/aarch64/aarch64_phases.def b/src/mapleall/maple_be/include/cg/aarch64/aarch64_phases.def index a3a74d7b2f..34f20fd47b 100644 --- a/src/mapleall/maple_be/include/cg/aarch64/aarch64_phases.def +++ b/src/mapleall/maple_be/include/cg/aarch64/aarch64_phases.def @@ -63,7 +63,7 @@ ADDTARGETPHASE("postcfgo", CGOptions::DoCFGO()); ADDTARGETPHASE("cgpostpeephole", CGOptions::DoPeephole()) ADDTARGETPHASE("peephole", CGOptions::DoPeephole()) - ADDTARGETPHASE("gencfi", !GetMIRModule()->IsCModule() || GetMIRModule()->IsWithDbgInfo()); + ADDTARGETPHASE("gencfi", true); ADDTARGETPHASE("yieldpoint", GetMIRModule()->IsJavaModule() && CGOptions::IsInsertYieldPoint()); ADDTARGETPHASE("scheduling", CGOptions::DoSchedule()); ADDTARGETPHASE("alignanalysis", GetMIRModule()->IsCModule() && CGOptions::DoAlignAnalysis()); diff --git a/src/mapleall/maple_be/include/cg/cgfunc.h b/src/mapleall/maple_be/include/cg/cgfunc.h index 1994ece015..a2abd60c7c 100644 --- a/src/mapleall/maple_be/include/cg/cgfunc.h +++ b/src/mapleall/maple_be/include/cg/cgfunc.h @@ -1083,7 +1083,7 @@ class CGFunc { virtual InsnVisitor *NewInsnModifier() = 0; bool GenCfi() const { - return (mirModule.GetSrcLang() != kSrcLangC) || mirModule.IsWithDbgInfo(); + return true; } MapleVector &GetDbgCallFrameLocations() { -- Gitee From 4d6a576b23c90364159328eb51fa798d045fc13c Mon Sep 17 00:00:00 2001 From: William Chen Date: Thu, 2 Jun 2022 10:04:10 -0700 Subject: [PATCH 2/2] Fixes to optimizations for gen cfi --- .../maple_be/include/cg/aarch64/aarch64_proepilog.h | 7 +++++++ src/mapleall/maple_be/src/cg/aarch64/aarch64_proepilog.cpp | 5 ++++- src/mapleall/maple_be/src/cg/cfgo.cpp | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/mapleall/maple_be/include/cg/aarch64/aarch64_proepilog.h b/src/mapleall/maple_be/include/cg/aarch64/aarch64_proepilog.h index 3769bf00c1..a14cf49008 100644 --- a/src/mapleall/maple_be/include/cg/aarch64/aarch64_proepilog.h +++ b/src/mapleall/maple_be/include/cg/aarch64/aarch64_proepilog.h @@ -92,11 +92,18 @@ class AArch64GenProEpilog : public GenProEpilog { BB *GetCurTailcallExitBB() { return curTailcallExitBB; } + void SetFastPathReturnBB(BB *bb) { + fastPathReturnBB = bb; + } + BB *GetFastPathReturnBB() { + return fastPathReturnBB; + } MapleAllocator tmpAlloc; static constexpr const int32 kOffset8MemPos = 8; static constexpr const int32 kOffset16MemPos = 16; MapleMap> exitBB2CallSitesMap; BB* curTailcallExitBB = nullptr; + BB* fastPathReturnBB = nullptr; bool useFP = true; /* frame pointer(x29) is available as a general-purpose register if useFP is set as false */ AArch64reg stackBaseReg = RFP; diff --git a/src/mapleall/maple_be/src/cg/aarch64/aarch64_proepilog.cpp b/src/mapleall/maple_be/src/cg/aarch64/aarch64_proepilog.cpp index 66b7c3f44c..8ea922dac1 100644 --- a/src/mapleall/maple_be/src/cg/aarch64/aarch64_proepilog.cpp +++ b/src/mapleall/maple_be/src/cg/aarch64/aarch64_proepilog.cpp @@ -841,6 +841,7 @@ BB *AArch64GenProEpilog::IsolateFastPath(BB &bb) { tgtBB->GetPrev()->SetNext(tgtBB->GetNext()); tgtBB->GetNext()->SetPrev(tgtBB->GetPrev()); } + SetFastPathReturnBB(tgtBB); return coldBB; } @@ -2013,7 +2014,9 @@ void AArch64GenProEpilog::Run() { } for (auto *exitBB : cgFunc.GetExitBBsVec()) { - GenerateEpilog(*exitBB); + if (GetFastPathReturnBB() != exitBB) { + GenerateEpilog(*exitBB); + } } if (cgFunc.GetFunction().IsJava()) { diff --git a/src/mapleall/maple_be/src/cg/cfgo.cpp b/src/mapleall/maple_be/src/cg/cfgo.cpp index e57e75f853..197d20082e 100644 --- a/src/mapleall/maple_be/src/cg/cfgo.cpp +++ b/src/mapleall/maple_be/src/cg/cfgo.cpp @@ -37,7 +37,7 @@ using namespace maple; void CFGOptimizer::InitOptimizePatterns() { /* Initialize cfg optimization patterns */ - diffPassPatterns.emplace_back(memPool->New(*cgFunc)); +// diffPassPatterns.emplace_back(memPool->New(*cgFunc)); diffPassPatterns.emplace_back(memPool->New(*cgFunc)); diffPassPatterns.emplace_back(memPool->New(*cgFunc)); diffPassPatterns.emplace_back(memPool->New(*cgFunc)); -- Gitee