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// /
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 }
0 commit comments