17
17
// ===----------------------------------------------------------------------===//
18
18
19
19
#define DEBUG_TYPE " libsil"
20
+
20
21
#include " swift/AST/AnyFunctionRef.h"
21
22
#include " swift/AST/CanTypeVisitor.h"
22
23
#include " swift/AST/Decl.h"
@@ -1388,16 +1389,13 @@ class DestructureInputs {
1388
1389
AbstractionPattern TopLevelOrigType = AbstractionPattern::getInvalid();
1389
1390
SmallVectorImpl<SILParameterInfo> &Inputs;
1390
1391
unsigned NextOrigParamIndex = 0 ;
1391
- Optional<SmallBitVector> NoImplicitCopyIndices;
1392
1392
1393
1393
public:
1394
1394
DestructureInputs (TypeExpansionContext expansion, TypeConverter &TC,
1395
1395
const Conventions &conventions, const ForeignInfo &foreign,
1396
- SmallVectorImpl<SILParameterInfo> &inputs,
1397
- Optional<SmallBitVector> noImplicitCopyIndices)
1396
+ SmallVectorImpl<SILParameterInfo> &inputs)
1398
1397
: expansion(expansion), TC(TC), Convs(conventions), Foreign(foreign),
1399
- Inputs(inputs),
1400
- NoImplicitCopyIndices(noImplicitCopyIndices) {}
1398
+ Inputs(inputs) {}
1401
1399
1402
1400
void destructure (AbstractionPattern origType,
1403
1401
CanAnyFunctionType::CanParamArrayRef params,
@@ -1435,18 +1433,14 @@ class DestructureInputs {
1435
1433
// Add any foreign parameters that are positioned here.
1436
1434
maybeAddForeignParameters ();
1437
1435
1438
- bool hasNoImplicitCopy =
1439
- NoImplicitCopyIndices.hasValue () && NoImplicitCopyIndices->any ();
1440
-
1441
1436
// Process all the non-self parameters.
1442
1437
for (unsigned i = 0 ; i != numNonSelfParams; ++i) {
1443
1438
auto ty = params[i].getParameterType ();
1444
1439
auto eltPattern = origType.getFunctionParamType (i);
1445
1440
auto flags = params[i].getParameterFlags ();
1446
1441
1447
1442
visit (flags.getValueOwnership (), /* forSelf=*/ false , eltPattern, ty,
1448
- flags.isNoDerivative (),
1449
- hasNoImplicitCopy && (*NoImplicitCopyIndices)[i]);
1443
+ flags.isNoDerivative ());
1450
1444
}
1451
1445
1452
1446
// Process the self parameter. Note that we implicitly drop self
@@ -1457,8 +1451,7 @@ class DestructureInputs {
1457
1451
auto eltPattern = origType.getFunctionParamType (numNonSelfParams);
1458
1452
auto flags = selfParam.getParameterFlags ();
1459
1453
1460
- visit (flags.getValueOwnership (), /* forSelf=*/ true , eltPattern, ty, false ,
1461
- false );
1454
+ visit (flags.getValueOwnership (), /* forSelf=*/ true , eltPattern, ty, false );
1462
1455
}
1463
1456
1464
1457
TopLevelOrigType = AbstractionPattern::getInvalid ();
@@ -1467,7 +1460,7 @@ class DestructureInputs {
1467
1460
1468
1461
void visit (ValueOwnership ownership, bool forSelf,
1469
1462
AbstractionPattern origType, CanType substType,
1470
- bool isNonDifferentiable, bool isNoImplicitCopy ) {
1463
+ bool isNonDifferentiable) {
1471
1464
assert (!isa<InOutType>(substType));
1472
1465
1473
1466
// Tuples get handled specially, in some cases:
@@ -1485,7 +1478,7 @@ class DestructureInputs {
1485
1478
assert (ownership == ValueOwnership::Default);
1486
1479
assert (!elt.isVararg ());
1487
1480
visit (ownership, forSelf, origType.getTupleElementType (i),
1488
- CanType (elt.getRawType ()), false , false );
1481
+ CanType (elt.getRawType ()), false );
1489
1482
}
1490
1483
return ;
1491
1484
case ValueOwnership::InOut:
@@ -1511,8 +1504,6 @@ class DestructureInputs {
1511
1504
convention = ParameterConvention::Direct_Unowned;
1512
1505
} else {
1513
1506
// If we are no implicit copy, our ownership is always Owned.
1514
- if (isNoImplicitCopy)
1515
- ownership = ValueOwnership::Owned;
1516
1507
convention = Convs.getDirect (ownership, forSelf, origParamIndex, origType,
1517
1508
substTLConv);
1518
1509
assert (!isIndirectFormalParameter (convention));
@@ -1579,7 +1570,7 @@ class DestructureInputs {
1579
1570
// This is a "self", but it's not a Swift self, we handle it differently.
1580
1571
visit (ForeignSelf->SubstSelfParam .getValueOwnership (),
1581
1572
/* forSelf=*/ false , ForeignSelf->OrigSelfParam ,
1582
- ForeignSelf->SubstSelfParam .getParameterType (), false , false );
1573
+ ForeignSelf->SubstSelfParam .getParameterType (), false );
1583
1574
}
1584
1575
return true ;
1585
1576
}
@@ -1892,8 +1883,7 @@ static CanSILFunctionType getSILFunctionType(
1892
1883
SILExtInfoBuilder extInfoBuilder, const Conventions &conventions,
1893
1884
const ForeignInfo &foreignInfo, Optional<SILDeclRef> origConstant,
1894
1885
Optional<SILDeclRef> constant, Optional<SubstitutionMap> reqtSubs,
1895
- ProtocolConformanceRef witnessMethodConformance,
1896
- Optional<SmallBitVector> noImplicitCopyIndices) {
1886
+ ProtocolConformanceRef witnessMethodConformance) {
1897
1887
// Find the generic parameters.
1898
1888
CanGenericSignature genericSig =
1899
1889
substFnInterfaceType.getOptGenericSignature ();
@@ -2053,8 +2043,7 @@ static CanSILFunctionType getSILFunctionType(
2053
2043
SmallVector<SILParameterInfo, 8 > inputs;
2054
2044
{
2055
2045
DestructureInputs destructurer (expansionContext, TC, conventions,
2056
- foreignInfo, inputs,
2057
- noImplicitCopyIndices);
2046
+ foreignInfo, inputs);
2058
2047
destructurer.destructure (origType, substFnInterfaceType.getParams (),
2059
2048
extInfoBuilder);
2060
2049
}
@@ -2337,15 +2326,14 @@ static CanSILFunctionType getNativeSILFunctionType(
2337
2326
AbstractionPattern origType, CanAnyFunctionType substInterfaceType,
2338
2327
SILExtInfoBuilder extInfoBuilder, Optional<SILDeclRef> origConstant,
2339
2328
Optional<SILDeclRef> constant, Optional<SubstitutionMap> reqtSubs,
2340
- ProtocolConformanceRef witnessMethodConformance,
2341
- Optional<SmallBitVector> noImplicitCopyIndices) {
2329
+ ProtocolConformanceRef witnessMethodConformance) {
2342
2330
assert (bool (origConstant) == bool (constant));
2343
2331
auto getSILFunctionTypeForConventions =
2344
2332
[&](const Conventions &convs) -> CanSILFunctionType {
2345
2333
return getSILFunctionType (TC, context, origType, substInterfaceType,
2346
2334
extInfoBuilder, convs, ForeignInfo (),
2347
2335
origConstant, constant, reqtSubs,
2348
- witnessMethodConformance, noImplicitCopyIndices );
2336
+ witnessMethodConformance);
2349
2337
};
2350
2338
switch (extInfoBuilder.getRepresentation ()) {
2351
2339
case SILFunctionType::Representation::Block:
@@ -2409,7 +2397,7 @@ CanSILFunctionType swift::getNativeSILFunctionType(
2409
2397
2410
2398
return ::getNativeSILFunctionType (
2411
2399
TC, context, origType, substType, silExtInfo.intoBuilder (), origConstant,
2412
- substConstant, reqtSubs, witnessMethodConformance, None );
2400
+ substConstant, reqtSubs, witnessMethodConformance);
2413
2401
}
2414
2402
2415
2403
// / Build a generic signature and environment for a re-abstraction thunk.
@@ -3076,7 +3064,7 @@ static CanSILFunctionType getSILFunctionTypeForClangDecl(
3076
3064
return getSILFunctionType (
3077
3065
TC, TypeExpansionContext::minimal (), origPattern, substInterfaceType,
3078
3066
extInfoBuilder, ObjCMethodConventions (method), foreignInfo, constant,
3079
- constant, None, ProtocolConformanceRef (), None );
3067
+ constant, None, ProtocolConformanceRef ());
3080
3068
}
3081
3069
3082
3070
if (auto method = dyn_cast<clang::CXXMethodDecl>(clangDecl)) {
@@ -3088,7 +3076,7 @@ static CanSILFunctionType getSILFunctionTypeForClangDecl(
3088
3076
return getSILFunctionType (TC, TypeExpansionContext::minimal (), origPattern,
3089
3077
substInterfaceType, extInfoBuilder, conventions,
3090
3078
foreignInfo, constant, constant, None,
3091
- ProtocolConformanceRef (), None );
3079
+ ProtocolConformanceRef ());
3092
3080
}
3093
3081
3094
3082
if (auto func = dyn_cast<clang::FunctionDecl>(clangDecl)) {
@@ -3101,7 +3089,7 @@ static CanSILFunctionType getSILFunctionTypeForClangDecl(
3101
3089
return getSILFunctionType (TC, TypeExpansionContext::minimal (), origPattern,
3102
3090
substInterfaceType, extInfoBuilder,
3103
3091
CFunctionConventions (func), foreignInfo, constant,
3104
- constant, None, ProtocolConformanceRef (), None );
3092
+ constant, None, ProtocolConformanceRef ());
3105
3093
}
3106
3094
3107
3095
llvm_unreachable (" call to unknown kind of C function" );
@@ -3129,15 +3117,15 @@ static CanSILFunctionType getSILFunctionTypeForAbstractCFunction(
3129
3117
return getSILFunctionType (
3130
3118
TC, TypeExpansionContext::minimal (), origType, substType,
3131
3119
extInfoBuilder, CFunctionTypeConventions (fnType), ForeignInfo (),
3132
- constant, constant, None, ProtocolConformanceRef (), None );
3120
+ constant, constant, None, ProtocolConformanceRef ());
3133
3121
}
3134
3122
}
3135
3123
3136
3124
// TODO: Ought to support captures in block funcs.
3137
3125
return getSILFunctionType (TC, TypeExpansionContext::minimal (), origType,
3138
3126
substType, extInfoBuilder,
3139
3127
DefaultBlockConventions (), ForeignInfo (), constant,
3140
- constant, None, ProtocolConformanceRef (), None );
3128
+ constant, None, ProtocolConformanceRef ());
3141
3129
}
3142
3130
3143
3131
// / Try to find a clang method declaration for the given function.
@@ -3305,7 +3293,7 @@ static CanSILFunctionType getSILFunctionTypeForObjCSelectorFamily(
3305
3293
TC, TypeExpansionContext::minimal (), AbstractionPattern (origType),
3306
3294
substInterfaceType, extInfoBuilder, ObjCSelectorFamilyConventions (family),
3307
3295
foreignInfo, constant, constant,
3308
- /* requirement subs*/ None, ProtocolConformanceRef (), None );
3296
+ /* requirement subs*/ None, ProtocolConformanceRef ());
3309
3297
}
3310
3298
3311
3299
static bool isImporterGeneratedAccessor (const clang::Decl *clangDecl,
@@ -3375,23 +3363,9 @@ static CanSILFunctionType getUncachedSILFunctionTypeForConstant(
3375
3363
}
3376
3364
}();
3377
3365
3378
- Optional<SmallBitVector> noImplicitCopyIndices;
3379
- if (constant.hasDecl ()) {
3380
- auto decl = constant.getDecl ();
3381
- if (auto *funcDecl = dyn_cast<AbstractFunctionDecl>(decl)) {
3382
- noImplicitCopyIndices.emplace (funcDecl->getParameters ()->size ());
3383
- for (auto p : llvm::enumerate (*funcDecl->getParameters ())) {
3384
- if (p.value ()->isNoImplicitCopy ()) {
3385
- noImplicitCopyIndices->set (p.index ());
3386
- }
3387
- }
3388
- }
3389
- }
3390
-
3391
3366
return ::getNativeSILFunctionType (
3392
3367
TC, context, origType, origLoweredInterfaceType, extInfoBuilder,
3393
- constant, constant, None, witnessMethodConformance,
3394
- noImplicitCopyIndices);
3368
+ constant, constant, None, witnessMethodConformance);
3395
3369
}
3396
3370
3397
3371
ForeignInfo foreignInfo;
0 commit comments