From 6cec3d0bd9d4621d8e7780765124baef871040fa Mon Sep 17 00:00:00 2001 From: Wen HU Date: Thu, 14 Apr 2022 16:39:02 -0400 Subject: [PATCH 1/3] 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 5243ce26bb..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()); + 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 f99eafc57b..749bbe72fe 100644 --- a/src/mapleall/maple_be/include/cg/cgfunc.h +++ b/src/mapleall/maple_be/include/cg/cgfunc.h @@ -1075,7 +1075,7 @@ class CGFunc { virtual InsnVisitor *NewInsnModifier() = 0; bool GenCfi() const { - return (mirModule.GetSrcLang() != kSrcLangC); + return true; } MapleVector &GetDbgCallFrameLocations() { -- Gitee From d7c737522477672fa1594cfeed184bf17b967fb4 Mon Sep 17 00:00:00 2001 From: Alfred Huang Date: Sat, 21 May 2022 18:57:46 -0700 Subject: [PATCH 2/3] Fixed deletion of CFI directives in tailcall opt. --- src/mapleall/maple_be/src/cg/aarch64/aarch64_proepilog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 59e44f6e28..ed5d9a0507 100644 --- a/src/mapleall/maple_be/src/cg/aarch64/aarch64_proepilog.cpp +++ b/src/mapleall/maple_be/src/cg/aarch64/aarch64_proepilog.cpp @@ -1943,7 +1943,7 @@ void AArch64GenProEpilog::ConvertToTailCalls(std::set &callInsnsMap) { CHECK_FATAL(0, "Tailcall in incorrect block"); } FOR_BB_INSNS_SAFE(insn, fromBB, next) { - if (insn->IsMachineInstruction() && insn->GetMachineOpcode() != MOP_xret) { + if (insn->IsCfiInsn() || (insn->IsMachineInstruction() && insn->GetMachineOpcode() != MOP_xret)) { Insn *newInsn = cgFunc.GetTheCFG()->CloneInsn(*insn); newInsn->SetDoNotRemove(true); toBB->InsertInsnBefore(*callInsn, *newInsn); -- Gitee From 36b51c9c3004269bf14b3cf46d55ebcb62d381a5 Mon Sep 17 00:00:00 2001 From: Wen HU Date: Wed, 25 May 2022 19:41:48 -0700 Subject: [PATCH 3/3] enable cfi for C only during -g for now --- 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 34f20fd47b..a3a74d7b2f 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", true); + ADDTARGETPHASE("gencfi", !GetMIRModule()->IsCModule() || GetMIRModule()->IsWithDbgInfo()); 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 749bbe72fe..9c6d229b24 100644 --- a/src/mapleall/maple_be/include/cg/cgfunc.h +++ b/src/mapleall/maple_be/include/cg/cgfunc.h @@ -1075,7 +1075,7 @@ class CGFunc { virtual InsnVisitor *NewInsnModifier() = 0; bool GenCfi() const { - return true; + return (mirModule.GetSrcLang() != kSrcLangC) || mirModule.IsWithDbgInfo(); } MapleVector &GetDbgCallFrameLocations() { -- Gitee