@@ -969,27 +969,34 @@ SDValue XtensaTargetLowering::LowerVASTART(SDValue Op,
969969SDValue XtensaTargetLowering::LowerVACOPY (SDValue Op, SelectionDAG &DAG) const {
970970 // Size of the va_list_tag structure
971971 constexpr unsigned VAListSize = 3 * 4 ;
972- return DAG.getMemcpy (
973- Op.getOperand (0 ), Op, Op.getOperand (1 ), Op.getOperand (2 ),
974- DAG.getConstant (VAListSize, SDLoc (Op), MVT::i32 ), Align (4 ),
975- /* isVolatile=*/ false , /* AlwaysInline=*/ false ,
976- /* CI=*/ nullptr , std::nullopt , MachinePointerInfo (), MachinePointerInfo ());
972+ SDValue Chain = Op.getOperand (0 );
973+ SDValue DstPtr = Op.getOperand (1 );
974+ SDValue SrcPtr = Op.getOperand (2 );
975+ const Value *DstSV = cast<SrcValueSDNode>(Op.getOperand (3 ))->getValue ();
976+ const Value *SrcSV = cast<SrcValueSDNode>(Op.getOperand (4 ))->getValue ();
977+ SDLoc DL (Op);
978+
979+ return DAG.getMemcpy (Chain, DL, DstPtr, SrcPtr,
980+ DAG.getConstant (VAListSize, SDLoc (Op), MVT::i32 ),
981+ Align (4 ), /* isVolatile*/ false , /* AlwaysInline*/ true ,
982+ /* CI=*/ nullptr , std::nullopt , MachinePointerInfo (DstSV),
983+ MachinePointerInfo (SrcSV));
977984}
978985
979986SDValue XtensaTargetLowering::LowerVAARG (SDValue Op, SelectionDAG &DAG) const {
980987 SDNode *Node = Op.getNode ();
981988 EVT VT = Node->getValueType (0 );
989+ Type *Ty = VT.getTypeForEVT (*DAG.getContext ());
982990 EVT PtrVT = Op.getValueType ();
983991 SDValue InChain = Node->getOperand (0 );
984992 SDValue VAListPtr = Node->getOperand (1 );
985993 const Value *SV = cast<SrcValueSDNode>(Node->getOperand (2 ))->getValue ();
986994 SDLoc DL (Node);
987995 auto &TD = DAG.getDataLayout ();
988- Align ArgAlignment = TD.getPrefTypeAlign (VT. getTypeForEVT (*DAG. getContext ()) );
996+ Align ArgAlignment = TD.getABITypeAlign (Ty );
989997 unsigned ArgAlignInBytes = ArgAlignment.value ();
990- unsigned ArgSizeInBytes =
991- TD.getTypeAllocSize (VT.getTypeForEVT (*DAG.getContext ()));
992- unsigned VASizeInBytes = (ArgSizeInBytes + 3 ) & 0x3 ;
998+ unsigned ArgSizeInBytes = TD.getTypeAllocSize (Ty);
999+ unsigned VASizeInBytes = llvm::alignTo (ArgSizeInBytes, 4 );
9931000
9941001 // va_stk
9951002 SDValue VAStack =
0 commit comments