@@ -1375,8 +1375,12 @@ void SignatureExpansion::expandExternalSignatureTypes() {
1375
1375
IGM.getSILModule (), FnType, TypeExpansionContext::minimal ()));
1376
1376
}();
1377
1377
1378
- // Convert the SIL result type to a Clang type.
1379
- auto clangResultTy = IGM.getClangType (SILResultTy);
1378
+ // Convert the SIL result type to a Clang type. If this is for a c++
1379
+ // constructor, use 'void' as the return type to arrange the function type.
1380
+ auto clangResultTy = IGM.getClangType (
1381
+ cxxCtorDecl
1382
+ ? SILType::getPrimitiveObjectType (IGM.Context .TheEmptyTupleType )
1383
+ : SILResultTy);
1380
1384
1381
1385
// Now convert the parameters to Clang types.
1382
1386
auto params = FnType->getParameters ();
@@ -1445,14 +1449,10 @@ void SignatureExpansion::expandExternalSignatureTypes() {
1445
1449
// Generate function info for this signature.
1446
1450
auto extInfo = clang::FunctionType::ExtInfo ();
1447
1451
1448
- if (cxxCtorDecl)
1449
- ForeignInfo.ClangInfo = &clang::CodeGen::arrangeCXXStructorDeclaration (
1450
- IGM.ClangCodeGen ->CGM (), {cxxCtorDecl, clang::Ctor_Complete});
1451
- else
1452
- ForeignInfo.ClangInfo = &clang::CodeGen::arrangeFreeFunctionCall (
1453
- IGM.ClangCodeGen ->CGM (), clangResultTy, paramTys, extInfo,
1454
- clang::CodeGen::RequiredArgs::All);
1455
- auto &FI = *ForeignInfo.ClangInfo ;
1452
+ auto &FI = clang::CodeGen::arrangeFreeFunctionCall (IGM.ClangCodeGen ->CGM (),
1453
+ clangResultTy, paramTys, extInfo,
1454
+ clang::CodeGen::RequiredArgs::All);
1455
+ ForeignInfo.ClangInfo = &FI;
1456
1456
1457
1457
assert (FI.arg_size () == paramTys.size () &&
1458
1458
" Expected one ArgInfo for each parameter type!" );
@@ -1596,7 +1596,12 @@ void SignatureExpansion::expandExternalSignatureTypes() {
1596
1596
for (auto i : indices (paramTys).slice (firstParamToLowerNormally))
1597
1597
emitArg (i);
1598
1598
1599
- if (returnInfo.isIndirect () || returnInfo.isIgnore ()) {
1599
+ if (cxxCtorDecl) {
1600
+ ResultIRType = cast<llvm::Function>(IGM.getAddrOfClangGlobalDecl (
1601
+ {cxxCtorDecl, clang::Ctor_Complete},
1602
+ (ForDefinition_t) false ))
1603
+ ->getReturnType ();
1604
+ } else if (returnInfo.isIndirect () || returnInfo.isIgnore ()) {
1600
1605
ResultIRType = IGM.VoidTy ;
1601
1606
} else {
1602
1607
ResultIRType = returnInfo.getCoerceToType ();
@@ -3996,12 +4001,6 @@ static void externalizeArguments(IRGenFunction &IGF, const Callee &callee,
3996
4001
// swiftcall function pointers through SIL as C functions anyway.
3997
4002
assert (FI.getExtParameterInfo (i).getABI () == clang::ParameterABI::Ordinary);
3998
4003
3999
- assert ((!silConv.isSILIndirect (params[i - firstParam]) ||
4000
- AI.getKind () == clang::CodeGen::ABIArgInfo::Direct ||
4001
- AI.getKind () == clang::CodeGen::ABIArgInfo::Indirect) &&
4002
- " indirect SIL types passed indirectly should be classified as "
4003
- " either Direct or Indirect" );
4004
-
4005
4004
// Add a padding argument if required.
4006
4005
if (auto *padType = AI.getPaddingType ())
4007
4006
out.add (llvm::UndefValue::get (padType));
@@ -4053,15 +4052,6 @@ static void externalizeArguments(IRGenFunction &IGF, const Callee &callee,
4053
4052
case clang::CodeGen::ABIArgInfo::IndirectAliased:
4054
4053
llvm_unreachable (" not implemented" );
4055
4054
case clang::CodeGen::ABIArgInfo::Indirect: {
4056
- // If this is a SIL type passed indirectly, avoid emitting a redundant
4057
- // initializing copy.
4058
- if (silConv.isSILIndirect (params[i - firstParam])) {
4059
- assert (paramType.isAddress () && " SIL type is not an address?" );
4060
- auto addr = in.claimNext ();
4061
- out.add (addr);
4062
- break ;
4063
- }
4064
-
4065
4055
auto &ti = cast<LoadableTypeInfo>(IGF.getTypeInfo (paramType));
4066
4056
4067
4057
auto temp = ti.allocateStack (IGF, paramType, " indirect-temporary" );
0 commit comments