From 29dc8a2bdc5cc765e6f4afb9e35087f53d812adf Mon Sep 17 00:00:00 2001 From: Fred Chow Date: Mon, 29 Nov 2021 17:15:04 -0800 Subject: [PATCH] Fixed the TyIdx for the temporary created in LowerAsmStmt() When lpre promotes calls' return vector, need to check the var symbol due to multiple return values in asm --- src/mapleall/maple_be/src/be/lower.cpp | 7 ++++++- src/mapleall/maple_me/src/me_ssa_lpre.cpp | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/mapleall/maple_be/src/be/lower.cpp b/src/mapleall/maple_be/src/be/lower.cpp index 7baa233203..d02bca05e4 100644 --- a/src/mapleall/maple_be/src/be/lower.cpp +++ b/src/mapleall/maple_be/src/be/lower.cpp @@ -1068,7 +1068,12 @@ void CGLowerer::LowerAsmStmt(AsmNode *asmNode, BlockNode *newBlk) { continue; } // introduce a temporary to store the expression tree operand - MIRSymbol *st = mirModule.GetMIRBuilder()->CreateSymbol((TyIdx)opnd->GetPrimType(), NewAsmTempStrIdx(), + TyIdx tyIdxUsed = (TyIdx)opnd->GetPrimType(); + if (opnd->op == OP_iread) { + IreadNode *ireadNode = static_cast(opnd); + tyIdxUsed = ireadNode->GetType()->GetTypeIndex(); + } + MIRSymbol *st = mirModule.GetMIRBuilder()->CreateSymbol(tyIdxUsed, NewAsmTempStrIdx(), kStVar, kScAuto, mirModule.CurFunction(), kScopeLocal); DassignNode *dass = mirModule.GetMIRBuilder()->CreateStmtDassign(*st, 0, opnd); diff --git a/src/mapleall/maple_me/src/me_ssa_lpre.cpp b/src/mapleall/maple_me/src/me_ssa_lpre.cpp index 4fb6e013d4..e61384169b 100644 --- a/src/mapleall/maple_me/src/me_ssa_lpre.cpp +++ b/src/mapleall/maple_me/src/me_ssa_lpre.cpp @@ -100,8 +100,12 @@ void MeSSALPre::GenerateSaveRealOcc(MeRealOcc &realOcc) { MapleVector::iterator it = mustDefList->begin(); for (; it != mustDefList->end(); it++) { MustDefMeNode *mustDefMeNode = &(*it); + VarMeExpr *theLHS = static_cast(mustDefMeNode->GetLHS()); + // check that this var is the worklist item being worked on + if (static_cast(workCand->GetTheMeExpr())->GetOst() != theLHS->GetOst()) { + continue; + } if (regOrVar->GetMeOp() == kMeOpReg) { - auto *theLHS = static_cast(mustDefMeNode->GetLHS()); // change mustDef lhs to regOrVar mustDefMeNode->UpdateLHS(*regOrVar); EnterCandsForSSAUpdate(regOrVar->GetOstIdx(), *realOcc.GetMeStmt()->GetBB()); -- Gitee