@@ -435,8 +435,9 @@ namespace {
435
435
void emitSelfConsumedDiagnostic (SILInstruction *Inst);
436
436
437
437
LiveOutBlockState &getBlockInfo (SILBasicBlock *BB) {
438
- return PerBlockInfo.insert ({BB,
439
- LiveOutBlockState (TheMemory.NumElements )}).first ->second ;
438
+ return PerBlockInfo
439
+ .insert ({BB, LiveOutBlockState (TheMemory.getNumElements ())})
440
+ .first ->second ;
440
441
}
441
442
442
443
AvailabilitySet getLivenessAtInst (SILInstruction *Inst, unsigned FirstElt,
@@ -640,7 +641,7 @@ void LifetimeChecker::noteUninitializedMembers(const DIMemoryUse &Use) {
640
641
if (Liveness.get (i) == DIKind::Yes) continue ;
641
642
642
643
// Ignore a failed super.init requirement.
643
- if (i == TheMemory.NumElements - 1 && TheMemory.isDerivedClassSelf ())
644
+ if (i == TheMemory.getNumElements () - 1 && TheMemory.isDerivedClassSelf ())
644
645
continue ;
645
646
646
647
std::string Name;
@@ -672,7 +673,7 @@ std::string LifetimeChecker::getUninitElementName(const DIMemoryUse &Use) {
672
673
// Verify that it isn't the super.init marker that failed. The client should
673
674
// handle this, not pass it down to diagnoseInitError.
674
675
assert ((!TheMemory.isDerivedClassSelf () ||
675
- firstUndefElement != TheMemory.NumElements - 1 ) &&
676
+ firstUndefElement != TheMemory.getNumElements () - 1 ) &&
676
677
" super.init failure not handled in the right place" );
677
678
678
679
// If the definition is a declaration, try to reconstruct a name and
@@ -938,8 +939,8 @@ void LifetimeChecker::handleStoreUse(unsigned UseID) {
938
939
939
940
if (TheMemory.isNonRootClassSelf ()) {
940
941
if (getSelfInitializedAtInst (Use.Inst ) != DIKind::Yes) {
941
- auto SelfLiveness = getLivenessAtInst (Use. Inst ,
942
- 0 , TheMemory.NumElements );
942
+ auto SelfLiveness =
943
+ getLivenessAtInst (Use. Inst , 0 , TheMemory.getNumElements () );
943
944
if (SelfLiveness.isAllYes ()) {
944
945
emitSelfConsumedDiagnostic (Use.Inst );
945
946
return ;
@@ -1816,11 +1817,12 @@ void LifetimeChecker::handleSelfInitUse(unsigned UseID) {
1816
1817
1817
1818
// Determine the liveness states of the memory object, including the
1818
1819
// self/super.init state.
1819
- AvailabilitySet Liveness = getLivenessAtInst (Inst, 0 , TheMemory.NumElements );
1820
+ AvailabilitySet Liveness =
1821
+ getLivenessAtInst (Inst, 0 , TheMemory.getNumElements ());
1820
1822
1821
1823
// self/super.init() calls require that self/super.init has not already
1822
1824
// been called. If it has, reject the program.
1823
- switch (Liveness.get (TheMemory.NumElements - 1 )) {
1825
+ switch (Liveness.get (TheMemory.getNumElements () - 1 )) {
1824
1826
case DIKind::No: // This is good! Keep going.
1825
1827
break ;
1826
1828
case DIKind::Yes:
@@ -1838,15 +1840,16 @@ void LifetimeChecker::handleSelfInitUse(unsigned UseID) {
1838
1840
}
1839
1841
1840
1842
if (TheMemory.isDelegatingInit ()) {
1841
- assert (TheMemory.NumElements == 1 && " delegating inits have a single elt" );
1843
+ assert (TheMemory.getNumElements () == 1 &&
1844
+ " delegating inits have a single elt" );
1842
1845
1843
1846
// Lower Assign instructions if needed.
1844
1847
if (isa<AssignInst>(Use.Inst ) || isa<AssignByWrapperInst>(Use.Inst ))
1845
1848
NeedsUpdateForInitState.push_back (UseID);
1846
1849
} else {
1847
1850
// super.init also requires that all ivars are initialized before the
1848
1851
// superclass initializer runs.
1849
- for (unsigned i = 0 , e = TheMemory.NumElements - 1 ; i != e; ++i) {
1852
+ for (unsigned i = 0 , e = TheMemory.getNumElements () - 1 ; i != e; ++i) {
1850
1853
if (Liveness.get (i) == DIKind::Yes) continue ;
1851
1854
1852
1855
// If the super.init call is implicit generated, produce a specific
@@ -2045,7 +2048,7 @@ void LifetimeChecker::processNonTrivialRelease(unsigned ReleaseID) {
2045
2048
assert (isa<StrongReleaseInst>(Release) || isa<DestroyValueInst>(Release) ||
2046
2049
isa<DestroyAddrInst>(Release));
2047
2050
2048
- auto Availability = getLivenessAtInst (Release, 0 , TheMemory.NumElements );
2051
+ auto Availability = getLivenessAtInst (Release, 0 , TheMemory.getNumElements () );
2049
2052
DIKind SelfInitialized = DIKind::Yes;
2050
2053
2051
2054
if (TheMemory.isNonRootClassSelf ()) {
@@ -2188,7 +2191,7 @@ SILValue LifetimeChecker::handleConditionalInitAssign() {
2188
2191
SILLocation Loc = TheMemory.getLoc ();
2189
2192
Loc.markAutoGenerated ();
2190
2193
2191
- unsigned NumMemoryElements = TheMemory.NumElements ;
2194
+ unsigned NumMemoryElements = TheMemory.getNumElements () ;
2192
2195
2193
2196
// We might need an extra bit to check if self was consumed.
2194
2197
if (HasConditionalSelfInitialized)
@@ -2338,10 +2341,10 @@ handleConditionalDestroys(SILValue ControlVariableAddr) {
2338
2341
SILBuilderWithScope B (TheMemory.MemoryInst );
2339
2342
Identifier ShiftRightFn, TruncateFn;
2340
2343
2341
- unsigned NumMemoryElements = TheMemory.NumElements ;
2342
-
2343
- unsigned SelfInitializedElt = TheMemory.NumElements ;
2344
- unsigned SuperInitElt = TheMemory.NumElements - 1 ;
2344
+ unsigned NumMemoryElements = TheMemory.getNumElements () ;
2345
+
2346
+ unsigned SelfInitializedElt = TheMemory.getNumElements () ;
2347
+ unsigned SuperInitElt = TheMemory.getNumElements () - 1 ;
2345
2348
2346
2349
// We might need an extra bit to check if self was consumed.
2347
2350
if (HasConditionalSelfInitialized)
@@ -2698,7 +2701,7 @@ AvailabilitySet LifetimeChecker::getLivenessAtInst(SILInstruction *Inst,
2698
2701
LLVM_DEBUG (llvm::dbgs () << " Get liveness " << FirstElt << " , #" << NumElts
2699
2702
<< " at " << *Inst);
2700
2703
2701
- AvailabilitySet Result (TheMemory.NumElements );
2704
+ AvailabilitySet Result (TheMemory.getNumElements () );
2702
2705
2703
2706
// Empty tuple queries return a completely "unknown" vector, since they don't
2704
2707
// care about any of the elements.
@@ -2709,13 +2712,13 @@ AvailabilitySet LifetimeChecker::getLivenessAtInst(SILInstruction *Inst,
2709
2712
2710
2713
// The vastly most common case is memory allocations that are not tuples,
2711
2714
// so special case this with a more efficient algorithm.
2712
- if (TheMemory.NumElements == 1 ) {
2715
+ if (TheMemory.getNumElements () == 1 ) {
2713
2716
return getLivenessAtNonTupleInst (Inst, InstBB, Result);
2714
2717
}
2715
2718
2716
2719
// Check locally to see if any elements are satisfied within the block, and
2717
2720
// keep track of which ones are still needed in the NeededElements set.
2718
- SmallBitVector NeededElements (TheMemory.NumElements );
2721
+ SmallBitVector NeededElements (TheMemory.getNumElements () );
2719
2722
NeededElements.set (FirstElt, FirstElt+NumElts);
2720
2723
2721
2724
// If there is a store in the current block, scan the block to see if the
@@ -2842,9 +2845,9 @@ bool LifetimeChecker::isInitializedAtUse(const DIMemoryUse &Use,
2842
2845
2843
2846
// If the client wants to know about super.init, check to see if we failed
2844
2847
// it or some other element.
2845
- if (Use.FirstElement + Use.NumElements == TheMemory.NumElements &&
2848
+ if (Use.FirstElement + Use.NumElements == TheMemory.getNumElements () &&
2846
2849
TheMemory.isAnyDerivedClassSelf () &&
2847
- Liveness.get (Liveness.size ()- 1 ) != DIKind::Yes) {
2850
+ Liveness.get (Liveness.size () - 1 ) != DIKind::Yes) {
2848
2851
if (SuperInitDone) *SuperInitDone = false ;
2849
2852
}
2850
2853
@@ -2864,8 +2867,8 @@ bool LifetimeChecker::isInitializedAtUse(const DIMemoryUse &Use,
2864
2867
// we caught it, self is no longer available.
2865
2868
if (TheMemory.isNonRootClassSelf ()) {
2866
2869
if (getSelfInitializedAtInst (Use.Inst ) != DIKind::Yes) {
2867
- auto SelfLiveness = getLivenessAtInst (Use. Inst ,
2868
- 0 , TheMemory.NumElements );
2870
+ auto SelfLiveness =
2871
+ getLivenessAtInst (Use. Inst , 0 , TheMemory.getNumElements () );
2869
2872
if (SelfLiveness.isAllYes ()) {
2870
2873
if (FailedSelfUse) *FailedSelfUse = true ;
2871
2874
return false ;
0 commit comments