@@ -1547,6 +1547,7 @@ SystemZTargetLowering::LowerCall(CallLoweringInfo &CLI,
1547
1547
bool IsVarArg = CLI.IsVarArg ;
1548
1548
MachineFunction &MF = DAG.getMachineFunction ();
1549
1549
EVT PtrVT = getPointerTy (MF.getDataLayout ());
1550
+ LLVMContext &Ctx = *DAG.getContext ();
1550
1551
1551
1552
// Detect unsupported vector argument and return types.
1552
1553
if (Subtarget.hasVector ()) {
@@ -1556,7 +1557,7 @@ SystemZTargetLowering::LowerCall(CallLoweringInfo &CLI,
1556
1557
1557
1558
// Analyze the operands of the call, assigning locations to each operand.
1558
1559
SmallVector<CCValAssign, 16 > ArgLocs;
1559
- SystemZCCState ArgCCInfo (CallConv, IsVarArg, MF, ArgLocs, *DAG. getContext () );
1560
+ SystemZCCState ArgCCInfo (CallConv, IsVarArg, MF, ArgLocs, Ctx );
1560
1561
ArgCCInfo.AnalyzeCallOperands (Outs, CC_SystemZ);
1561
1562
1562
1563
// We don't support GuaranteedTailCallOpt, only automatically-detected
@@ -1581,14 +1582,25 @@ SystemZTargetLowering::LowerCall(CallLoweringInfo &CLI,
1581
1582
1582
1583
if (VA.getLocInfo () == CCValAssign::Indirect) {
1583
1584
// Store the argument in a stack slot and pass its address.
1584
- SDValue SpillSlot = DAG.CreateStackTemporary (Outs[I].ArgVT );
1585
+ unsigned ArgIndex = Outs[I].OrigArgIndex ;
1586
+ EVT SlotVT;
1587
+ if (I + 1 != E && Outs[I + 1 ].OrigArgIndex == ArgIndex) {
1588
+ // Allocate the full stack space for a promoted (and split) argument.
1589
+ Type *OrigArgType = CLI.Args [Outs[I].OrigArgIndex ].Ty ;
1590
+ EVT OrigArgVT = getValueType (MF.getDataLayout (), OrigArgType);
1591
+ MVT PartVT = getRegisterTypeForCallingConv (Ctx, CLI.CallConv , OrigArgVT);
1592
+ unsigned N = getNumRegistersForCallingConv (Ctx, CLI.CallConv , OrigArgVT);
1593
+ SlotVT = EVT::getIntegerVT (Ctx, PartVT.getSizeInBits () * N);
1594
+ } else {
1595
+ SlotVT = Outs[I].ArgVT ;
1596
+ }
1597
+ SDValue SpillSlot = DAG.CreateStackTemporary (SlotVT);
1585
1598
int FI = cast<FrameIndexSDNode>(SpillSlot)->getIndex ();
1586
1599
MemOpChains.push_back (
1587
1600
DAG.getStore (Chain, DL, ArgValue, SpillSlot,
1588
1601
MachinePointerInfo::getFixedStack (MF, FI)));
1589
1602
// If the original argument was split (e.g. i128), we need
1590
1603
// to store all parts of it here (and pass just one address).
1591
- unsigned ArgIndex = Outs[I].OrigArgIndex ;
1592
1604
assert (Outs[I].PartOffset == 0 );
1593
1605
while (I + 1 != E && Outs[I + 1 ].OrigArgIndex == ArgIndex) {
1594
1606
SDValue PartValue = OutVals[I + 1 ];
@@ -1598,6 +1610,8 @@ SystemZTargetLowering::LowerCall(CallLoweringInfo &CLI,
1598
1610
MemOpChains.push_back (
1599
1611
DAG.getStore (Chain, DL, PartValue, Address,
1600
1612
MachinePointerInfo::getFixedStack (MF, FI)));
1613
+ assert ((PartOffset + PartValue.getValueType ().getStoreSize () <=
1614
+ SlotVT.getStoreSize ()) && " Not enough space for argument part!" );
1601
1615
++I;
1602
1616
}
1603
1617
ArgValue = SpillSlot;
@@ -1691,7 +1705,7 @@ SystemZTargetLowering::LowerCall(CallLoweringInfo &CLI,
1691
1705
1692
1706
// Assign locations to each value returned by this call.
1693
1707
SmallVector<CCValAssign, 16 > RetLocs;
1694
- CCState RetCCInfo (CallConv, IsVarArg, MF, RetLocs, *DAG. getContext () );
1708
+ CCState RetCCInfo (CallConv, IsVarArg, MF, RetLocs, Ctx );
1695
1709
RetCCInfo.AnalyzeCallResult (Ins, RetCC_SystemZ);
1696
1710
1697
1711
// Copy all of the result registers out of their specified physreg.
0 commit comments