Skip to content

Commit 40e5955

Browse files
committed
SILOptimizer: rename needUpdateStackNesting (and similar) -> invalidatedStackNesting
NFC
1 parent bfff482 commit 40e5955

File tree

8 files changed

+30
-30
lines changed

8 files changed

+30
-30
lines changed

include/swift/SILOptimizer/Utils/SILInliner.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class SILInliner {
7272
///
7373
/// In this case stack nesting must be corrected after inlining with the
7474
/// StackNesting utility.
75-
static bool needsUpdateStackNesting(FullApplySite apply) {
75+
static bool invalidatesStackNesting(FullApplySite apply) {
7676
// Inlining of coroutines can result in improperly nested stack
7777
// allocations.
7878
return isa<BeginApplyInst>(apply);
@@ -111,7 +111,7 @@ class SILInliner {
111111
/// function.
112112
///
113113
/// *NOTE*: Inlining can result in improperly nested stack allocations, which
114-
/// must be corrected after inlining. See needsUpdateStackNesting().
114+
/// must be corrected after inlining. See invalidatesStackNesting().
115115
///
116116
/// Returns an iterator to the first inlined instruction (or the end of the
117117
/// caller block for empty functions) and the last block in function order
@@ -134,7 +134,7 @@ class SILInliner {
134134
/// function.
135135
///
136136
/// *NOTE*: Inlining can result in improperly nested stack allocations, which
137-
/// must be corrected after inlining. See needsUpdateStackNesting().
137+
/// must be corrected after inlining. See invalidatesStackNesting().
138138
///
139139
/// Returns an iterator to the first inlined instruction (or the end of the
140140
/// caller block for empty functions) and the last block in function order

lib/SILOptimizer/IPO/ClosureSpecializer.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ SILValue ClosureSpecCloner::cloneCalleeConversion(
780780
/// Populate the body of the cloned closure, modifying instructions as
781781
/// necessary. This is where we create the actual specialized BB Arguments
782782
void ClosureSpecCloner::populateCloned() {
783-
bool needToUpdateStackNesting = false;
783+
bool invalidatedStackNesting = false;
784784
SILFunction *Cloned = getCloned();
785785
SILFunction *ClosureUser = CallSiteDesc.getApplyCallee();
786786

@@ -880,11 +880,11 @@ void ClosureSpecCloner::populateCloned() {
880880
Builder.createReleaseValue(Loc, SILValue(NewClosure),
881881
Builder.getDefaultAtomicity());
882882
else
883-
needToUpdateStackNesting |=
883+
invalidatedStackNesting |=
884884
CallSiteDesc.destroyIfPartialApplyStack(Builder, NewClosure);
885885
for (auto PAI : NeedsRelease) {
886886
if (PAI->isOnStack())
887-
needToUpdateStackNesting |=
887+
invalidatedStackNesting |=
888888
CallSiteDesc.destroyIfPartialApplyStack(Builder, PAI);
889889
else
890890
Builder.createReleaseValue(Loc, SILValue(PAI),
@@ -909,19 +909,19 @@ void ClosureSpecCloner::populateCloned() {
909909
Builder.createReleaseValue(Loc, SILValue(NewClosure),
910910
Builder.getDefaultAtomicity());
911911
else
912-
needToUpdateStackNesting |=
912+
invalidatedStackNesting |=
913913
CallSiteDesc.destroyIfPartialApplyStack(Builder, NewClosure);
914914
for (auto PAI : NeedsRelease) {
915915
if (PAI->isOnStack())
916-
needToUpdateStackNesting |=
916+
invalidatedStackNesting |=
917917
CallSiteDesc.destroyIfPartialApplyStack(Builder, PAI);
918918
else
919919
Builder.createReleaseValue(Loc, SILValue(PAI),
920920
Builder.getDefaultAtomicity());
921921
}
922922
}
923923
}
924-
if (needToUpdateStackNesting) {
924+
if (invalidatedStackNesting) {
925925
StackNesting().correctStackNesting(Cloned);
926926
}
927927
}
@@ -971,7 +971,7 @@ void SILClosureSpecializerTransform::run() {
971971
// specialized all of their uses.
972972
LLVM_DEBUG(llvm::dbgs() << "Trying to remove dead closures!\n");
973973
sortUnique(PropagatedClosures);
974-
bool needUpdateStackNesting = false;
974+
bool invalidatedStackNesting = false;
975975

976976
for (auto *Closure : PropagatedClosures) {
977977
LLVM_DEBUG(llvm::dbgs() << " Visiting: " << *Closure);
@@ -983,10 +983,10 @@ void SILClosureSpecializerTransform::run() {
983983

984984
LLVM_DEBUG(llvm::dbgs() << " Deleted closure!\n");
985985
++NumPropagatedClosuresEliminated;
986-
needUpdateStackNesting = true;
986+
invalidatedStackNesting = true;
987987
}
988988

989-
if (needUpdateStackNesting) {
989+
if (invalidatedStackNesting) {
990990
StackNesting().correctStackNesting(F);
991991
}
992992
}

lib/SILOptimizer/Mandatory/MandatoryCombine.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class MandatoryCombiner final
7272

7373
/// Set to true if some alloc/dealloc_stack instruction are inserted and at
7474
/// the end of the run stack nesting needs to be corrected.
75-
bool needUpdateStackNesting;
75+
bool invalidatedStackNesting;
7676

7777
/// The number of times that the worklist has been processed.
7878
unsigned iteration;
@@ -119,7 +119,7 @@ class MandatoryCombiner final
119119
++iteration;
120120
}
121121

122-
if (needUpdateStackNesting) {
122+
if (invalidatedStackNesting) {
123123
StackNesting().correctStackNesting(&function);
124124
}
125125

@@ -279,7 +279,7 @@ SILInstruction *MandatoryCombiner::visitApplyInst(ApplyInst *instruction) {
279279
#endif
280280
);
281281
if (tryDeleteDeadClosure(partialApply, instModCallbacks)) {
282-
needUpdateStackNesting = true;
282+
invalidatedStackNesting = true;
283283
}
284284
return nullptr;
285285
}

lib/SILOptimizer/Mandatory/MandatoryInlining.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ static SILValue cleanupLoadedCalleeValue(SILValue calleeValue, LoadInst *li) {
343343
/// Removes instructions that create the callee value if they are no
344344
/// longer necessary after inlining.
345345
static void cleanupCalleeValue(SILValue calleeValue,
346-
bool &needUpdateStackNesting) {
346+
bool &invalidatedStackNesting) {
347347
// Handle the case where the callee of the apply is a load instruction. If we
348348
// fail to optimize, return. Otherwise, see if we can look through other
349349
// abstractions on our callee.
@@ -383,7 +383,7 @@ static void cleanupCalleeValue(SILValue calleeValue,
383383
return;
384384
calleeValue = callee;
385385
}
386-
needUpdateStackNesting = true;
386+
invalidatedStackNesting = true;
387387

388388
calleeValue = stripCopiesAndBorrows(calleeValue);
389389

@@ -450,7 +450,7 @@ class ClosureCleanup {
450450
public:
451451
/// Set to true if some alloc/dealloc_stack instruction are inserted and at
452452
/// the end of the run stack nesting needs to be corrected.
453-
bool needUpdateStackNesting = false;
453+
bool invalidatedStackNesting = false;
454454

455455
/// This regular instruction deletion callback checks for any function-type
456456
/// values that may be unused after deleting the given instruction.
@@ -481,7 +481,7 @@ class ClosureCleanup {
481481
continue;
482482

483483
if (auto *SVI = dyn_cast<SingleValueInstruction>(I.getValue()))
484-
cleanupCalleeValue(SVI, needUpdateStackNesting);
484+
cleanupCalleeValue(SVI, invalidatedStackNesting);
485485
}
486486
}
487487
};
@@ -812,7 +812,7 @@ runOnFunctionRecursively(SILOptFunctionBuilder &FuncBuilder,
812812

813813
SmallVector<ParameterConvention, 16> CapturedArgConventions;
814814
SmallVector<SILValue, 32> FullArgs;
815-
bool needUpdateStackNesting = false;
815+
bool invalidatedStackNesting = false;
816816

817817
// Visiting blocks in reverse order avoids revisiting instructions after block
818818
// splitting, which would be quadratic.
@@ -930,7 +930,7 @@ runOnFunctionRecursively(SILOptFunctionBuilder &FuncBuilder,
930930
closureCleanup.recordDeadFunction(I);
931931
});
932932

933-
needUpdateStackNesting |= Inliner.needsUpdateStackNesting(InnerAI);
933+
invalidatedStackNesting |= Inliner.invalidatesStackNesting(InnerAI);
934934

935935
// Inlining deletes the apply, and can introduce multiple new basic
936936
// blocks. After this, CalleeValue and other instructions may be invalid.
@@ -944,7 +944,7 @@ runOnFunctionRecursively(SILOptFunctionBuilder &FuncBuilder,
944944
// we may be able to remove dead callee computations (e.g. dead
945945
// partial_apply closures).
946946
closureCleanup.cleanupDeadClosures(F);
947-
needUpdateStackNesting |= closureCleanup.needUpdateStackNesting;
947+
invalidatedStackNesting |= closureCleanup.invalidatedStackNesting;
948948

949949
// Resume inlining within nextBB, which contains only the inlined
950950
// instructions and possibly instructions in the original call block that
@@ -953,7 +953,7 @@ runOnFunctionRecursively(SILOptFunctionBuilder &FuncBuilder,
953953
}
954954
}
955955

956-
if (needUpdateStackNesting) {
956+
if (invalidatedStackNesting) {
957957
StackNesting().correctStackNesting(F);
958958
}
959959

lib/SILOptimizer/SILCombiner/SILCombine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ bool SILCombiner::runOnFunction(SILFunction &F) {
230230
Iteration++;
231231
}
232232

233-
if (needUpdateStackNesting) {
233+
if (invalidatedStackNesting) {
234234
StackNesting().correctStackNesting(&F);
235235
}
236236

lib/SILOptimizer/SILCombiner/SILCombiner.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class SILCombiner :
6767

6868
/// Set to true if some alloc/dealloc_stack instruction are inserted and at
6969
/// the end of the run stack nesting needs to be corrected.
70-
bool needUpdateStackNesting = false;
70+
bool invalidatedStackNesting = false;
7171

7272
/// The current iteration of the SILCombine.
7373
unsigned Iteration;

lib/SILOptimizer/SILCombiner/SILCombinerApplyVisitors.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,14 @@ SILInstruction *SILCombiner::visitPartialApplyInst(PartialApplyInst *PAI) {
107107
bool argsAreKeptAlive = tryOptimizeApplyOfPartialApply(
108108
PAI, Builder.getBuilderContext(), getInstModCallbacks());
109109
if (argsAreKeptAlive)
110-
needUpdateStackNesting = true;
110+
invalidatedStackNesting = true;
111111

112112
// Try to delete the partial_apply.
113113
// In case it became dead because of tryOptimizeApplyOfPartialApply, we don't
114114
// need to copy all arguments again (to extend their lifetimes), because it
115115
// was already done in tryOptimizeApplyOfPartialApply.
116116
if (tryDeleteDeadClosure(PAI, getInstModCallbacks(), !argsAreKeptAlive))
117-
needUpdateStackNesting = true;
117+
invalidatedStackNesting = true;
118118

119119
return nullptr;
120120
}

lib/SILOptimizer/Transforms/PerformanceInliner.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,7 @@ bool SILPerformanceInliner::inlineCallsIntoFunction(SILFunction *Caller) {
888888
// remains valid.
889889
SmallVector<FullApplySite, 8> AppliesToInline;
890890
collectAppliesToInline(Caller, AppliesToInline);
891-
bool needUpdateStackNesting = false;
891+
bool invalidatedStackNesting = false;
892892

893893
if (AppliesToInline.empty())
894894
return false;
@@ -918,7 +918,7 @@ bool SILPerformanceInliner::inlineCallsIntoFunction(SILFunction *Caller) {
918918

919919
// Note that this must happen before inlining as the apply instruction
920920
// will be deleted after inlining.
921-
needUpdateStackNesting |= SILInliner::needsUpdateStackNesting(AI);
921+
invalidatedStackNesting |= SILInliner::invalidatesStackNesting(AI);
922922

923923
// We've already determined we should be able to inline this, so
924924
// unconditionally inline the function.
@@ -933,7 +933,7 @@ bool SILPerformanceInliner::inlineCallsIntoFunction(SILFunction *Caller) {
933933
// reestablish a canonical CFG.
934934
mergeBasicBlocks(Caller);
935935

936-
if (needUpdateStackNesting) {
936+
if (invalidatedStackNesting) {
937937
StackNesting().correctStackNesting(Caller);
938938
}
939939

0 commit comments

Comments
 (0)