diff --git a/src/mapleall/maple_be/src/cg/cgfunc.cpp b/src/mapleall/maple_be/src/cg/cgfunc.cpp index e19c9080df951ce373993fb9146d617294047b7f..42bc05b0f5544d9051829c7922516c0b344cd384 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(); } diff --git a/src/mapleall/maple_be/src/cg/emit.cpp b/src/mapleall/maple_be/src/cg/emit.cpp index b7d2c9aacf789a5eb03b57540093cf4ede651bcf..31d6f318169e32d760280affcf6f371c992212bb 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) {