@@ -1238,33 +1238,37 @@ void SelectionDAGBuilder::visitRet(const ReturnInst &I) {
1238
1238
unsigned NumValues = ValueVTs.size ();
1239
1239
if (NumValues) {
1240
1240
SDValue RetOp = getValue (I.getOperand (0 ));
1241
- for (unsigned j = 0 , f = NumValues; j != f; ++j) {
1242
- EVT VT = ValueVTs[j];
1243
1241
1244
- ISD::NodeType ExtendKind = ISD::ANY_EXTEND ;
1242
+ const Function *F = I. getParent ()-> getParent () ;
1245
1243
1246
- const Function *F = I.getParent ()->getParent ();
1247
- if (F->getAttributes ().hasAttribute (AttributeSet::ReturnIndex,
1248
- Attribute::SExt))
1249
- ExtendKind = ISD::SIGN_EXTEND;
1250
- else if (F->getAttributes ().hasAttribute (AttributeSet::ReturnIndex,
1251
- Attribute::ZExt))
1252
- ExtendKind = ISD::ZERO_EXTEND;
1244
+ ISD::NodeType ExtendKind = ISD::ANY_EXTEND;
1245
+ if (F->getAttributes ().hasAttribute (AttributeSet::ReturnIndex,
1246
+ Attribute::SExt))
1247
+ ExtendKind = ISD::SIGN_EXTEND;
1248
+ else if (F->getAttributes ().hasAttribute (AttributeSet::ReturnIndex,
1249
+ Attribute::ZExt))
1250
+ ExtendKind = ISD::ZERO_EXTEND;
1251
+
1252
+ LLVMContext &Context = F->getContext ();
1253
+ bool RetInReg = F->getAttributes ().hasAttribute (AttributeSet::ReturnIndex,
1254
+ Attribute::InReg);
1255
+
1256
+ for (unsigned j = 0 ; j != NumValues; ++j) {
1257
+ EVT VT = ValueVTs[j];
1253
1258
1254
1259
if (ExtendKind != ISD::ANY_EXTEND && VT.isInteger ())
1255
- VT = TLI.getTypeForExtArgOrReturn (*DAG. getContext () , VT, ExtendKind);
1260
+ VT = TLI.getTypeForExtArgOrReturn (Context , VT, ExtendKind);
1256
1261
1257
- unsigned NumParts = TLI.getNumRegisters (*DAG. getContext () , VT);
1258
- MVT PartVT = TLI.getRegisterType (*DAG. getContext () , VT);
1262
+ unsigned NumParts = TLI.getNumRegisters (Context , VT);
1263
+ MVT PartVT = TLI.getRegisterType (Context , VT);
1259
1264
SmallVector<SDValue, 4 > Parts (NumParts);
1260
1265
getCopyToParts (DAG, getCurSDLoc (),
1261
1266
SDValue (RetOp.getNode (), RetOp.getResNo () + j),
1262
1267
&Parts[0 ], NumParts, PartVT, &I, ExtendKind);
1263
1268
1264
1269
// 'inreg' on function refers to return value
1265
1270
ISD::ArgFlagsTy Flags = ISD::ArgFlagsTy ();
1266
- if (F->getAttributes ().hasAttribute (AttributeSet::ReturnIndex,
1267
- Attribute::InReg))
1271
+ if (RetInReg)
1268
1272
Flags.setInReg ();
1269
1273
1270
1274
// Propagate extension type if any
0 commit comments