@@ -969,27 +969,34 @@ SDValue XtensaTargetLowering::LowerVASTART(SDValue Op,
969
969
SDValue XtensaTargetLowering::LowerVACOPY (SDValue Op, SelectionDAG &DAG) const {
970
970
// Size of the va_list_tag structure
971
971
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));
977
984
}
978
985
979
986
SDValue XtensaTargetLowering::LowerVAARG (SDValue Op, SelectionDAG &DAG) const {
980
987
SDNode *Node = Op.getNode ();
981
988
EVT VT = Node->getValueType (0 );
989
+ Type *Ty = VT.getTypeForEVT (*DAG.getContext ());
982
990
EVT PtrVT = Op.getValueType ();
983
991
SDValue InChain = Node->getOperand (0 );
984
992
SDValue VAListPtr = Node->getOperand (1 );
985
993
const Value *SV = cast<SrcValueSDNode>(Node->getOperand (2 ))->getValue ();
986
994
SDLoc DL (Node);
987
995
auto &TD = DAG.getDataLayout ();
988
- Align ArgAlignment = TD.getPrefTypeAlign (VT. getTypeForEVT (*DAG. getContext ()) );
996
+ Align ArgAlignment = TD.getABITypeAlign (Ty );
989
997
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 );
993
1000
994
1001
// va_stk
995
1002
SDValue VAStack =
0 commit comments