Skip to content

Commit 5da38cb

Browse files
committed
[NFC] OSSACanonicalizeGuaranteed: Renamed.
1 parent 8f1d661 commit 5da38cb

File tree

12 files changed

+94
-94
lines changed

12 files changed

+94
-94
lines changed

include/swift/SILOptimizer/Utils/CanonicalizeBorrowScope.h renamed to include/swift/SILOptimizer/Utils/OSSACanonicalizeGuaranteed.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===--- CanonicalizeBorrowScope.h - Canonicalize OSSA borrows --*- C++ -*-===//
1+
//===- OSSACanonicalizeGuaranteed.h - Canonicalize OSSA borrows -*- C++ -*-===//
22
//
33
// This source file is part of the Swift.org open source project
44
//
@@ -40,10 +40,10 @@ namespace swift {
4040
class BasicCalleeAnalysis;
4141

4242
//===----------------------------------------------------------------------===//
43-
// MARK: CanonicalizeBorrowScope
43+
// MARK: OSSACanonicalizeGuaranteed
4444
//===----------------------------------------------------------------------===//
4545

46-
class CanonicalizeBorrowScope {
46+
class OSSACanonicalizeGuaranteed {
4747
public:
4848
/// Return true if \p inst is an instructions that forwards ownership is its
4949
/// first operand and can be trivially duplicated, sunk to its uses, hoisted
@@ -88,7 +88,7 @@ class CanonicalizeBorrowScope {
8888
llvm::SmallDenseMap<SILBasicBlock *, CopyValueInst *, 4> persistentCopies;
8989

9090
public:
91-
CanonicalizeBorrowScope(SILFunction *function, InstructionDeleter &deleter)
91+
OSSACanonicalizeGuaranteed(SILFunction *function, InstructionDeleter &deleter)
9292
: function(function), deleter(deleter) {}
9393

9494
BorrowedValue getBorrowedValue() const { return borrowedValue; }

include/swift/SILOptimizer/Utils/OSSACanonicalizeOwned.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ class OSSACanonicalizeOwned final {
210210
/// If the source of a copy is guaranteed, then the copy itself is the root of
211211
/// an owned extended lifetime. Note that it will also be part of a borrowed
212212
/// extended lifetime, which will be canonicalized separately by
213-
/// CanonicalizeBorrowScope.
213+
/// OSSACanonicalizeGuaranteed.
214214
///
215215
/// This use-def walk must be consistent with the def-use walks performed
216216
/// within the canonicalizeValueLifetime() and canonicalizeBorrowScopes()

include/swift/SILOptimizer/Utils/OwnershipOptUtils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ void extendOwnedLifetime(SILValue ownedValue,
6161
///
6262
/// Precondition: guaranteedBoundary is a superset of beginBorrow's current
6363
/// scope (therefore, none of the safety checks done during
64-
/// CanonicalizeBorrowScope are needed here).
64+
/// OSSACanonicalizeGuaranteed are needed here).
6565
void extendLocalBorrow(BeginBorrowInst *beginBorrow,
6666
PrunedLivenessBoundary &guaranteedBoundary,
6767
InstructionDeleter &deleter);

lib/SILOptimizer/SILCombiner/SILCombine.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@
3333
#include "swift/SILOptimizer/Analysis/SimplifyInstruction.h"
3434
#include "swift/SILOptimizer/PassManager/PassManager.h"
3535
#include "swift/SILOptimizer/PassManager/Transforms.h"
36-
#include "swift/SILOptimizer/Utils/CanonicalizeBorrowScope.h"
3736
#include "swift/SILOptimizer/Utils/CanonicalizeInstruction.h"
3837
#include "swift/SILOptimizer/Utils/DebugOptUtils.h"
3938
#include "swift/SILOptimizer/Utils/InstOptUtils.h"
39+
#include "swift/SILOptimizer/Utils/OSSACanonicalizeGuaranteed.h"
4040
#include "swift/SILOptimizer/Utils/OSSACanonicalizeOwned.h"
4141
#include "swift/SILOptimizer/Utils/SILOptFunctionBuilder.h"
4242
#include "swift/SILOptimizer/Utils/StackNesting.h"
@@ -325,8 +325,9 @@ void SILCombiner::canonicalizeOSSALifetimes(SILInstruction *currentInst) {
325325
// fast convergence, rewriting borrow scopes should not be combined with
326326
// other unrelated transformations.
327327
if (auto *copyDef = dyn_cast<CopyValueInst>(def)) {
328-
if (SILValue borrowDef = CanonicalizeBorrowScope::getCanonicalBorrowedDef(
329-
copyDef->getOperand())) {
328+
if (SILValue borrowDef =
329+
OSSACanonicalizeGuaranteed::getCanonicalBorrowedDef(
330+
copyDef->getOperand())) {
330331
if (isa<SILFunctionArgument>(borrowDef)) {
331332
def = borrowDef;
332333
}
@@ -362,8 +363,8 @@ void SILCombiner::canonicalizeOSSALifetimes(SILInstruction *currentInst) {
362363
DontPruneDebugInsts,
363364
MaximizeLifetime_t(!parentTransform->getFunction()->shouldOptimize()),
364365
parentTransform->getFunction(), NLABA, DEBA, domTree, CA, deleter);
365-
CanonicalizeBorrowScope borrowCanonicalizer(parentTransform->getFunction(),
366-
deleter);
366+
OSSACanonicalizeGuaranteed borrowCanonicalizer(parentTransform->getFunction(),
367+
deleter);
367368

368369
while (!defsToCanonicalize.empty()) {
369370
SILValue def = defsToCanonicalize.pop_back_val();

lib/SILOptimizer/Transforms/CopyPropagation.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
/// an OSSA reference after propagating that reference through all copies. For
2222
/// owned references, this is a simple process of canonicalization that can be
2323
/// invoked separately via the OSSACanonicalizeOwned utility. The
24-
/// CanonicalizeBorrowScope utility handles borrowed references, but this is
24+
/// OSSACanonicalizeGuaranteed utility handles borrowed references, but this is
2525
/// much more involved. It requires coordination to cleanup owned lifetimes
2626
/// outside the borrow scope after canonicalizing the scope itself.
2727
///
@@ -59,8 +59,8 @@
5959
#include "swift/SILOptimizer/Analysis/DeadEndBlocksAnalysis.h"
6060
#include "swift/SILOptimizer/PassManager/Passes.h"
6161
#include "swift/SILOptimizer/PassManager/Transforms.h"
62-
#include "swift/SILOptimizer/Utils/CanonicalizeBorrowScope.h"
6362
#include "swift/SILOptimizer/Utils/InstOptUtils.h"
63+
#include "swift/SILOptimizer/Utils/OSSACanonicalizeGuaranteed.h"
6464
#include "swift/SILOptimizer/Utils/OSSACanonicalizeOwned.h"
6565
#include "swift/SILOptimizer/Utils/OwnershipOptUtils.h"
6666
#include "llvm/ADT/SetVector.h"
@@ -108,7 +108,7 @@ struct CanonicalDefWorklist {
108108
// extended lifetime.
109109
if (auto *copy = dyn_cast<CopyValueInst>(def)) {
110110
if (SILValue borrowDef =
111-
CanonicalizeBorrowScope::getCanonicalBorrowedDef(
111+
OSSACanonicalizeGuaranteed::getCanonicalBorrowedDef(
112112
copy->getOperand())) {
113113
if (canonicalizeBorrows || isa<SILFunctionArgument>(borrowDef)) {
114114
borrowedValues.insert(borrowDef);
@@ -123,7 +123,7 @@ struct CanonicalDefWorklist {
123123
// Look through hoistable owned forwarding instructions on the
124124
// use-def chain.
125125
if (SILInstruction *defInst = def->getDefiningInstruction()) {
126-
if (CanonicalizeBorrowScope::isRewritableOSSAForward(defInst)) {
126+
if (OSSACanonicalizeGuaranteed::isRewritableOSSAForward(defInst)) {
127127
SILValue forwardedDef = defInst->getOperand(0);
128128
if (forwardedDef->getOwnershipKind() == OwnershipKind::Owned) {
129129
def = forwardedDef;
@@ -151,7 +151,7 @@ struct CanonicalDefWorklist {
151151
useWorklist.append(copy->getUses().begin(), copy->getUses().end());
152152
continue;
153153
}
154-
if (!CanonicalizeBorrowScope::isRewritableOSSAForward(user))
154+
if (!OSSACanonicalizeGuaranteed::isRewritableOSSAForward(user))
155155
continue;
156156

157157
if (!ownedForwards.insert(user))
@@ -210,7 +210,7 @@ struct CanonicalDefWorklist {
210210
/// This allows the ownership of '%src' to be forwarded to its member.
211211
///
212212
/// This utility runs during copy propagation as a prerequisite to
213-
/// CanonicalizeBorrowScopes.
213+
/// OSSACanonicalizeGuaranteeds.
214214
///
215215
/// TODO: generalize this to handle multiple nondebug uses of the
216216
/// struct_extract.
@@ -562,7 +562,7 @@ void CopyPropagation::propagateCopies(
562562
}
563563
// borrowCanonicalizer performs all modifications through deleter's
564564
// callbacks, so we don't need to explicitly check for changes.
565-
CanonicalizeBorrowScope borrowCanonicalizer(f, deleter);
565+
OSSACanonicalizeGuaranteed borrowCanonicalizer(f, deleter);
566566
// The utilities in this loop cannot delete borrows before they are popped
567567
// from the worklist.
568568
while (true) {
@@ -581,7 +581,7 @@ void CopyPropagation::propagateCopies(
581581
// Canonicalize a forwarded owned value before sinking the forwarding
582582
// instruction, and sink the instruction before canonicalizing the owned
583583
// value being forwarded. Process 'ownedForwards' in reverse since
584-
// they may be chained, and CanonicalizeBorrowScopes pushes them
584+
// they may be chained, and OSSACanonicalizeGuaranteeds pushes them
585585
// top-down.
586586
for (auto result : ownedForward->getResults()) {
587587
if (!continueWithNextSubpassRun(result))
@@ -599,7 +599,7 @@ void CopyPropagation::propagateCopies(
599599
OSSACanonicalizeOwned::getCanonicalCopiedDef(
600600
ownedForward->getOperand(0))
601601
->getDefiningInstruction()) {
602-
if (CanonicalizeBorrowScope::isRewritableOSSAForward(forwardDef)) {
602+
if (OSSACanonicalizeGuaranteed::isRewritableOSSAForward(forwardDef)) {
603603
defWorklist.ownedForwards.insert(forwardDef);
604604
}
605605
}

lib/SILOptimizer/Transforms/SILMem2Reg.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
#include "swift/SILOptimizer/PassManager/Passes.h"
4141
#include "swift/SILOptimizer/PassManager/Transforms.h"
4242
#include "swift/SILOptimizer/Utils/CFGOptUtils.h"
43-
#include "swift/SILOptimizer/Utils/CanonicalizeBorrowScope.h"
4443
#include "swift/SILOptimizer/Utils/InstOptUtils.h"
44+
#include "swift/SILOptimizer/Utils/OSSACanonicalizeGuaranteed.h"
4545
#include "swift/SILOptimizer/Utils/OSSACanonicalizeOwned.h"
4646
#include "swift/SILOptimizer/Utils/OwnershipOptUtils.h"
4747
#include "swift/SILOptimizer/Utils/ScopeOptUtils.h"
@@ -2158,19 +2158,20 @@ void MemoryToRegisters::canonicalizeValueLifetimes(
21582158
continue;
21592159
auto root = OSSACanonicalizeOwned::getCanonicalCopiedDef(value);
21602160
if (auto *copy = dyn_cast<CopyValueInst>(root)) {
2161-
if (SILValue borrowDef = CanonicalizeBorrowScope::getCanonicalBorrowedDef(
2162-
copy->getOperand())) {
2161+
if (SILValue borrowDef =
2162+
OSSACanonicalizeGuaranteed::getCanonicalBorrowedDef(
2163+
copy->getOperand())) {
21632164
guaranteed.push_back(copy);
21642165
continue;
21652166
}
21662167
}
21672168
canonicalizer.canonicalizeValueLifetime(root);
21682169
}
2169-
CanonicalizeBorrowScope borrowCanonicalizer(&f, deleter);
2170+
OSSACanonicalizeGuaranteed borrowCanonicalizer(&f, deleter);
21702171
for (auto value : guaranteed) {
21712172
if (isa<SILUndef>(value) || value->isMarkedAsDeleted())
21722173
continue;
2173-
auto borrowee = CanonicalizeBorrowScope::getCanonicalBorrowedDef(value);
2174+
auto borrowee = OSSACanonicalizeGuaranteed::getCanonicalBorrowedDef(value);
21742175
if (!borrowee)
21752176
continue;
21762177
BorrowedValue borrow(borrowee);

lib/SILOptimizer/Utils/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ target_sources(swiftSILOptimizer PRIVATE
33
CFGOptUtils.cpp
44
CanonicalizeInstruction.cpp
55
OSSACanonicalizeOwned.cpp
6-
CanonicalizeBorrowScope.cpp
6+
OSSACanonicalizeGuaranteed.cpp
77
CastOptimizer.cpp
88
CheckedCastBrJumpThreading.cpp
99
CompileTimeInterpolationUtils.cpp

lib/SILOptimizer/Utils/LexicalDestroyFolding.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@
8989
#include "swift/SIL/Test.h"
9090
#include "swift/SILOptimizer/Analysis/Reachability.h"
9191
#include "swift/SILOptimizer/PassManager/Transforms.h"
92-
#include "swift/SILOptimizer/Utils/CanonicalizeBorrowScope.h"
9392
#include "swift/SILOptimizer/Utils/InstructionDeleter.h"
93+
#include "swift/SILOptimizer/Utils/OSSACanonicalizeGuaranteed.h"
9494
#include "swift/SILOptimizer/Utils/OSSACanonicalizeOwned.h"
9595
#include "swift/SILOptimizer/Utils/SILSSAUpdater.h"
9696
#include "llvm/ADT/SmallVector.h"

0 commit comments

Comments
 (0)