21
21
// / an OSSA reference after propagating that reference through all copies. For
22
22
// / owned references, this is a simple process of canonicalization that can be
23
23
// / 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
25
25
// / much more involved. It requires coordination to cleanup owned lifetimes
26
26
// / outside the borrow scope after canonicalizing the scope itself.
27
27
// /
59
59
#include " swift/SILOptimizer/Analysis/DeadEndBlocksAnalysis.h"
60
60
#include " swift/SILOptimizer/PassManager/Passes.h"
61
61
#include " swift/SILOptimizer/PassManager/Transforms.h"
62
- #include " swift/SILOptimizer/Utils/CanonicalizeBorrowScope.h"
63
62
#include " swift/SILOptimizer/Utils/InstOptUtils.h"
63
+ #include " swift/SILOptimizer/Utils/OSSACanonicalizeGuaranteed.h"
64
64
#include " swift/SILOptimizer/Utils/OSSACanonicalizeOwned.h"
65
65
#include " swift/SILOptimizer/Utils/OwnershipOptUtils.h"
66
66
#include " llvm/ADT/SetVector.h"
@@ -108,7 +108,7 @@ struct CanonicalDefWorklist {
108
108
// extended lifetime.
109
109
if (auto *copy = dyn_cast<CopyValueInst>(def)) {
110
110
if (SILValue borrowDef =
111
- CanonicalizeBorrowScope ::getCanonicalBorrowedDef (
111
+ OSSACanonicalizeGuaranteed ::getCanonicalBorrowedDef (
112
112
copy->getOperand ())) {
113
113
if (canonicalizeBorrows || isa<SILFunctionArgument>(borrowDef)) {
114
114
borrowedValues.insert (borrowDef);
@@ -123,7 +123,7 @@ struct CanonicalDefWorklist {
123
123
// Look through hoistable owned forwarding instructions on the
124
124
// use-def chain.
125
125
if (SILInstruction *defInst = def->getDefiningInstruction ()) {
126
- if (CanonicalizeBorrowScope ::isRewritableOSSAForward (defInst)) {
126
+ if (OSSACanonicalizeGuaranteed ::isRewritableOSSAForward (defInst)) {
127
127
SILValue forwardedDef = defInst->getOperand (0 );
128
128
if (forwardedDef->getOwnershipKind () == OwnershipKind::Owned) {
129
129
def = forwardedDef;
@@ -151,7 +151,7 @@ struct CanonicalDefWorklist {
151
151
useWorklist.append (copy->getUses ().begin (), copy->getUses ().end ());
152
152
continue ;
153
153
}
154
- if (!CanonicalizeBorrowScope ::isRewritableOSSAForward (user))
154
+ if (!OSSACanonicalizeGuaranteed ::isRewritableOSSAForward (user))
155
155
continue ;
156
156
157
157
if (!ownedForwards.insert (user))
@@ -210,7 +210,7 @@ struct CanonicalDefWorklist {
210
210
// / This allows the ownership of '%src' to be forwarded to its member.
211
211
// /
212
212
// / This utility runs during copy propagation as a prerequisite to
213
- // / CanonicalizeBorrowScopes .
213
+ // / OSSACanonicalizeGuaranteeds .
214
214
// /
215
215
// / TODO: generalize this to handle multiple nondebug uses of the
216
216
// / struct_extract.
@@ -562,7 +562,7 @@ void CopyPropagation::propagateCopies(
562
562
}
563
563
// borrowCanonicalizer performs all modifications through deleter's
564
564
// callbacks, so we don't need to explicitly check for changes.
565
- CanonicalizeBorrowScope borrowCanonicalizer (f, deleter);
565
+ OSSACanonicalizeGuaranteed borrowCanonicalizer (f, deleter);
566
566
// The utilities in this loop cannot delete borrows before they are popped
567
567
// from the worklist.
568
568
while (true ) {
@@ -581,7 +581,7 @@ void CopyPropagation::propagateCopies(
581
581
// Canonicalize a forwarded owned value before sinking the forwarding
582
582
// instruction, and sink the instruction before canonicalizing the owned
583
583
// 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
585
585
// top-down.
586
586
for (auto result : ownedForward->getResults ()) {
587
587
if (!continueWithNextSubpassRun (result))
@@ -599,7 +599,7 @@ void CopyPropagation::propagateCopies(
599
599
OSSACanonicalizeOwned::getCanonicalCopiedDef (
600
600
ownedForward->getOperand (0 ))
601
601
->getDefiningInstruction ()) {
602
- if (CanonicalizeBorrowScope ::isRewritableOSSAForward (forwardDef)) {
602
+ if (OSSACanonicalizeGuaranteed ::isRewritableOSSAForward (forwardDef)) {
603
603
defWorklist.ownedForwards .insert (forwardDef);
604
604
}
605
605
}
0 commit comments