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 3769bf00c1a4611eb9747adabf37c781f4f9351e..a14cf490089155e84a1c3ecc9a068604d34108b4 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 66b7c3f44c344a9c4da734900f8ecec45fd61184..8ea922dac145f9f797ba867fe9589fce25fc0bd9 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 e57e75f853bd006867e35eea5d6af983550bcbd0..b2554fa1dd7e47df2dc34540915400d1d1ce3d95 100644 --- a/src/mapleall/maple_be/src/cg/cfgo.cpp +++ b/src/mapleall/maple_be/src/cg/cfgo.cpp @@ -37,7 +37,11 @@ using namespace maple; void CFGOptimizer::InitOptimizePatterns() { /* Initialize cfg optimization patterns */ - diffPassPatterns.emplace_back(memPool->New(*cgFunc)); + + // disable the pass that conflicts with cfi + if (!cgFunc->GenCfi()) { + diffPassPatterns.emplace_back(memPool->New(*cgFunc)); + } diffPassPatterns.emplace_back(memPool->New(*cgFunc)); diffPassPatterns.emplace_back(memPool->New(*cgFunc)); diffPassPatterns.emplace_back(memPool->New(*cgFunc));