[llvm] [Mips] Add the missing judgment when processing function handleMFLOSlot (PR #121463)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 2 01:57:46 PST 2025
https://github.com/yingopq created https://github.com/llvm/llvm-project/pull/121463
In function handleMFLOSlot, we may get a variable LastInstInFunction with a value of true from function getNextMachineInstr and IInSlot may be null which would trigger an assert.
So we need to skip this case.
Fix #118223.
>From a6284051a54831ff350af408b5330625d2f369fd Mon Sep 17 00:00:00 2001
From: Ying Huang <ying.huang at oss.cipunited.com>
Date: Thu, 2 Jan 2025 04:50:05 -0500
Subject: [PATCH] [Mips] Add the missing judgment when processing function
handleMFLOSlot
In function handleMFLOSlot, we may get a variable LastInstInFunction
with a value of true from function getNextMachineInstr and IInSlot may
be null which would trigger an assert.
So we need to skip this case.
Fix #118223.
---
llvm/lib/Target/Mips/MipsBranchExpansion.cpp | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/Target/Mips/MipsBranchExpansion.cpp b/llvm/lib/Target/Mips/MipsBranchExpansion.cpp
index 80f3f1ec8090e0..9b28fcbca16db8 100644
--- a/llvm/lib/Target/Mips/MipsBranchExpansion.cpp
+++ b/llvm/lib/Target/Mips/MipsBranchExpansion.cpp
@@ -751,9 +751,8 @@ bool MipsBranchExpansion::handleMFLOSlot(Pred Predicate, Safe SafeInSlot) {
for (MachineFunction::iterator FI = MFp->begin(); FI != MFp->end(); ++FI) {
for (Iter I = FI->begin(); I != FI->end(); ++I) {
- if (!Predicate(*I) && !hasPendingMFLO) {
+ if (!Predicate(*I) && !hasPendingMFLO)
continue;
- }
Iter IInSlot;
bool LastInstInFunction =
@@ -767,6 +766,8 @@ bool MipsBranchExpansion::handleMFLOSlot(Pred Predicate, Safe SafeInSlot) {
std::pair<Iter, bool> Res = getNextMachineInstr(std::next(I), &*FI);
LastInstInFunction |= Res.second;
IInSlot = Res.first;
+ if (LastInstInFunction)
+ continue;
if (!SafeInSlot(*IInSlot, *I)) {
Changed = true;
TII->insertNop(*(I->getParent()), std::next(I), I->getDebugLoc())
More information about the llvm-commits
mailing list