@@ -360,7 +360,8 @@ static void addIndirectResultAttributes(IRGenModule &IGM,
360
360
llvm::AttributeList &attrs,
361
361
unsigned paramIndex, bool allowSRet,
362
362
llvm::Type *storageType,
363
- const TypeInfo &typeInfo) {
363
+ const TypeInfo &typeInfo,
364
+ bool useInReg = false ) {
364
365
llvm::AttrBuilder b (IGM.getLLVMContext ());
365
366
b.addAttribute (llvm::Attribute::NoAlias);
366
367
// Bitwise takable value types are guaranteed not to capture
@@ -370,6 +371,8 @@ static void addIndirectResultAttributes(IRGenModule &IGM,
370
371
if (allowSRet) {
371
372
assert (storageType);
372
373
b.addStructRetAttr (storageType);
374
+ if (useInReg)
375
+ b.addAttribute (llvm::Attribute::InReg);
373
376
}
374
377
attrs = attrs.addParamAttributes (IGM.getLLVMContext (), paramIndex, b);
375
378
}
@@ -552,7 +555,7 @@ namespace {
552
555
553
556
private:
554
557
const TypeInfo &expand (SILParameterInfo param);
555
- llvm::Type *addIndirectResult (SILType resultType);
558
+ llvm::Type *addIndirectResult (SILType resultType, bool useInReg = false );
556
559
557
560
SILFunctionConventions getSILFuncConventions () const {
558
561
return SILFunctionConventions (FnType, IGM.getSILModule ());
@@ -611,11 +614,12 @@ namespace {
611
614
} // end namespace irgen
612
615
} // end namespace swift
613
616
614
- llvm::Type *SignatureExpansion::addIndirectResult (SILType resultType) {
617
+ llvm::Type *SignatureExpansion::addIndirectResult (SILType resultType,
618
+ bool useInReg) {
615
619
const TypeInfo &resultTI = IGM.getTypeInfo (resultType);
616
620
auto storageTy = resultTI.getStorageType ();
617
621
addIndirectResultAttributes (IGM, Attrs, ParamIRTypes.size (), claimSRet (),
618
- storageTy, resultTI);
622
+ storageTy, resultTI, useInReg );
619
623
addPointerParameter (storageTy);
620
624
return IGM.VoidTy ;
621
625
}
@@ -1707,9 +1711,9 @@ void SignatureExpansion::expandExternalSignatureTypes() {
1707
1711
// returned indirect values.
1708
1712
emitArg (0 );
1709
1713
firstParamToLowerNormally = 1 ;
1710
- addIndirectResult (resultType);
1714
+ addIndirectResult (resultType, returnInfo. getInReg () );
1711
1715
} else
1712
- addIndirectResult (resultType);
1716
+ addIndirectResult (resultType, returnInfo. getInReg () );
1713
1717
}
1714
1718
1715
1719
// Use a special IR type for passing block pointers.
0 commit comments