@@ -360,7 +360,8 @@ static void addIndirectResultAttributes(IRGenModule &IGM,
360360 llvm::AttributeList &attrs,
361361 unsigned paramIndex, bool allowSRet,
362362 llvm::Type *storageType,
363- const TypeInfo &typeInfo) {
363+ const TypeInfo &typeInfo,
364+ bool useInReg = false ) {
364365 llvm::AttrBuilder b (IGM.getLLVMContext ());
365366 b.addAttribute (llvm::Attribute::NoAlias);
366367 // Bitwise takable value types are guaranteed not to capture
@@ -370,6 +371,8 @@ static void addIndirectResultAttributes(IRGenModule &IGM,
370371 if (allowSRet) {
371372 assert (storageType);
372373 b.addStructRetAttr (storageType);
374+ if (useInReg)
375+ b.addAttribute (llvm::Attribute::InReg);
373376 }
374377 attrs = attrs.addParamAttributes (IGM.getLLVMContext (), paramIndex, b);
375378}
@@ -552,7 +555,7 @@ namespace {
552555
553556 private:
554557 const TypeInfo &expand (SILParameterInfo param);
555- llvm::Type *addIndirectResult (SILType resultType);
558+ llvm::Type *addIndirectResult (SILType resultType, bool useInReg = false );
556559
557560 SILFunctionConventions getSILFuncConventions () const {
558561 return SILFunctionConventions (FnType, IGM.getSILModule ());
@@ -611,11 +614,12 @@ namespace {
611614} // end namespace irgen
612615} // end namespace swift
613616
614- llvm::Type *SignatureExpansion::addIndirectResult (SILType resultType) {
617+ llvm::Type *SignatureExpansion::addIndirectResult (SILType resultType,
618+ bool useInReg) {
615619 const TypeInfo &resultTI = IGM.getTypeInfo (resultType);
616620 auto storageTy = resultTI.getStorageType ();
617621 addIndirectResultAttributes (IGM, Attrs, ParamIRTypes.size (), claimSRet (),
618- storageTy, resultTI);
622+ storageTy, resultTI, useInReg );
619623 addPointerParameter (storageTy);
620624 return IGM.VoidTy ;
621625}
@@ -1707,9 +1711,9 @@ void SignatureExpansion::expandExternalSignatureTypes() {
17071711 // returned indirect values.
17081712 emitArg (0 );
17091713 firstParamToLowerNormally = 1 ;
1710- addIndirectResult (resultType);
1714+ addIndirectResult (resultType, returnInfo. getInReg () );
17111715 } else
1712- addIndirectResult (resultType);
1716+ addIndirectResult (resultType, returnInfo. getInReg () );
17131717 }
17141718
17151719 // Use a special IR type for passing block pointers.
0 commit comments