From d87efc3a031497c58e899db8901280caf9b6c980 Mon Sep 17 00:00:00 2001 From: William Chen Date: Thu, 2 Jun 2022 10:04:10 -0700 Subject: [PATCH 1/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 From d932117b203eecd68cf70ba6d8adec793f094141 Mon Sep 17 00:00:00 2001 From: Wen HU Date: Thu, 2 Jun 2022 12:38:35 -0700 Subject: [PATCH 2/2] disalbe a cfgo pass when cfi gen is enabled --- src/mapleall/maple_be/src/cg/cfgo.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/mapleall/maple_be/src/cg/cfgo.cpp b/src/mapleall/maple_be/src/cg/cfgo.cpp index 197d20082e..b2554fa1dd 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)); -- Gitee