From 1efd37d531b1f0b6df1bc8cc2d90ea8096160d51 Mon Sep 17 00:00:00 2001 From: linma Date: Mon, 27 Dec 2021 12:15:28 -0800 Subject: [PATCH] Fix bug in SimplifyCFG : check bb status when moving stmts from BB to another BB --- src/mapleall/maple_me/src/simplifyCFG.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mapleall/maple_me/src/simplifyCFG.cpp b/src/mapleall/maple_me/src/simplifyCFG.cpp index f166de5706..672eaa876f 100644 --- a/src/mapleall/maple_me/src/simplifyCFG.cpp +++ b/src/mapleall/maple_me/src/simplifyCFG.cpp @@ -1140,14 +1140,16 @@ BB *SimplifyCFG::MergeSuccIntoPred(BB *pred, BB *succ) { bool isSuccEmpty = IsMeEmptyBB(*succ) && IsMplEmptyBB(*succ); if (!isSuccEmpty) { if (isMeIR) { - for (MeStmt *stmt = succ->GetFirstMe(); stmt != nullptr;) { + MeStmt *stmt = succ->GetFirstMe(); + while (stmt && (!succ->IsMeStmtEmpty())) { MeStmt *next = stmt->GetNextMeStmt(); succ->RemoveMeStmt(stmt); pred->AddMeStmtLast(stmt); stmt = next; } } else { - for (StmtNode *stmt = &succ->GetFirst(); stmt != nullptr;) { + StmtNode *stmt = &succ->GetFirst(); + while (stmt && (!succ->IsEmpty())) { StmtNode *next = stmt->GetNext(); succ->RemoveStmtNode(stmt); pred->AddStmtNode(stmt); -- Gitee