From 07f86e115cf402c21e6eaf91274b09c30209ed8e Mon Sep 17 00:00:00 2001 From: Wen HU Date: Wed, 20 Jul 2022 08:35:36 -0700 Subject: [PATCH 1/2] keep the unreachable code for scope labels with -g --- src/mapleall/maple_be/src/cg/cgfunc.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mapleall/maple_be/src/cg/cgfunc.cpp b/src/mapleall/maple_be/src/cg/cgfunc.cpp index e19c9080df..42bc05b0f5 100644 --- a/src/mapleall/maple_be/src/cg/cgfunc.cpp +++ b/src/mapleall/maple_be/src/cg/cgfunc.cpp @@ -2135,7 +2135,10 @@ void CGFunc::HandleFunction() { MarkCleanupEntryBB(); DetermineReturnTypeofCall(); theCFG->MarkLabelTakenBB(); - theCFG->UnreachCodeAnalysis(); + /* keep the unreachable code for scope labels */ + if (!GetCG()->GetCGOptions().WithDwarf()) { + theCFG->UnreachCodeAnalysis(); + } if (mirModule.GetSrcLang() == kSrcLangC) { theCFG->WontExitAnalysis(); } -- Gitee From a01c03429a8114b250c8e22412c65e6837a311de Mon Sep 17 00:00:00 2001 From: Wen HU Date: Wed, 20 Jul 2022 08:37:14 -0700 Subject: [PATCH 2/2] emit low/high pc --- src/mapleall/maple_be/src/cg/emit.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/mapleall/maple_be/src/cg/emit.cpp b/src/mapleall/maple_be/src/cg/emit.cpp index b7d2c9aacf..31d6f31816 100644 --- a/src/mapleall/maple_be/src/cg/emit.cpp +++ b/src/mapleall/maple_be/src/cg/emit.cpp @@ -3127,11 +3127,8 @@ void Emitter::EmitDIAttrValue(DBGDie *die, DBGDieAttr *attr, DwAt attrName, DwTa } } else if (tagName == DW_TAG_lexical_block) { auto i = static_cast(attr->GetU()); - if (GetCG()->GetMIRModule()->GetDbgInfo()->IsScopeIdEmited(lastMIRFunc, i)) { - (void)Emit(".LScp." + std::to_string(i) + "E-.LScp." + std::to_string(i) + "B"); - } else { - (void)Emit(0); - } + CHECK_FATAL(GetCG()->GetMIRModule()->GetDbgInfo()->IsScopeIdEmited(lastMIRFunc, i), "missing scope label"); + (void)Emit(".LScp." + std::to_string(i) + "E-.LScp." + std::to_string(i) + "B"); } } else { EmitHexUnsigned(static_cast(static_cast(attr->GetI()))); @@ -3184,11 +3181,8 @@ void Emitter::EmitDIAttrValue(DBGDie *die, DBGDieAttr *attr, DwAt attrName, DwTa res->Emit(*this, nullptr); } else if (tagName == DW_TAG_lexical_block) { auto i = static_cast(attr->GetU()); - if (GetCG()->GetMIRModule()->GetDbgInfo()->IsScopeIdEmited(lastMIRFunc, i)) { - (void)Emit(".LScp." + std::to_string(i) + "B"); - } else { - (void)Emit(0); - } + CHECK_FATAL(GetCG()->GetMIRModule()->GetDbgInfo()->IsScopeIdEmited(lastMIRFunc, i), "missing scope label"); + (void)Emit(".LScp." + std::to_string(i) + "B"); } } else if (attrName == DW_AT_high_pc) { if (tagName == DW_TAG_compile_unit) { -- Gitee