From 4df75bdd00d4d1ff586f02ec24f2b23f80ab632a Mon Sep 17 00:00:00 2001 From: William Chen Date: Mon, 21 Mar 2022 12:53:53 -0700 Subject: [PATCH] Check if curbb has any insn before adding comment to last insn --- src/mapleall/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/mapleall/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp b/src/mapleall/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp index bbc327e9fa..d5f2eaf5ae 100644 --- a/src/mapleall/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp +++ b/src/mapleall/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp @@ -1418,8 +1418,11 @@ void AArch64CGFunc::SelectRegassign(RegassignNode &stmt, Operand &opnd0) { ASSERT(regOpnd != nullptr, "null ptr check!"); SelectCopy(*regOpnd, dtype, opnd0, rhsType); if (GetCG()->GenerateVerboseCG()) { - GetCurBB()->GetLastInsn()->AppendComment(" regassign %" + std::to_string(pregIdx)); - GetCurBB()->GetLastInsn()->AppendComment("; "); + if (GetCurBB()->GetLastInsn()) { + GetCurBB()->GetLastInsn()->AppendComment(" regassign %" + std::to_string(pregIdx) + "; "); + } else if (GetCurBB()->GetPrev()->GetLastInsn()) { + GetCurBB()->GetPrev()->GetLastInsn()->AppendComment(" regassign %" + std::to_string(pregIdx) + "; "); + } } if ((Globals::GetInstance()->GetOptimLevel() == 0) && (pregIdx >= 0)) { -- Gitee