@@ -2211,9 +2211,9 @@ void SelectionDAGBuilder::visitRet(const ReturnInst &I) {
2211
2211
Chain = DAG.getNode(ISD::TokenFactor, getCurSDLoc(),
2212
2212
MVT::Other, Chains);
2213
2213
} else if (I.getNumOperands() != 0) {
2214
- SmallVector<EVT , 4> ValueVTs ;
2215
- ComputeValueVTs(TLI, DL, I.getOperand(0)->getType(), ValueVTs );
2216
- unsigned NumValues = ValueVTs .size();
2214
+ SmallVector<Type * , 4> Types ;
2215
+ ComputeValueTypes( DL, I.getOperand(0)->getType(), Types );
2216
+ unsigned NumValues = Types .size();
2217
2217
if (NumValues) {
2218
2218
SDValue RetOp = getValue(I.getOperand(0));
2219
2219
@@ -2233,7 +2233,7 @@ void SelectionDAGBuilder::visitRet(const ReturnInst &I) {
2233
2233
bool RetInReg = F->getAttributes().hasRetAttr(Attribute::InReg);
2234
2234
2235
2235
for (unsigned j = 0; j != NumValues; ++j) {
2236
- EVT VT = ValueVTs [j];
2236
+ EVT VT = TLI.getValueType(DL, Types [j]) ;
2237
2237
2238
2238
if (ExtendKind != ISD::ANY_EXTEND && VT.isInteger())
2239
2239
VT = TLI.getTypeForExtReturn(Context, VT, ExtendKind);
@@ -2275,7 +2275,7 @@ void SelectionDAGBuilder::visitRet(const ReturnInst &I) {
2275
2275
for (unsigned i = 0; i < NumParts; ++i) {
2276
2276
Outs.push_back(ISD::OutputArg(Flags,
2277
2277
Parts[i].getValueType().getSimpleVT(),
2278
- VT, I.getOperand(0)->getType() , 0, 0));
2278
+ VT, Types[j] , 0, 0));
2279
2279
OutVals.push_back(Parts[i]);
2280
2280
}
2281
2281
}
@@ -10983,15 +10983,21 @@ std::pair<SDValue, SDValue>
10983
10983
TargetLowering::LowerCallTo(TargetLowering::CallLoweringInfo &CLI) const {
10984
10984
// Handle the incoming return values from the call.
10985
10985
CLI.Ins.clear();
10986
- SmallVector<EVT , 4> RetTys ;
10986
+ SmallVector<Type * , 4> RetOrigTys ;
10987
10987
SmallVector<TypeSize, 4> Offsets;
10988
10988
auto &DL = CLI.DAG.getDataLayout();
10989
- ComputeValueVTs(*this, DL, CLI.RetTy, RetTys, &Offsets);
10989
+ ComputeValueTypes(DL, CLI.RetTy, RetOrigTys, &Offsets);
10990
+
10991
+ SmallVector<EVT, 4> RetTys;
10992
+ for (Type *Ty : RetOrigTys)
10993
+ RetTys.push_back(getValueType(DL, Ty));
10990
10994
10991
10995
if (CLI.IsPostTypeLegalization) {
10992
10996
// If we are lowering a libcall after legalization, split the return type.
10997
+ SmallVector<Type *, 4> OldRetOrigTys;
10993
10998
SmallVector<EVT, 4> OldRetTys;
10994
10999
SmallVector<TypeSize, 4> OldOffsets;
11000
+ RetOrigTys.swap(OldRetOrigTys);
10995
11001
RetTys.swap(OldRetTys);
10996
11002
Offsets.swap(OldOffsets);
10997
11003
@@ -11001,6 +11007,7 @@ TargetLowering::LowerCallTo(TargetLowering::CallLoweringInfo &CLI) const {
11001
11007
MVT RegisterVT = getRegisterType(CLI.RetTy->getContext(), RetVT);
11002
11008
unsigned NumRegs = getNumRegisters(CLI.RetTy->getContext(), RetVT);
11003
11009
unsigned RegisterVTByteSZ = RegisterVT.getSizeInBits() / 8;
11010
+ RetOrigTys.append(NumRegs, OldRetOrigTys[i]);
11004
11011
RetTys.append(NumRegs, RegisterVT);
11005
11012
for (unsigned j = 0; j != NumRegs; ++j)
11006
11013
Offsets.push_back(TypeSize::getFixed(Offset + j * RegisterVTByteSZ));
@@ -11069,7 +11076,7 @@ TargetLowering::LowerCallTo(TargetLowering::CallLoweringInfo &CLI) const {
11069
11076
unsigned NumRegs = getNumRegistersForCallingConv(CLI.RetTy->getContext(),
11070
11077
CLI.CallConv, VT);
11071
11078
for (unsigned i = 0; i != NumRegs; ++i) {
11072
- ISD::InputArg Ret(Flags, RegisterVT, VT, CLI.RetTy ,
11079
+ ISD::InputArg Ret(Flags, RegisterVT, VT, RetOrigTys[I] ,
11073
11080
CLI.IsReturnValueUsed, ISD::InputArg::NoArgIndex, 0);
11074
11081
if (CLI.RetTy->isPointerTy()) {
11075
11082
Ret.Flags.setPointer();
@@ -11106,18 +11113,18 @@ TargetLowering::LowerCallTo(TargetLowering::CallLoweringInfo &CLI) const {
11106
11113
CLI.Outs.clear();
11107
11114
CLI.OutVals.clear();
11108
11115
for (unsigned i = 0, e = Args.size(); i != e; ++i) {
11109
- SmallVector<EVT , 4> ValueVTs ;
11110
- ComputeValueVTs(*this, DL, Args[i].Ty, ValueVTs );
11116
+ SmallVector<Type * , 4> ArgTys ;
11117
+ ComputeValueTypes( DL, Args[i].Ty, ArgTys );
11111
11118
// FIXME: Split arguments if CLI.IsPostTypeLegalization
11112
11119
Type *FinalType = Args[i].Ty;
11113
11120
if (Args[i].IsByVal)
11114
11121
FinalType = Args[i].IndirectType;
11115
11122
bool NeedsRegBlock = functionArgumentNeedsConsecutiveRegisters(
11116
11123
FinalType, CLI.CallConv, CLI.IsVarArg, DL);
11117
- for (unsigned Value = 0, NumValues = ValueVTs .size(); Value != NumValues;
11124
+ for (unsigned Value = 0, NumValues = ArgTys .size(); Value != NumValues;
11118
11125
++Value) {
11119
- EVT VT = ValueVTs [Value];
11120
- Type *ArgTy = VT.getTypeForEVT(CLI.RetTy->getContext() );
11126
+ Type *ArgTy = ArgTys [Value];
11127
+ EVT VT = getValueType(DL, ArgTy );
11121
11128
SDValue Op = SDValue(Args[i].Node.getNode(),
11122
11129
Args[i].Node.getResNo() + Value);
11123
11130
ISD::ArgFlagsTy Flags;
@@ -11130,10 +11137,9 @@ TargetLowering::LowerCallTo(TargetLowering::CallLoweringInfo &CLI) const {
11130
11137
11131
11138
if (i >= CLI.NumFixedArgs)
11132
11139
Flags.setVarArg();
11133
- if (Args[i].Ty ->isPointerTy()) {
11140
+ if (ArgTy ->isPointerTy()) {
11134
11141
Flags.setPointer();
11135
- Flags.setPointerAddrSpace(
11136
- cast<PointerType>(Args[i].Ty)->getAddressSpace());
11142
+ Flags.setPointerAddrSpace(cast<PointerType>(ArgTy)->getAddressSpace());
11137
11143
}
11138
11144
if (Args[i].IsZExt)
11139
11145
Flags.setZExt();
@@ -11252,7 +11258,7 @@ TargetLowering::LowerCallTo(TargetLowering::CallLoweringInfo &CLI) const {
11252
11258
// For scalable vectors the scalable part is currently handled
11253
11259
// by individual targets, so we just use the known minimum size here.
11254
11260
ISD::OutputArg MyFlags(
11255
- Flags, Parts[j].getValueType().getSimpleVT(), VT, Args[i].Ty , i,
11261
+ Flags, Parts[j].getValueType().getSimpleVT(), VT, ArgTy , i,
11256
11262
j * Parts[j].getValueType().getStoreSize().getKnownMinValue());
11257
11263
if (NumParts > 1 && j == 0)
11258
11264
MyFlags.Flags.setSplit();
@@ -11645,26 +11651,24 @@ void SelectionDAGISel::LowerArguments(const Function &F) {
11645
11651
// Set up the incoming argument description vector.
11646
11652
for (const Argument &Arg : F.args()) {
11647
11653
unsigned ArgNo = Arg.getArgNo();
11648
- SmallVector<EVT , 4> ValueVTs ;
11649
- ComputeValueVTs(*TLI, DAG.getDataLayout(), Arg.getType(), ValueVTs );
11654
+ SmallVector<Type * , 4> Types ;
11655
+ ComputeValueTypes( DAG.getDataLayout(), Arg.getType(), Types );
11650
11656
bool isArgValueUsed = !Arg.use_empty();
11651
11657
unsigned PartBase = 0;
11652
11658
Type *FinalType = Arg.getType();
11653
11659
if (Arg.hasAttribute(Attribute::ByVal))
11654
11660
FinalType = Arg.getParamByValType();
11655
11661
bool NeedsRegBlock = TLI->functionArgumentNeedsConsecutiveRegisters(
11656
11662
FinalType, F.getCallingConv(), F.isVarArg(), DL);
11657
- for (unsigned Value = 0, NumValues = ValueVTs .size();
11658
- Value != NumValues; ++Value) {
11659
- EVT VT = ValueVTs [Value];
11660
- Type *ArgTy = VT.getTypeForEVT(*DAG.getContext() );
11663
+ for (unsigned Value = 0, NumValues = Types .size(); Value != NumValues ;
11664
+ ++Value) {
11665
+ Type *ArgTy = Types [Value];
11666
+ EVT VT = TLI->getValueType(DL, ArgTy );
11661
11667
ISD::ArgFlagsTy Flags;
11662
11668
11663
-
11664
- if (Arg.getType()->isPointerTy()) {
11669
+ if (ArgTy->isPointerTy()) {
11665
11670
Flags.setPointer();
11666
- Flags.setPointerAddrSpace(
11667
- cast<PointerType>(Arg.getType())->getAddressSpace());
11671
+ Flags.setPointerAddrSpace(cast<PointerType>(ArgTy)->getAddressSpace());
11668
11672
}
11669
11673
if (Arg.hasAttribute(Attribute::ZExt))
11670
11674
Flags.setZExt();
@@ -11768,7 +11772,7 @@ void SelectionDAGISel::LowerArguments(const Function &F) {
11768
11772
// are responsible for handling scalable vector arguments and
11769
11773
// return values.
11770
11774
ISD::InputArg MyFlags(
11771
- Flags, RegisterVT, VT, Arg.getType() , isArgValueUsed, ArgNo,
11775
+ Flags, RegisterVT, VT, ArgTy , isArgValueUsed, ArgNo,
11772
11776
PartBase + i * RegisterVT.getStoreSize().getKnownMinValue());
11773
11777
if (NumRegs > 1 && i == 0)
11774
11778
MyFlags.Flags.setSplit();
0 commit comments