Skip to content

Commit 5fb9e09

Browse files
committed
Fix assertion failure: ArgPartOffset == 0
1 parent b211289 commit 5fb9e09

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6803,7 +6803,7 @@ SDValue LoongArchTargetLowering::LowerFormalArguments(
68036803
else
68046804
analyzeInputArgs(MF, CCInfo, Ins, /*IsRet=*/false, CC_LoongArch);
68056805

6806-
for (unsigned i = 0, e = ArgLocs.size(); i != e; ++i) {
6806+
for (unsigned i = 0, e = ArgLocs.size(), InsIdx = 0; i != e; ++i, ++InsIdx) {
68076807
CCValAssign &VA = ArgLocs[i];
68086808
SDValue ArgValue;
68096809
// Passing f64 on LA32D with a soft float ABI must be handled as a special
@@ -6812,25 +6812,26 @@ SDValue LoongArchTargetLowering::LowerFormalArguments(
68126812
assert(VA.needsCustom());
68136813
ArgValue = unpackF64OnLA32DSoftABI(DAG, Chain, VA, ArgLocs[++i], DL);
68146814
} else if (VA.isRegLoc())
6815-
ArgValue = unpackFromRegLoc(DAG, Chain, VA, DL, Ins[i], *this);
6815+
ArgValue = unpackFromRegLoc(DAG, Chain, VA, DL, Ins[InsIdx], *this);
68166816
else
68176817
ArgValue = unpackFromMemLoc(DAG, Chain, VA, DL);
68186818
if (VA.getLocInfo() == CCValAssign::Indirect) {
68196819
// If the original argument was split and passed by reference, we need to
68206820
// load all parts of it here (using the same address).
68216821
InVals.push_back(DAG.getLoad(VA.getValVT(), DL, Chain, ArgValue,
68226822
MachinePointerInfo()));
6823-
unsigned ArgIndex = Ins[i].OrigArgIndex;
6824-
unsigned ArgPartOffset = Ins[i].PartOffset;
6823+
unsigned ArgIndex = Ins[InsIdx].OrigArgIndex;
6824+
unsigned ArgPartOffset = Ins[InsIdx].PartOffset;
68256825
assert(ArgPartOffset == 0);
6826-
while (i + 1 != e && Ins[i + 1].OrigArgIndex == ArgIndex) {
6826+
while (i + 1 != e && Ins[InsIdx + 1].OrigArgIndex == ArgIndex) {
68276827
CCValAssign &PartVA = ArgLocs[i + 1];
6828-
unsigned PartOffset = Ins[i + 1].PartOffset - ArgPartOffset;
6828+
unsigned PartOffset = Ins[InsIdx + 1].PartOffset - ArgPartOffset;
68296829
SDValue Offset = DAG.getIntPtrConstant(PartOffset, DL);
68306830
SDValue Address = DAG.getNode(ISD::ADD, DL, PtrVT, ArgValue, Offset);
68316831
InVals.push_back(DAG.getLoad(PartVA.getValVT(), DL, Chain, Address,
68326832
MachinePointerInfo()));
68336833
++i;
6834+
++InsIdx;
68346835
}
68356836
continue;
68366837
}

0 commit comments

Comments
 (0)