@@ -1547,6 +1547,7 @@ SystemZTargetLowering::LowerCall(CallLoweringInfo &CLI,
15471547 bool IsVarArg = CLI.IsVarArg ;
15481548 MachineFunction &MF = DAG.getMachineFunction ();
15491549 EVT PtrVT = getPointerTy (MF.getDataLayout ());
1550+ LLVMContext &Ctx = *DAG.getContext ();
15501551
15511552 // Detect unsupported vector argument and return types.
15521553 if (Subtarget.hasVector ()) {
@@ -1556,7 +1557,7 @@ SystemZTargetLowering::LowerCall(CallLoweringInfo &CLI,
15561557
15571558 // Analyze the operands of the call, assigning locations to each operand.
15581559 SmallVector<CCValAssign, 16 > ArgLocs;
1559- SystemZCCState ArgCCInfo (CallConv, IsVarArg, MF, ArgLocs, *DAG. getContext () );
1560+ SystemZCCState ArgCCInfo (CallConv, IsVarArg, MF, ArgLocs, Ctx );
15601561 ArgCCInfo.AnalyzeCallOperands (Outs, CC_SystemZ);
15611562
15621563 // We don't support GuaranteedTailCallOpt, only automatically-detected
@@ -1581,14 +1582,25 @@ SystemZTargetLowering::LowerCall(CallLoweringInfo &CLI,
15811582
15821583 if (VA.getLocInfo () == CCValAssign::Indirect) {
15831584 // 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);
15851598 int FI = cast<FrameIndexSDNode>(SpillSlot)->getIndex ();
15861599 MemOpChains.push_back (
15871600 DAG.getStore (Chain, DL, ArgValue, SpillSlot,
15881601 MachinePointerInfo::getFixedStack (MF, FI)));
15891602 // If the original argument was split (e.g. i128), we need
15901603 // to store all parts of it here (and pass just one address).
1591- unsigned ArgIndex = Outs[I].OrigArgIndex ;
15921604 assert (Outs[I].PartOffset == 0 );
15931605 while (I + 1 != E && Outs[I + 1 ].OrigArgIndex == ArgIndex) {
15941606 SDValue PartValue = OutVals[I + 1 ];
@@ -1598,6 +1610,8 @@ SystemZTargetLowering::LowerCall(CallLoweringInfo &CLI,
15981610 MemOpChains.push_back (
15991611 DAG.getStore (Chain, DL, PartValue, Address,
16001612 MachinePointerInfo::getFixedStack (MF, FI)));
1613+ assert ((PartOffset + PartValue.getValueType ().getStoreSize () <=
1614+ SlotVT.getStoreSize ()) && " Not enough space for argument part!" );
16011615 ++I;
16021616 }
16031617 ArgValue = SpillSlot;
@@ -1691,7 +1705,7 @@ SystemZTargetLowering::LowerCall(CallLoweringInfo &CLI,
16911705
16921706 // Assign locations to each value returned by this call.
16931707 SmallVector<CCValAssign, 16 > RetLocs;
1694- CCState RetCCInfo (CallConv, IsVarArg, MF, RetLocs, *DAG. getContext () );
1708+ CCState RetCCInfo (CallConv, IsVarArg, MF, RetLocs, Ctx );
16951709 RetCCInfo.AnalyzeCallResult (Ins, RetCC_SystemZ);
16961710
16971711 // Copy all of the result registers out of their specified physreg.
0 commit comments