From 89a033e0e0234c69735130acdb330dff1f5300a9 Mon Sep 17 00:00:00 2001 From: Fred Chow Date: Mon, 16 May 2022 12:20:24 -0700 Subject: [PATCH] In CGLowerer::LowerStructReturn(), update nextStmt in it intead of relying on its caller to update nextStmt based on its return value --- src/mapleall/maple_be/src/be/lower.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/mapleall/maple_be/src/be/lower.cpp b/src/mapleall/maple_be/src/be/lower.cpp index 757e22ad10..af2669e130 100644 --- a/src/mapleall/maple_be/src/be/lower.cpp +++ b/src/mapleall/maple_be/src/be/lower.cpp @@ -1409,7 +1409,8 @@ static PrimType IsStructElementSame(MIRType *ty) { } #endif -// return true if successfully lowered; nextStmt is in/out +// return true if successfully lowered; nextStmt is in/out, and is made to point +// to its following statement if lowering of the struct return is successful bool CGLowerer::LowerStructReturn(BlockNode &newBlk, StmtNode *stmt, StmtNode *&nextStmt, bool &lvar, BlockNode *oldBlk) { if (!nextStmt) { @@ -1650,6 +1651,7 @@ bool CGLowerer::LowerStructReturn(BlockNode &newBlk, StmtNode *stmt, newBlk.AddStatement(aStmt); } } + nextStmt = nextStmt->GetNext(); // skip the dassign return true; } @@ -1833,9 +1835,8 @@ BlockNode *CGLowerer::LowerBlock(BlockNode &block) { case OP_icallassigned: { // pass the addr of lvar if this is a struct call assignment bool lvar = false; - if (LowerStructReturn(*newBlk, stmt, nextStmt, lvar, &block)) { - nextStmt = nextStmt->GetNext(); // skip dassign - } else { + // nextStmt could be changed by the call to LowerStructReturn + if (!LowerStructReturn(*newBlk, stmt, nextStmt, lvar, &block)) { newBlk->AppendStatementsFromBlock(*LowerCallAssignedStmt(*stmt, lvar)); } break; @@ -1852,6 +1853,7 @@ BlockNode *CGLowerer::LowerBlock(BlockNode &block) { case OP_call: case OP_icall: #if TARGARM32 || TARGAARCH64 || TARGRISCV64 || TARGX86_64 + // nextStmt could be changed by the call to LowerStructReturn LowerCallStmt(*stmt, nextStmt, *newBlk); #else LowerStmt(*stmt, *newBlk); -- Gitee