Skip to content

Commit 649d7f1

Browse files
committed
Optimizer: rename BorrowArgumentsUpdater -> GuaranteedPhiUpdater
NFC
1 parent 6472ee8 commit 649d7f1

File tree

19 files changed

+40
-40
lines changed

19 files changed

+40
-40
lines changed

SwiftCompilerSources/Sources/Optimizer/PassManager/PassRegistration.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,5 +136,5 @@ private func registerSwiftAnalyses() {
136136

137137
private func registerUtilities() {
138138
registerVerifier()
139-
registerBorrowArgumentsUpdater()
139+
registerGuaranteedPhiUpdater()
140140
}

SwiftCompilerSources/Sources/Optimizer/Utilities/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
swift_compiler_sources(Optimizer
1010
AccessUtilsTest.swift
1111
AddressUtils.swift
12-
BorrowArgumentsUpdater.swift
12+
GuaranteedPhiUpdater.swift
1313
BorrowUtils.swift
1414
SpecializationCloner.swift
1515
DiagnosticEngine.swift

SwiftCompilerSources/Sources/Optimizer/Utilities/BorrowArgumentsUpdater.swift renamed to SwiftCompilerSources/Sources/Optimizer/Utilities/GuaranteedPhiUpdater.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===--- BorrowArgumentsUpdater.swift -------------------------------------===//
1+
//===--- GuaranteedPhiUpdater.swift ---------------------------------------===//
22
//
33
// This source file is part of the Swift.org open source project
44
//
@@ -14,13 +14,13 @@ import SIL
1414
import OptimizerBridging
1515

1616
/// Updates the reborrow flags and the borrowed-from instructions for all guaranteed phis in `function`.
17-
func updateBorrowArguments(in function: Function, _ context: some MutatingContext) {
17+
func updateGuaranteedPhis(in function: Function, _ context: some MutatingContext) {
1818
updateReborrowFlags(in: function, context)
1919
updateBorrowedFrom(in: function, context)
2020
}
2121

2222
/// Updates the reborrow flags and the borrowed-from instructions for all `phis`.
23-
func updateBorrowArguments(for phis: some Sequence<Phi>, _ context: some MutatingContext) {
23+
func updateGuaranteedPhis(phis: some Sequence<Phi>, _ context: some MutatingContext) {
2424
updateReborrowFlags(for: phis, context)
2525
updateBorrowedFrom(for: phis, context)
2626
}
@@ -151,12 +151,12 @@ private func addEnclosingValues(
151151
return true
152152
}
153153

154-
func registerBorrowArgumentsUpdater() {
155-
BridgedUtilities.registerBorrowArgumentsUpdater(
154+
func registerGuaranteedPhiUpdater() {
155+
BridgedUtilities.registerGuaranteedPhiUpdater(
156156
{ (bridgedCtxt: BridgedPassContext, bridgedFunction: BridgedFunction) in
157157
let context = FunctionPassContext(_bridged: bridgedCtxt)
158158
let function = bridgedFunction.function;
159-
updateBorrowArguments(in: function, context)
159+
updateGuaranteedPhis(in: function, context)
160160
},
161161
{ (bridgedCtxt: BridgedPassContext, bridgedPhiArray: BridgedArrayRef) in
162162
let context = FunctionPassContext(_bridged: bridgedCtxt)
@@ -170,7 +170,7 @@ func registerBorrowArgumentsUpdater() {
170170
}
171171
}
172172
}
173-
updateBorrowArguments(for: guaranteedPhis, context)
173+
updateGuaranteedPhis(phis: guaranteedPhis, context)
174174
}
175175
)
176176
}

include/swift/SILOptimizer/OptimizerBridging.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ struct BridgedUtilities {
134134
typedef void (* _Nonnull UpdatePhisFn)(BridgedPassContext, BridgedArrayRef);
135135

136136
static void registerVerifier(VerifyFunctionFn verifyFunctionFn);
137-
static void registerBorrowArgumentsUpdater(UpdateFunctionFn updateBorrowedFromFn,
138-
UpdatePhisFn updateBorrowedFromPhisFn);
137+
static void registerGuaranteedPhiUpdater(UpdateFunctionFn updateBorrowedFromFn,
138+
UpdatePhisFn updateBorrowedFromPhisFn);
139139
};
140140

141141
struct BridgedBasicBlockSet {

include/swift/SILOptimizer/Utils/OwnershipOptUtils.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,10 +359,10 @@ bool extendStoreBorrow(StoreBorrowInst *sbi,
359359

360360
/// Updates the reborrow flags and the borrowed-from instructions for all
361361
/// guaranteed phis in function `f`.
362-
void updateAllBorrowArguments(SILPassManager *pm, SILFunction *f);
362+
void updateAllGuaranteedPhis(SILPassManager *pm, SILFunction *f);
363363

364364
/// Updates the reborrow flags and the borrowed-from instructions for all `phis`.
365-
void updateBorrowArguments(SILPassManager *pm, ArrayRef<SILPhiArgument *> phis);
365+
void updateGuaranteedPhis(SILPassManager *pm, ArrayRef<SILPhiArgument *> phis);
366366

367367
} // namespace swift
368368

lib/SILOptimizer/LoopTransforms/ArrayPropertyOpt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,7 @@ class SwiftArrayPropertyOptPass : public SILFunctionTransform {
837837
if (getFunction()->getModule().getOptions().VerifyAll)
838838
getFunction()->verifyCriticalEdges();
839839

840-
updateAllBorrowArguments(getPassManager(), Fn);
840+
updateAllGuaranteedPhis(getPassManager(), Fn);
841841

842842
// We preserve the dominator tree. Let's invalidate everything
843843
// else.

lib/SILOptimizer/LoopTransforms/LoopRotate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ class LoopRotation : public SILFunctionTransform {
506506
}
507507

508508
if (changed) {
509-
updateAllBorrowArguments(PM, f);
509+
updateAllGuaranteedPhis(PM, f);
510510
// We preserve loop info and the dominator tree.
511511
domAnalysis->lockInvalidation();
512512
loopAnalysis->lockInvalidation();

lib/SILOptimizer/Mandatory/ClosureLifetimeFixup.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1529,7 +1529,7 @@ class ClosureLifetimeFixup : public SILFunctionTransform {
15291529
if (fixupClosureLifetimes(*getFunction(), dominanceAnalysis,
15301530
deadEndBlocksAnalysis, checkStackNesting,
15311531
modifiedCFG)) {
1532-
updateAllBorrowArguments(getPassManager(), getFunction());
1532+
updateAllGuaranteedPhis(getPassManager(), getFunction());
15331533
if (checkStackNesting){
15341534
modifiedCFG |=
15351535
StackNesting::fixNesting(getFunction()) == StackNesting::Changes::CFG;

lib/SILOptimizer/SILCombiner/SILCombine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ class SILCombine : public SILFunctionTransform {
620620
bool Changed = Combiner.runOnFunction(*getFunction());
621621

622622
if (Changed) {
623-
updateAllBorrowArguments(getPassManager(), getFunction());
623+
updateAllGuaranteedPhis(getPassManager(), getFunction());
624624
// Invalidate everything.
625625
invalidateAnalysis(SILAnalysis::InvalidationKind::FunctionBody);
626626
}

lib/SILOptimizer/SemanticARC/OwnedToGuaranteedPhiOpt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ bool swift::semanticarc::tryConvertOwnedPhisToGuaranteedPhis(Context &ctx) {
268268
}
269269

270270
if (madeChange)
271-
updateAllBorrowArguments(ctx.pm, &ctx.fn);
271+
updateAllGuaranteedPhis(ctx.pm, &ctx.fn);
272272

273273
return madeChange;
274274
}

lib/SILOptimizer/SemanticARC/SemanticARCOpts.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ struct SemanticARCOpts : SILFunctionTransform {
177177
// converted to guaranteed, ignoring the phi, try convert those phis to be
178178
// guaranteed.
179179
if (tryConvertOwnedPhisToGuaranteedPhis(visitor.ctx)) {
180-
updateAllBorrowArguments(getPassManager(), &f);
180+
updateAllGuaranteedPhis(getPassManager(), &f);
181181

182182
// We return here early to save a little compile time so we do not
183183
// invalidate analyses redundantly.
@@ -187,7 +187,7 @@ struct SemanticARCOpts : SILFunctionTransform {
187187

188188
// Otherwise, we only deleted instructions and did not touch phis.
189189
if (didEliminateARCInsts) {
190-
updateAllBorrowArguments(getPassManager(), &f);
190+
updateAllGuaranteedPhis(getPassManager(), &f);
191191
invalidateAnalysis(SILAnalysis::InvalidationKind::Instructions);
192192
}
193193
}

lib/SILOptimizer/Transforms/ConditionForwarding.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class ConditionForwarding : public SILFunctionTransform {
117117
}
118118
}
119119
if (Changed) {
120-
updateAllBorrowArguments(getPassManager(), F);
120+
updateAllGuaranteedPhis(getPassManager(), F);
121121
invalidateAnalysis(SILAnalysis::InvalidationKind::BranchesAndInstructions);
122122
}
123123
}

lib/SILOptimizer/Transforms/CopyPropagation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ void CopyPropagation::run() {
635635

636636
// Invalidate analyses.
637637
if (changed || deleter.hadCallbackInvocation()) {
638-
updateAllBorrowArguments(getPassManager(), getFunction());
638+
updateAllGuaranteedPhis(getPassManager(), getFunction());
639639
// Preserves NonLocalAccessBlockAnalysis.
640640
accessBlockAnalysis->lockInvalidation();
641641
invalidateAnalysis(SILAnalysis::InvalidationKind::Instructions);

lib/SILOptimizer/Transforms/PerformanceInliner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1286,7 +1286,7 @@ bool SILPerformanceInliner::inlineCallsIntoFunction(SILFunction *Caller) {
12861286
if (invalidatedStackNesting) {
12871287
StackNesting::fixNesting(Caller);
12881288
}
1289-
updateAllBorrowArguments(pm, Caller);
1289+
updateAllGuaranteedPhis(pm, Caller);
12901290

12911291
// If we were asked to verify our caller after inlining all callees we could
12921292
// find into it, do so now. This makes it easier to catch verification bugs in

lib/SILOptimizer/Transforms/SILMem2Reg.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2297,7 +2297,7 @@ class SILMem2Reg : public SILFunctionTransform {
22972297
accessBlockAnalysis, calleeAnalysis)
22982298
.run();
22992299
if (madeChange) {
2300-
updateAllBorrowArguments(getPassManager(), f);
2300+
updateAllGuaranteedPhis(getPassManager(), f);
23012301
invalidateAnalysis(SILAnalysis::InvalidationKind::Instructions);
23022302
}
23032303
}

lib/SILOptimizer/Transforms/SimplifyCFG.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2189,7 +2189,7 @@ bool SimplifyCFG::simplifySwitchEnumBlock(SwitchEnumInst *SEI) {
21892189
}
21902190
Builder.createBranch(loc, LiveBlock, PayLoad);
21912191
SEI->eraseFromParent();
2192-
updateBorrowArguments(PM, { cast<SILPhiArgument>(LiveBlock->getArgument(0)) });
2192+
updateGuaranteedPhis(PM, { cast<SILPhiArgument>(LiveBlock->getArgument(0)) });
21932193
} else {
21942194
if (SEI->getOperand()->getOwnershipKind() == OwnershipKind::Owned) {
21952195
Builder.createDestroyValue(loc, SEI->getOperand());
@@ -3784,7 +3784,7 @@ bool SimplifyCFG::simplifyArgument(SILBasicBlock *BB, unsigned i) {
37843784

37853785
proj->eraseFromParent();
37863786

3787-
updateBorrowArguments(PM, { NewArg });
3787+
updateGuaranteedPhis(PM, { NewArg });
37883788

37893789
return true;
37903790
}

lib/SILOptimizer/Utils/BasicBlockOptUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ void BasicBlockCloner::updateSSAAfterCloning() {
169169
}
170170
}
171171
}
172-
updateBorrowArguments(pm, updateSSAPhis);
172+
updateGuaranteedPhis(pm, updateSSAPhis);
173173
}
174174

175175
void BasicBlockCloner::sinkAddressProjections() {

lib/SILOptimizer/Utils/InstOptUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ swift::castValueToABICompatibleType(SILBuilder *builder, SILPassManager *pm,
687687
builder->createBranch(loc, contBB, {noneValue});
688688
builder->setInsertionPoint(contBB->begin());
689689

690-
updateBorrowArguments(pm, { phi });
690+
updateGuaranteedPhis(pm, { phi });
691691

692692
return {lookThroughBorrowedFromUser(phi), true};
693693
}

lib/SILOptimizer/Utils/OwnershipOptUtils.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,27 +1913,27 @@ bool swift::extendStoreBorrow(StoreBorrowInst *sbi,
19131913
// Swift Bridging
19141914
//===----------------------------------------------------------------------===//
19151915

1916-
static BridgedUtilities::UpdateFunctionFn updateAllBorrowArgumentsFunction;
1917-
static BridgedUtilities::UpdatePhisFn updateBorrowArgumentsFunction;
1916+
static BridgedUtilities::UpdateFunctionFn updateAllGuaranteedPhisFunction;
1917+
static BridgedUtilities::UpdatePhisFn updateGuaranteedPhisFunction;
19181918

1919-
void BridgedUtilities::registerBorrowArgumentsUpdater(UpdateFunctionFn updateAllBorrowArgumentsFn,
1920-
UpdatePhisFn updateBorrowArgumentsFn) {
1921-
updateAllBorrowArgumentsFunction = updateAllBorrowArgumentsFn;
1922-
updateBorrowArgumentsFunction = updateBorrowArgumentsFn;
1919+
void BridgedUtilities::registerGuaranteedPhiUpdater(UpdateFunctionFn updateAllGuaranteedPhisFn,
1920+
UpdatePhisFn updateGuaranteedPhisFn) {
1921+
updateAllGuaranteedPhisFunction = updateAllGuaranteedPhisFn;
1922+
updateGuaranteedPhisFunction = updateGuaranteedPhisFn;
19231923
}
19241924

1925-
void swift::updateAllBorrowArguments(SILPassManager *pm, SILFunction *f) {
1926-
if (updateAllBorrowArgumentsFunction)
1927-
updateAllBorrowArgumentsFunction({pm->getSwiftPassInvocation()}, {f});
1925+
void swift::updateAllGuaranteedPhis(SILPassManager *pm, SILFunction *f) {
1926+
if (updateAllGuaranteedPhisFunction)
1927+
updateAllGuaranteedPhisFunction({pm->getSwiftPassInvocation()}, {f});
19281928
}
19291929

1930-
void swift::updateBorrowArguments(SILPassManager *pm, ArrayRef<SILPhiArgument *> phis) {
1931-
if (!updateBorrowArgumentsFunction)
1930+
void swift::updateGuaranteedPhis(SILPassManager *pm, ArrayRef<SILPhiArgument *> phis) {
1931+
if (!updateGuaranteedPhisFunction)
19321932
return;
19331933

19341934
llvm::SmallVector<BridgedValue, 8> bridgedPhis;
19351935
for (SILPhiArgument *phi : phis) {
19361936
bridgedPhis.push_back({phi});
19371937
}
1938-
updateBorrowArgumentsFunction({pm->getSwiftPassInvocation()}, ArrayRef(bridgedPhis));
1938+
updateGuaranteedPhisFunction({pm->getSwiftPassInvocation()}, ArrayRef(bridgedPhis));
19391939
}

0 commit comments

Comments
 (0)