@@ -1578,6 +1578,7 @@ class DestructureInputs {
1578
1578
SmallVectorImpl<SILParameterInfo> &Inputs;
1579
1579
SmallVectorImpl<int > &ParameterMap;
1580
1580
SmallBitVector &AddressableLoweredParameters;
1581
+ SmallBitVector &ConditionallyAddressableLoweredParameters;
1581
1582
unsigned NextOrigParamIndex = 0 ;
1582
1583
1583
1584
void addLoweredParameter (SILParameterInfo parameter,
@@ -1593,11 +1594,13 @@ class DestructureInputs {
1593
1594
std::optional<ActorIsolation> isolationInfo,
1594
1595
SmallVectorImpl<SILParameterInfo> &inputs,
1595
1596
SmallVectorImpl<int > ¶meterMap,
1596
- SmallBitVector &addressableParams)
1597
- : expansion(expansion), TC(TC), Convs(conventions), Foreign(foreign),
1598
- IsolationInfo(isolationInfo), Inputs(inputs),
1599
- ParameterMap(parameterMap),
1600
- AddressableLoweredParameters(addressableParams)
1597
+ SmallBitVector &addressableParams,
1598
+ SmallBitVector &conditionallyAddressableParams)
1599
+ : expansion(expansion), TC(TC), Convs(conventions), Foreign(foreign),
1600
+ IsolationInfo(isolationInfo), Inputs(inputs),
1601
+ ParameterMap(parameterMap),
1602
+ AddressableLoweredParameters(addressableParams),
1603
+ ConditionallyAddressableLoweredParameters(conditionallyAddressableParams)
1601
1604
{}
1602
1605
1603
1606
void destructure (AbstractionPattern origType,
@@ -1768,7 +1771,9 @@ class DestructureInputs {
1768
1771
1769
1772
// Any parameters not yet marked addressable shouldn't be.
1770
1773
assert (AddressableLoweredParameters.size () <= ParameterMap.size ());
1774
+ assert (ConditionallyAddressableLoweredParameters.size () <= ParameterMap.size ());
1771
1775
AddressableLoweredParameters.resize (ParameterMap.size (), false );
1776
+ ConditionallyAddressableLoweredParameters.resize (ParameterMap.size (), false );
1772
1777
}
1773
1778
1774
1779
void visit (AbstractionPattern origType, AnyFunctionType::Param substParam,
@@ -1809,8 +1814,8 @@ class DestructureInputs {
1809
1814
if (origFlags.isAddressable ()) {
1810
1815
origType = AbstractionPattern::getOpaque ();
1811
1816
1812
- // Remember that this lowered parameter is addressable in the
1813
- // addressable parameters vector.
1817
+ // Remember that this lowered parameter is unconditionally addressable in
1818
+ // the addressable parameters vector.
1814
1819
AddressableLoweredParameters.resize (ParameterMap.size () + 1 , false );
1815
1820
AddressableLoweredParameters[ParameterMap.size ()] = true ;
1816
1821
} else if (hasScopedDependency) {
@@ -1821,10 +1826,14 @@ class DestructureInputs {
1821
1826
if (initialSubstTL.getRecursiveProperties ().isAddressableForDependencies ()) {
1822
1827
origType = AbstractionPattern::getOpaque ();
1823
1828
1824
- // Remember that this lowered parameter is addressable in the
1825
- // addressable parameters vector.
1829
+ // Remember that this lowered parameter is conditionally addressable in
1830
+ // the addressable parameters vector.
1826
1831
AddressableLoweredParameters.resize (ParameterMap.size () + 1 , false );
1827
1832
AddressableLoweredParameters[ParameterMap.size ()] = true ;
1833
+
1834
+ ConditionallyAddressableLoweredParameters
1835
+ .resize (ParameterMap.size () + 1 , false );
1836
+ ConditionallyAddressableLoweredParameters[ParameterMap.size ()] = true ;
1828
1837
}
1829
1838
}
1830
1839
@@ -2565,6 +2574,7 @@ static CanSILFunctionType getSILFunctionType(
2565
2574
SmallVector<SILParameterInfo, 8 > inputs;
2566
2575
SmallVector<int , 8 > parameterMap;
2567
2576
SmallBitVector addressableParams;
2577
+ SmallBitVector conditionallyAddressableParams;
2568
2578
{
2569
2579
std::optional<ActorIsolation> actorIsolation;
2570
2580
if (constant) {
@@ -2587,7 +2597,9 @@ static CanSILFunctionType getSILFunctionType(
2587
2597
}
2588
2598
DestructureInputs destructurer (expansionContext, TC, conventions,
2589
2599
foreignInfo, actorIsolation, inputs,
2590
- parameterMap, addressableParams);
2600
+ parameterMap,
2601
+ addressableParams,
2602
+ conditionallyAddressableParams);
2591
2603
destructurer.destructure (origType, substFnInterfaceType.getParams (),
2592
2604
extInfoBuilder, unimplementable);
2593
2605
}
@@ -2668,11 +2680,19 @@ static CanSILFunctionType getSILFunctionType(
2668
2680
IndexSubset *addressableSet = addressableDeps.any ()
2669
2681
? IndexSubset::get (TC.Context , addressableDeps)
2670
2682
: nullptr ;
2683
+
2684
+ SmallBitVector condAddressableDeps = scopeIndicesSet
2685
+ ? scopeIndicesSet->getBitVector () & conditionallyAddressableParams
2686
+ : SmallBitVector (1 , false );
2687
+ IndexSubset *condAddressableSet = condAddressableDeps.any ()
2688
+ ? IndexSubset::get (TC.Context , condAddressableDeps)
2689
+ : nullptr ;
2671
2690
2672
2691
return LifetimeDependenceInfo (inheritIndicesSet,
2673
2692
scopeIndicesSet,
2674
2693
target, /* immortal*/ false ,
2675
- addressableSet);
2694
+ addressableSet,
2695
+ condAddressableSet);
2676
2696
};
2677
2697
// Lower parameter dependencies.
2678
2698
for (unsigned i = 0 ; i < parameterMap.size (); ++i) {
@@ -2759,10 +2779,12 @@ static CanSILFunctionType getSILFunctionTypeForInitAccessor(
2759
2779
std::optional<ActorIsolation> actorIsolation; // For now always null.
2760
2780
SmallVector<int , 8 > unusedParameterMap;
2761
2781
SmallBitVector unusedAddressableParams;
2782
+ SmallBitVector unusedConditionalAddressableParams;
2762
2783
DestructureInputs destructurer (context, TC, conventions, foreignInfo,
2763
2784
actorIsolation, inputs,
2764
2785
unusedParameterMap,
2765
- unusedAddressableParams);
2786
+ unusedAddressableParams,
2787
+ unusedConditionalAddressableParams);
2766
2788
destructurer.destructure (
2767
2789
origType, substAccessorType.getParams (),
2768
2790
extInfoBuilder.withRepresentation (SILFunctionTypeRepresentation::Thin),
0 commit comments