diff --git a/docs/SIL/Instructions.md b/docs/SIL/Instructions.md index 38063fbd38927..3ea429b5c5324 100644 --- a/docs/SIL/Instructions.md +++ b/docs/SIL/Instructions.md @@ -1032,7 +1032,7 @@ extend_lifetime %0 : $X ``` Indicates that a value's linear lifetime extends to this point. -Inserted by OSSALifetimeCompletion(AvailabilityBoundary) in order to +Inserted by OSSACompleteLifetime(AvailabilityBoundary) in order to provide the invariant that a value is either consumed OR has an `extend_lifetime` user on all paths and furthermore that all uses are within the boundary defined by that set of instructions (the diff --git a/include/swift/SIL/OSSALifetimeCompletion.h b/include/swift/SIL/OSSACompleteLifetime.h similarity index 95% rename from include/swift/SIL/OSSALifetimeCompletion.h rename to include/swift/SIL/OSSACompleteLifetime.h index 73d23804c978b..c4153120615f3 100644 --- a/include/swift/SIL/OSSALifetimeCompletion.h +++ b/include/swift/SIL/OSSACompleteLifetime.h @@ -38,7 +38,7 @@ class DeadEndBlocks; enum class LifetimeCompletion { NoLifetime, AlreadyComplete, WasCompleted }; -class OSSALifetimeCompletion { +class OSSACompleteLifetime { public: enum HandleTrivialVariable_t { IgnoreTrivialVariable, ExtendTrivialVariable }; @@ -63,7 +63,7 @@ class OSSALifetimeCompletion { bool ForceLivenessVerification; public: - OSSALifetimeCompletion( + OSSACompleteLifetime( SILFunction *function, const DominanceInfo *domInfo, DeadEndBlocks &deadEndBlocks, HandleTrivialVariable_t handleTrivialVariable = IgnoreTrivialVariable, @@ -113,8 +113,8 @@ class OSSALifetimeCompletion { break; } // During SILGenCleanup, extend move_value [var_decl]. - if (handleTrivialVariable == ExtendTrivialVariable - && value->isFromVarDecl()) { + if (handleTrivialVariable == ExtendTrivialVariable && + value->isFromVarDecl()) { break; } return LifetimeCompletion::NoLifetime; @@ -203,13 +203,13 @@ class UnreachableLifetimeCompletion { bool completeLifetimes(); }; -inline llvm::raw_ostream & -operator<<(llvm::raw_ostream &OS, OSSALifetimeCompletion::Boundary boundary) { +inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, + OSSACompleteLifetime::Boundary boundary) { switch (boundary) { - case OSSALifetimeCompletion::Boundary::Liveness: + case OSSACompleteLifetime::Boundary::Liveness: OS << "liveness"; break; - case OSSALifetimeCompletion::Boundary::Availability: + case OSSACompleteLifetime::Boundary::Availability: OS << "availability"; break; } diff --git a/include/swift/SILOptimizer/Utils/CanonicalizeBorrowScope.h b/include/swift/SILOptimizer/Utils/OSSACanonicalizeGuaranteed.h similarity index 95% rename from include/swift/SILOptimizer/Utils/CanonicalizeBorrowScope.h rename to include/swift/SILOptimizer/Utils/OSSACanonicalizeGuaranteed.h index c683973489e57..f503df0ad7c6b 100644 --- a/include/swift/SILOptimizer/Utils/CanonicalizeBorrowScope.h +++ b/include/swift/SILOptimizer/Utils/OSSACanonicalizeGuaranteed.h @@ -1,4 +1,4 @@ -//===--- CanonicalizeBorrowScope.h - Canonicalize OSSA borrows --*- C++ -*-===// +//===- OSSACanonicalizeGuaranteed.h - Canonicalize OSSA borrows -*- C++ -*-===// // // This source file is part of the Swift.org open source project // @@ -14,7 +14,7 @@ /// to only the uses within the scope. To do this, it hoists forwarding /// operations out of the scope. This exposes many useless scopes that can be /// deleted, which in turn allows canonicalization of the outer owned values -/// (via CanonicalizeOSSALifetime). +/// (via OSSACanonicalizeOwned). /// /// This does not shrink borrow scopes; it does not rewrite end_borrows. For /// that, see ShrinkBorrowScope. @@ -40,10 +40,10 @@ namespace swift { class BasicCalleeAnalysis; //===----------------------------------------------------------------------===// -// MARK: CanonicalizeBorrowScope +// MARK: OSSACanonicalizeGuaranteed //===----------------------------------------------------------------------===// -class CanonicalizeBorrowScope { +class OSSACanonicalizeGuaranteed { public: /// Return true if \p inst is an instructions that forwards ownership is its /// first operand and can be trivially duplicated, sunk to its uses, hoisted @@ -88,7 +88,7 @@ class CanonicalizeBorrowScope { llvm::SmallDenseMap persistentCopies; public: - CanonicalizeBorrowScope(SILFunction *function, InstructionDeleter &deleter) + OSSACanonicalizeGuaranteed(SILFunction *function, InstructionDeleter &deleter) : function(function), deleter(deleter) {} BorrowedValue getBorrowedValue() const { return borrowedValue; } diff --git a/include/swift/SILOptimizer/Utils/CanonicalizeOSSALifetime.h b/include/swift/SILOptimizer/Utils/OSSACanonicalizeOwned.h similarity index 98% rename from include/swift/SILOptimizer/Utils/CanonicalizeOSSALifetime.h rename to include/swift/SILOptimizer/Utils/OSSACanonicalizeOwned.h index f686492a70e06..407feecaba3d3 100644 --- a/include/swift/SILOptimizer/Utils/CanonicalizeOSSALifetime.h +++ b/include/swift/SILOptimizer/Utils/OSSACanonicalizeOwned.h @@ -1,4 +1,4 @@ -//===- CanonicalizeOSSALifetime.h - Canonicalize OSSA lifetimes -*- C++ -*-===// +//===- OSSACanonicalizeOwned.h - Canonicalize OSSA lifetimes -*- C++ -*-===// // // This source file is part of the Swift.org open source project // @@ -14,7 +14,7 @@ /// /// This top-level API rewrites the extended OSSA lifetime of a SILValue: /// -/// void canonicalizeValueLifetime(SILValue def, CanonicalizeOSSALifetime &) +/// void canonicalizeValueLifetime(SILValue def, OSSACanonicalizeOwned &) /// /// The "extended lifetime" of the references defined by 'def' transitively /// includes the uses of 'def' itself along with the uses of any copies of @@ -197,7 +197,7 @@ enum MaximizeLifetime_t : bool { /// /// TODO: Move all the private per-definition members into an implementation /// class in the .cpp file. -class CanonicalizeOSSALifetime final { +class OSSACanonicalizeOwned final { public: /// Find the original definition of a potentially copied value. \p copiedValue /// must be an owned value. It is usually a copy but may also be a destroy. @@ -210,7 +210,7 @@ class CanonicalizeOSSALifetime final { /// If the source of a copy is guaranteed, then the copy itself is the root of /// an owned extended lifetime. Note that it will also be part of a borrowed /// extended lifetime, which will be canonicalized separately by - /// CanonicalizeBorrowScope. + /// OSSACanonicalizeGuaranteed. /// /// This use-def walk must be consistent with the def-use walks performed /// within the canonicalizeValueLifetime() and canonicalizeBorrowScopes() @@ -343,14 +343,14 @@ class CanonicalizeOSSALifetime final { struct LivenessState { BitfieldRef::StackState state; - LivenessState(CanonicalizeOSSALifetime &parent, SILValue def, + LivenessState(OSSACanonicalizeOwned &parent, SILValue def, ArrayRef lexicalLifetimeEnds) : state(parent.liveness, def->getFunction()) { parent.initializeLiveness(def, lexicalLifetimeEnds); } }; - CanonicalizeOSSALifetime( + OSSACanonicalizeOwned( PruneDebugInsts_t pruneDebugMode, MaximizeLifetime_t maximizeLifetime, SILFunction *function, NonLocalAccessBlockAnalysis *accessBlockAnalysis, DeadEndBlocksAnalysis *deadEndBlocksAnalysis, DominanceInfo *domTree, @@ -470,7 +470,7 @@ class CanonicalizeOSSALifetime final { } bool respectsDeadEnds() const { - // TODO: OSSALifetimeCompletion: Once lifetimes are always complete, delete + // TODO: OSSACompleteLifetime: Once lifetimes are always complete, delete // this method. return !endingLifetimeAtExplicitEnds(); } diff --git a/include/swift/SILOptimizer/Utils/OwnershipOptUtils.h b/include/swift/SILOptimizer/Utils/OwnershipOptUtils.h index 772766301b1a1..c3e74d8d52483 100644 --- a/include/swift/SILOptimizer/Utils/OwnershipOptUtils.h +++ b/include/swift/SILOptimizer/Utils/OwnershipOptUtils.h @@ -48,7 +48,7 @@ inline bool requiresOSSACleanup(SILValue v) { /// /// Precondition: lifetimeBoundary is a superset of ownedValue's current /// lifetime (therefore, none of the safety checks done during -/// CanonicalizeOSSALifetime are needed here). +/// OSSACanonicalizeOwned are needed here). void extendOwnedLifetime(SILValue ownedValue, PrunedLivenessBoundary &lifetimeBoundary, InstructionDeleter &deleter); @@ -61,7 +61,7 @@ void extendOwnedLifetime(SILValue ownedValue, /// /// Precondition: guaranteedBoundary is a superset of beginBorrow's current /// scope (therefore, none of the safety checks done during -/// CanonicalizeBorrowScope are needed here). +/// OSSACanonicalizeGuaranteed are needed here). void extendLocalBorrow(BeginBorrowInst *beginBorrow, PrunedLivenessBoundary &guaranteedBoundary, InstructionDeleter &deleter); diff --git a/lib/SIL/Utils/CMakeLists.txt b/lib/SIL/Utils/CMakeLists.txt index bb4ecf1edf78a..c04a6da4e779c 100644 --- a/lib/SIL/Utils/CMakeLists.txt +++ b/lib/SIL/Utils/CMakeLists.txt @@ -13,7 +13,7 @@ target_sources(swiftSIL PRIVATE MemAccessUtils.cpp MemoryLocations.cpp OptimizationRemark.cpp - OSSALifetimeCompletion.cpp + OSSACompleteLifetime.cpp OwnershipLiveness.cpp OwnershipUtils.cpp PrettyStackTrace.cpp diff --git a/lib/SIL/Utils/OSSALifetimeCompletion.cpp b/lib/SIL/Utils/OSSACompleteLifetime.cpp similarity index 88% rename from lib/SIL/Utils/OSSALifetimeCompletion.cpp rename to lib/SIL/Utils/OSSACompleteLifetime.cpp index 18cfdc9faccc2..a3fa3d9323a57 100644 --- a/lib/SIL/Utils/OSSALifetimeCompletion.cpp +++ b/lib/SIL/Utils/OSSACompleteLifetime.cpp @@ -1,4 +1,4 @@ -//===--- OSSALifetimeCompletion.cpp ---------------------------------------===// +//===--- OSSACompleteLifetime.cpp ---------------------------------------===// // // This source file is part of the Swift.org open source project // @@ -49,7 +49,7 @@ /// //===----------------------------------------------------------------------===// -#include "swift/SIL/OSSALifetimeCompletion.h" +#include "swift/SIL/OSSACompleteLifetime.h" #include "swift/Basic/Assertions.h" #include "swift/SIL/AddressWalker.h" #include "swift/SIL/BasicBlockUtils.h" @@ -64,17 +64,17 @@ using namespace swift; // FIXME: remove this option after fixing: // rdar://145994924 (Mem2Reg calls lifetime completion without checking for // pointer escapes) -llvm::cl::opt VerifyLifetimeCompletion( - "verify-lifetime-completion", llvm::cl::init(false), - llvm::cl::desc(".")); +llvm::cl::opt VerifyLifetimeCompletion("verify-lifetime-completion", + llvm::cl::init(false), + llvm::cl::desc(".")); static SILInstruction *endOSSALifetime(SILValue value, - OSSALifetimeCompletion::LifetimeEnd end, + OSSACompleteLifetime::LifetimeEnd end, SILBuilder &builder, DeadEndBlocks &deb) { auto loc = - RegularLocation::getAutoGeneratedLocation(builder.getInsertionPointLoc()); - if (end == OSSALifetimeCompletion::LifetimeEnd::Loop) { + RegularLocation::getAutoGeneratedLocation(builder.getInsertionPointLoc()); + if (end == OSSACompleteLifetime::LifetimeEnd::Loop) { return builder.createExtendLifetime(loc, value); } auto isDeadEnd = IsDeadEnd_t(deb.isDeadEnd(builder.getInsertionBB())); @@ -101,21 +101,21 @@ static bool endLifetimeAtLivenessBoundary(SILValue value, bool changed = false; for (SILInstruction *lastUser : boundary.lastUsers) { - if (liveness.isInterestingUser(lastUser) - != PrunedLiveness::LifetimeEndingUse) { + if (liveness.isInterestingUser(lastUser) != + PrunedLiveness::LifetimeEndingUse) { changed = true; - SILBuilderWithScope::insertAfter(lastUser, [value, - &deb](SILBuilder &builder) { - endOSSALifetime(value, OSSALifetimeCompletion::LifetimeEnd::Boundary, - builder, deb); - }); + SILBuilderWithScope::insertAfter( + lastUser, [value, &deb](SILBuilder &builder) { + endOSSALifetime(value, OSSACompleteLifetime::LifetimeEnd::Boundary, + builder, deb); + }); } } for (SILBasicBlock *edge : boundary.boundaryEdges) { changed = true; SILBuilderWithScope builder(edge->begin()); - endOSSALifetime(value, OSSALifetimeCompletion::LifetimeEnd::Boundary, - builder, deb); + endOSSALifetime(value, OSSACompleteLifetime::LifetimeEnd::Boundary, builder, + deb); } for (SILNode *deadDef : boundary.deadDefs) { SILInstruction *next = nullptr; @@ -126,8 +126,8 @@ static bool endLifetimeAtLivenessBoundary(SILValue value, } changed = true; SILBuilderWithScope builder(next); - endOSSALifetime(value, OSSALifetimeCompletion::LifetimeEnd::Boundary, - builder, deb); + endOSSALifetime(value, OSSACompleteLifetime::LifetimeEnd::Boundary, builder, + deb); } return changed; } @@ -174,7 +174,7 @@ namespace { /// Visits the latest instructions at which `value` is available. /// /// Together with visitUsersOutsideLinearLivenessBoundary, implements -/// OSSALifetimeCompletion::visitAvailabilityBoundary. +/// OSSACompleteLifetime::visitAvailabilityBoundary. /// /// Finding these positions is a three step process: /// 1) computeRegion: Forward CFG walk from non-lifetime-ending boundary to find @@ -200,7 +200,7 @@ class AvailabilityBoundaryVisitor { region(value->getFunction()) {} using Visit = llvm::function_ref; + OSSACompleteLifetime::LifetimeEnd)>; struct Result; @@ -311,8 +311,8 @@ void AvailabilityBoundaryVisitor::computeRegion( // ScopedAddresses) are available only up to their last extend_lifetime on // non-dead-end paths. They cannot be consumed, but are only "available" up to // the end of their scope. - if (value->getOwnershipKind() != OwnershipKind::None - || ScopedAddressValue(value)) { + if (value->getOwnershipKind() != OwnershipKind::None || + ScopedAddressValue(value)) { for (auto *endBlock : boundary.endBlocks) { if (!consumingBlocks.contains(endBlock)) { collect(endBlock); @@ -338,8 +338,8 @@ void AvailabilityBoundaryVisitor::computeRegion( ->getModule() .getASTContext() .SILOpts.VerifySILOwnership) { - llvm::errs() << "Invalid SIL provided to OSSALifetimeCompletion?! {{\n"; - llvm::errs() << "OSSALifetimeCompletion is visiting the availability " + llvm::errs() << "Invalid SIL provided to OSSACompleteLifetime?! {{\n"; + llvm::errs() << "OSSACompleteLifetime is visiting the availability " "boundary of "; value->print(llvm::errs()); llvm::errs() @@ -353,8 +353,8 @@ void AvailabilityBoundaryVisitor::computeRegion( "value was leaked. The function with the leak is as follows:\n"; block->getFunction()->print(llvm::errs()); llvm::errs() - << "Invalid SIL provided to OSSALifetimeCompletion?! }}\n" - << "Something that ran before OSSALifetimeCompletion (the current " + << "Invalid SIL provided to OSSACompleteLifetime?! }}\n" + << "Something that ran before OSSACompleteLifetime (the current " "pass, an earlier pass, SILGen) has introduced a leak of this " "value.\n" << "Please rerun the crashing swift-frontend command with the " @@ -362,8 +362,8 @@ void AvailabilityBoundaryVisitor::computeRegion( << "-sil-ownership-verify-all -Xllvm '-sil-print-function=" << block->getFunction()->getName() << "' -Xllvm -sil-print-types -Xllvm -sil-print-module-on-error\n"; - llvm::errs() << "Use the -disable-sil-ownership-verifier to disable " - "this check.\n"; + llvm::errs() << "Use the -disable-sil-ownership-verifier frontend flag " + "to disable this check.\n"; llvm::report_fatal_error("Invalid lifetime of value whose availability " "boundary is being visited."); } @@ -419,7 +419,7 @@ void AvailabilityBoundaryVisitor::propagateAvailablity(Result &result) { void AvailabilityBoundaryVisitor::visitAvailabilityBoundary( Result const &result, llvm::function_ref + OSSACompleteLifetime::LifetimeEnd end)> visit) { for (auto *block : region) { auto available = result.getState(block) == State::Available; @@ -441,13 +441,12 @@ void AvailabilityBoundaryVisitor::visitAvailabilityBoundary( ->getModule() .getASTContext() .SILOpts.VerifySILOwnership); - visit(block->getTerminator(), - OSSALifetimeCompletion::LifetimeEnd::Boundary); + visit(block->getTerminator(), OSSACompleteLifetime::LifetimeEnd::Boundary); } } } // end anonymous namespace -void OSSALifetimeCompletion::visitAvailabilityBoundary( +void OSSACompleteLifetime::visitAvailabilityBoundary( SILValue value, const SSAPrunedLiveness &liveness, llvm::function_ref visit) { @@ -468,7 +467,7 @@ static bool endLifetimeAtAvailabilityBoundary(SILValue value, const SSAPrunedLiveness &liveness, DeadEndBlocks &deb) { bool changed = false; - OSSALifetimeCompletion::visitAvailabilityBoundary( + OSSACompleteLifetime::visitAvailabilityBoundary( value, liveness, [&](auto *unreachable, auto end) { SILBuilderWithScope builder(unreachable); endOSSALifetime(value, end, builder, deb); @@ -479,14 +478,14 @@ static bool endLifetimeAtAvailabilityBoundary(SILValue value, static bool endLifetimeAtBoundary(SILValue value, SSAPrunedLiveness const &liveness, - OSSALifetimeCompletion::Boundary boundary, + OSSACompleteLifetime::Boundary boundary, DeadEndBlocks &deadEndBlocks) { bool changed = false; switch (boundary) { - case OSSALifetimeCompletion::Boundary::Liveness: + case OSSACompleteLifetime::Boundary::Liveness: changed |= endLifetimeAtLivenessBoundary(value, liveness, deadEndBlocks); break; - case OSSALifetimeCompletion::Boundary::Availability: + case OSSACompleteLifetime::Boundary::Availability: changed |= endLifetimeAtAvailabilityBoundary(value, liveness, deadEndBlocks); break; @@ -494,18 +493,18 @@ static bool endLifetimeAtBoundary(SILValue value, return changed; } -bool OSSALifetimeCompletion::analyzeAndUpdateLifetime( +bool OSSACompleteLifetime::analyzeAndUpdateLifetime( ScopedAddressValue scopedAddress, Boundary boundary) { SmallVector discoveredBlocks; SSAPrunedLiveness liveness(scopedAddress->getFunction(), &discoveredBlocks); liveness.initializeDef(scopedAddress.value); struct Walker : TransitiveAddressWalker { - OSSALifetimeCompletion &completion; + OSSACompleteLifetime &completion; ScopedAddressValue scopedAddress; Boundary boundary; SSAPrunedLiveness &liveness; - Walker(OSSALifetimeCompletion &completion, ScopedAddressValue scopedAddress, + Walker(OSSACompleteLifetime &completion, ScopedAddressValue scopedAddress, Boundary boundary, SSAPrunedLiveness &liveness) : completion(completion), scopedAddress(scopedAddress), boundary(boundary), liveness(liveness) {} @@ -555,8 +554,8 @@ bool OSSALifetimeCompletion::analyzeAndUpdateLifetime( /// End the lifetime of \p value at unreachable instructions. /// /// Returns true if any new instructions were created to complete the lifetime. -bool OSSALifetimeCompletion::analyzeAndUpdateLifetime(SILValue value, - Boundary boundary) { +bool OSSACompleteLifetime::analyzeAndUpdateLifetime(SILValue value, + Boundary boundary) { if (auto scopedAddress = ScopedAddressValue(value)) { return analyzeAndUpdateLifetime(scopedAddress, boundary); } @@ -577,8 +576,8 @@ bool OSSALifetimeCompletion::analyzeAndUpdateLifetime(SILValue value, } InteriorLiveness liveness(value); liveness.compute(domInfo, handleInnerScope); - if (VerifyLifetimeCompletion && boundary != Boundary::Availability - && liveness.getAddressUseKind() != AddressUseKind::NonEscaping) { + if (VerifyLifetimeCompletion && boundary != Boundary::Availability && + liveness.getAddressUseKind() != AddressUseKind::NonEscaping) { llvm::errs() << "Incomplete liveness for: " << value; if (auto *escapingUse = liveness.escapingUse) { llvm::errs() << " escapes at:\n"; @@ -596,20 +595,19 @@ namespace swift::test { // - string: either "liveness" or "availability" // Dumps: // - function -static FunctionTest OSSALifetimeCompletionTest( - "ossa_lifetime_completion", - [](auto &function, auto &arguments, auto &test) { +static FunctionTest OSSACompleteLifetimeTest( + "ossa_complete_lifetime", [](auto &function, auto &arguments, auto &test) { SILValue value = arguments.takeValue(); - OSSALifetimeCompletion::Boundary kind = - llvm::StringSwitch( + OSSACompleteLifetime::Boundary kind = + llvm::StringSwitch( arguments.takeString()) - .Case("liveness", OSSALifetimeCompletion::Boundary::Liveness) + .Case("liveness", OSSACompleteLifetime::Boundary::Liveness) .Case("availability", - OSSALifetimeCompletion::Boundary::Availability); + OSSACompleteLifetime::Boundary::Availability); auto *deb = test.getDeadEndBlocks(); llvm::outs() << "OSSA lifetime completion on " << kind << " boundary: " << value; - OSSALifetimeCompletion completion(&function, /*domInfo*/ nullptr, *deb); + OSSACompleteLifetime completion(&function, /*domInfo*/ nullptr, *deb); completion.completeOSSALifetime(value, kind); function.print(llvm::outs()); }); @@ -686,12 +684,12 @@ bool UnreachableLifetimeCompletion::completeLifetimes() { } } - OSSALifetimeCompletion completion(function, domInfo, deadEndBlocks); + OSSACompleteLifetime completion(function, domInfo, deadEndBlocks); bool changed = false; for (auto value : incompleteValues) { if (completion.completeOSSALifetime( - value, OSSALifetimeCompletion::Boundary::Availability) == + value, OSSACompleteLifetime::Boundary::Availability) == LifetimeCompletion::WasCompleted) { changed = true; } diff --git a/lib/SILOptimizer/Mandatory/ConsumeOperatorCopyableAddressesChecker.cpp b/lib/SILOptimizer/Mandatory/ConsumeOperatorCopyableAddressesChecker.cpp index cbd794f7504e0..0210ccda903fb 100644 --- a/lib/SILOptimizer/Mandatory/ConsumeOperatorCopyableAddressesChecker.cpp +++ b/lib/SILOptimizer/Mandatory/ConsumeOperatorCopyableAddressesChecker.cpp @@ -163,8 +163,8 @@ #include "swift/SILOptimizer/Analysis/LoopAnalysis.h" #include "swift/SILOptimizer/PassManager/Transforms.h" #include "swift/SILOptimizer/Utils/CFGOptUtils.h" -#include "swift/SILOptimizer/Utils/CanonicalizeOSSALifetime.h" #include "swift/SILOptimizer/Utils/InstOptUtils.h" +#include "swift/SILOptimizer/Utils/OSSACanonicalizeOwned.h" #include "swift/SILOptimizer/Utils/SILOptFunctionBuilder.h" #include "swift/SILOptimizer/Utils/SpecializationMangler.h" #include "llvm/ADT/PointerEmbeddedInt.h" diff --git a/lib/SILOptimizer/Mandatory/ConsumeOperatorCopyableValuesChecker.cpp b/lib/SILOptimizer/Mandatory/ConsumeOperatorCopyableValuesChecker.cpp index 724203c1a24e7..9d54e6633569f 100644 --- a/lib/SILOptimizer/Mandatory/ConsumeOperatorCopyableValuesChecker.cpp +++ b/lib/SILOptimizer/Mandatory/ConsumeOperatorCopyableValuesChecker.cpp @@ -33,7 +33,7 @@ #include "swift/SILOptimizer/Analysis/LoopAnalysis.h" #include "swift/SILOptimizer/PassManager/Transforms.h" #include "swift/SILOptimizer/Utils/CFGOptUtils.h" -#include "swift/SILOptimizer/Utils/CanonicalizeOSSALifetime.h" +#include "swift/SILOptimizer/Utils/OSSACanonicalizeOwned.h" using namespace swift; @@ -227,7 +227,7 @@ struct ConsumeOperatorCopyableValuesChecker { CheckerLivenessInfo livenessInfo; DominanceInfo *dominance; InstructionDeleter deleter; - CanonicalizeOSSALifetime canonicalizer; + OSSACanonicalizeOwned canonicalizer; ConsumeOperatorCopyableValuesChecker( SILFunction *fn, DominanceInfo *dominance, diff --git a/lib/SILOptimizer/Mandatory/MoveOnlyAddressCheckerTester.cpp b/lib/SILOptimizer/Mandatory/MoveOnlyAddressCheckerTester.cpp index 16a7518406928..4614dd7104f5d 100644 --- a/lib/SILOptimizer/Mandatory/MoveOnlyAddressCheckerTester.cpp +++ b/lib/SILOptimizer/Mandatory/MoveOnlyAddressCheckerTester.cpp @@ -45,8 +45,8 @@ #include "swift/SILOptimizer/Analysis/DominanceAnalysis.h" #include "swift/SILOptimizer/Analysis/NonLocalAccessBlockAnalysis.h" #include "swift/SILOptimizer/PassManager/Transforms.h" -#include "swift/SILOptimizer/Utils/CanonicalizeOSSALifetime.h" #include "swift/SILOptimizer/Utils/InstructionDeleter.h" +#include "swift/SILOptimizer/Utils/OSSACanonicalizeOwned.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/MapVector.h" #include "llvm/ADT/PointerIntPair.h" diff --git a/lib/SILOptimizer/Mandatory/MoveOnlyAddressCheckerUtils.cpp b/lib/SILOptimizer/Mandatory/MoveOnlyAddressCheckerUtils.cpp index ba67d14f4c4f9..a256473132e72 100644 --- a/lib/SILOptimizer/Mandatory/MoveOnlyAddressCheckerUtils.cpp +++ b/lib/SILOptimizer/Mandatory/MoveOnlyAddressCheckerUtils.cpp @@ -243,7 +243,7 @@ #include "swift/SIL/FieldSensitivePrunedLiveness.h" #include "swift/SIL/InstructionUtils.h" #include "swift/SIL/MemAccessUtils.h" -#include "swift/SIL/OSSALifetimeCompletion.h" +#include "swift/SIL/OSSACompleteLifetime.h" #include "swift/SIL/OwnershipUtils.h" #include "swift/SIL/PrunedLiveness.h" #include "swift/SIL/SILArgument.h" @@ -259,8 +259,8 @@ #include "swift/SILOptimizer/Analysis/DominanceAnalysis.h" #include "swift/SILOptimizer/Analysis/NonLocalAccessBlockAnalysis.h" #include "swift/SILOptimizer/PassManager/Transforms.h" -#include "swift/SILOptimizer/Utils/CanonicalizeOSSALifetime.h" #include "swift/SILOptimizer/Utils/InstructionDeleter.h" +#include "swift/SILOptimizer/Utils/OSSACanonicalizeOwned.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/MapVector.h" #include "llvm/ADT/PointerIntPair.h" @@ -1472,7 +1472,7 @@ struct MoveOnlyAddressCheckerPImpl { /// The instruction deleter used by \p canonicalizer. InstructionDeleter deleter; - /// State to run CanonicalizeOSSALifetime. + /// State to run OSSACanonicalizeOwned. OSSACanonicalizer canonicalizer; /// Per mark must check address use state. @@ -4071,13 +4071,12 @@ bool MoveOnlyAddressChecker::check( return pimpl.changed; } bool MoveOnlyAddressChecker::completeLifetimes() { - // TODO: Delete once OSSALifetimeCompletion is run as part of SILGenCleanup + // TODO: Delete once OSSACompleteLifetime is run as part of SILGenCleanup bool changed = false; // Lifetimes must be completed inside out (bottom-up in the CFG). PostOrderFunctionInfo *postOrder = poa->get(fn); - OSSALifetimeCompletion completion(fn, domTree, - *deadEndBlocksAnalysis->get(fn)); + OSSACompleteLifetime completion(fn, domTree, *deadEndBlocksAnalysis->get(fn)); for (auto *block : postOrder->getPostOrder()) { for (SILInstruction &inst : reverse(*block)) { for (auto result : inst.getResults()) { @@ -4086,7 +4085,7 @@ bool MoveOnlyAddressChecker::completeLifetimes() { continue; } if (completion.completeOSSALifetime( - result, OSSALifetimeCompletion::Boundary::Availability) == + result, OSSACompleteLifetime::Boundary::Availability) == LifetimeCompletion::WasCompleted) { changed = true; } @@ -4097,7 +4096,7 @@ bool MoveOnlyAddressChecker::completeLifetimes() { continue; } if (completion.completeOSSALifetime( - arg, OSSALifetimeCompletion::Boundary::Availability) == + arg, OSSACompleteLifetime::Boundary::Availability) == LifetimeCompletion::WasCompleted) { changed = true; } diff --git a/lib/SILOptimizer/Mandatory/MoveOnlyChecker.cpp b/lib/SILOptimizer/Mandatory/MoveOnlyChecker.cpp index 28cd79ae9bd80..b1e0e4e191a11 100644 --- a/lib/SILOptimizer/Mandatory/MoveOnlyChecker.cpp +++ b/lib/SILOptimizer/Mandatory/MoveOnlyChecker.cpp @@ -31,7 +31,7 @@ #include "swift/SIL/FieldSensitivePrunedLiveness.h" #include "swift/SIL/InstructionUtils.h" #include "swift/SIL/MemAccessUtils.h" -#include "swift/SIL/OSSALifetimeCompletion.h" +#include "swift/SIL/OSSACompleteLifetime.h" #include "swift/SIL/OwnershipUtils.h" #include "swift/SIL/PrunedLiveness.h" #include "swift/SIL/SILArgument.h" @@ -47,8 +47,8 @@ #include "swift/SILOptimizer/Analysis/DominanceAnalysis.h" #include "swift/SILOptimizer/Analysis/NonLocalAccessBlockAnalysis.h" #include "swift/SILOptimizer/PassManager/Transforms.h" -#include "swift/SILOptimizer/Utils/CanonicalizeOSSALifetime.h" #include "swift/SILOptimizer/Utils/InstructionDeleter.h" +#include "swift/SILOptimizer/Utils/OSSACanonicalizeOwned.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/MapVector.h" #include "llvm/ADT/PointerIntPair.h" @@ -122,8 +122,8 @@ void MoveOnlyChecker::checkObjects() { void MoveOnlyChecker::completeObjectLifetimes( ArrayRef insts) { - // TODO: Delete once OSSALifetimeCompletion is run as part of SILGenCleanup. - OSSALifetimeCompletion completion(fn, domTree, *deba->get(fn)); + // TODO: Delete once OSSACompleteLifetime is run as part of SILGenCleanup. + OSSACompleteLifetime completion(fn, domTree, *deba->get(fn)); // Collect all values derived from each mark_unresolved_non_copyable_value // instruction via ownership instructions and phis. @@ -170,7 +170,7 @@ void MoveOnlyChecker::completeObjectLifetimes( if (!transitiveValues.isVisited(result)) continue; if (completion.completeOSSALifetime( - result, OSSALifetimeCompletion::Boundary::Availability) == + result, OSSACompleteLifetime::Boundary::Availability) == LifetimeCompletion::WasCompleted) { madeChange = true; } @@ -183,7 +183,7 @@ void MoveOnlyChecker::completeObjectLifetimes( if (!transitiveValues.isVisited(arg)) continue; if (completion.completeOSSALifetime( - arg, OSSALifetimeCompletion::Boundary::Availability) == + arg, OSSACompleteLifetime::Boundary::Availability) == LifetimeCompletion::WasCompleted) { madeChange = true; } diff --git a/lib/SILOptimizer/Mandatory/MoveOnlyObjectCheckerTester.cpp b/lib/SILOptimizer/Mandatory/MoveOnlyObjectCheckerTester.cpp index 975bae0dd3748..3203d7a00de75 100644 --- a/lib/SILOptimizer/Mandatory/MoveOnlyObjectCheckerTester.cpp +++ b/lib/SILOptimizer/Mandatory/MoveOnlyObjectCheckerTester.cpp @@ -42,8 +42,8 @@ #include "swift/SILOptimizer/Analysis/PostOrderAnalysis.h" #include "swift/SILOptimizer/PassManager/Transforms.h" #include "swift/SILOptimizer/Utils/CFGOptUtils.h" -#include "swift/SILOptimizer/Utils/CanonicalizeOSSALifetime.h" #include "swift/SILOptimizer/Utils/InstructionDeleter.h" +#include "swift/SILOptimizer/Utils/OSSACanonicalizeOwned.h" #include "swift/SILOptimizer/Utils/SILSSAUpdater.h" #include "clang/AST/DeclTemplate.h" #include "llvm/ADT/ArrayRef.h" diff --git a/lib/SILOptimizer/Mandatory/MoveOnlyObjectCheckerUtils.cpp b/lib/SILOptimizer/Mandatory/MoveOnlyObjectCheckerUtils.cpp index 8372fe5875164..e77a473c1a683 100644 --- a/lib/SILOptimizer/Mandatory/MoveOnlyObjectCheckerUtils.cpp +++ b/lib/SILOptimizer/Mandatory/MoveOnlyObjectCheckerUtils.cpp @@ -41,8 +41,8 @@ #include "swift/SILOptimizer/Analysis/PostOrderAnalysis.h" #include "swift/SILOptimizer/PassManager/Transforms.h" #include "swift/SILOptimizer/Utils/CFGOptUtils.h" -#include "swift/SILOptimizer/Utils/CanonicalizeOSSALifetime.h" #include "swift/SILOptimizer/Utils/InstructionDeleter.h" +#include "swift/SILOptimizer/Utils/OSSACanonicalizeOwned.h" #include "swift/SILOptimizer/Utils/SILSSAUpdater.h" #include "clang/AST/DeclTemplate.h" #include "llvm/ADT/ArrayRef.h" @@ -102,7 +102,7 @@ void OSSACanonicalizer::computeBoundaryData(SILValue value) { // Then use that information to stash for our diagnostics the boundary // consuming/non-consuming users as well as enter the boundary consuming users // into the boundaryConsumignUserSet for quick set testing later. - using IsInterestingUser = CanonicalizeOSSALifetime::IsInterestingUser; + using IsInterestingUser = OSSACanonicalizeOwned::IsInterestingUser; InstructionSet boundaryConsumingUserSet(value->getFunction()); for (auto *lastUser : originalBoundary.lastUsers) { LLVM_DEBUG(llvm::dbgs() << "Looking at boundary use: " << *lastUser); diff --git a/lib/SILOptimizer/Mandatory/MoveOnlyObjectCheckerUtils.h b/lib/SILOptimizer/Mandatory/MoveOnlyObjectCheckerUtils.h index cefd8551db131..b3050ab0ef228 100644 --- a/lib/SILOptimizer/Mandatory/MoveOnlyObjectCheckerUtils.h +++ b/lib/SILOptimizer/Mandatory/MoveOnlyObjectCheckerUtils.h @@ -20,7 +20,7 @@ #ifndef SWIFT_SILOPTIMIZER_MANDATORY_MOVEONLYOBJECTCHECKERUTILS_H #define SWIFT_SILOPTIMIZER_MANDATORY_MOVEONLYOBJECTCHECKERUTILS_H -#include "swift/SILOptimizer/Utils/CanonicalizeOSSALifetime.h" +#include "swift/SILOptimizer/Utils/OSSACanonicalizeOwned.h" #include "llvm/Support/Compiler.h" #include "MoveOnlyBorrowToDestructureUtils.h" @@ -30,7 +30,7 @@ namespace siloptimizer { class DiagnosticEmitter; -/// Wrapper around CanonicalizeOSSALifetime that we use to specialize its +/// Wrapper around OSSACanonicalizeOwned that we use to specialize its /// interface for our purposes. struct OSSACanonicalizer { /// A per mark must check, vector of uses that copy propagation says need a @@ -44,7 +44,7 @@ struct OSSACanonicalizer { /// A list of non-consuming boundary uses. SmallVector nonConsumingBoundaryUsers; - CanonicalizeOSSALifetime canonicalizer; + OSSACanonicalizeOwned canonicalizer; OSSACanonicalizer(SILFunction *fn, DominanceInfo *domTree, DeadEndBlocksAnalysis *deadEndBlocksAnalysis, @@ -62,7 +62,7 @@ struct OSSACanonicalizer { struct LivenessState { OSSACanonicalizer &parent; - CanonicalizeOSSALifetime::LivenessState canonicalizerState; + OSSACanonicalizeOwned::LivenessState canonicalizerState; LivenessState(OSSACanonicalizer &parent, SILValue def) : parent(parent), canonicalizerState(parent.canonicalizer, def, {}) {} diff --git a/lib/SILOptimizer/Mandatory/MoveOnlyUtils.cpp b/lib/SILOptimizer/Mandatory/MoveOnlyUtils.cpp index f4c6cce99ef88..0780988490354 100644 --- a/lib/SILOptimizer/Mandatory/MoveOnlyUtils.cpp +++ b/lib/SILOptimizer/Mandatory/MoveOnlyUtils.cpp @@ -45,8 +45,8 @@ #include "swift/SILOptimizer/Analysis/DominanceAnalysis.h" #include "swift/SILOptimizer/Analysis/NonLocalAccessBlockAnalysis.h" #include "swift/SILOptimizer/PassManager/Transforms.h" -#include "swift/SILOptimizer/Utils/CanonicalizeOSSALifetime.h" #include "swift/SILOptimizer/Utils/InstructionDeleter.h" +#include "swift/SILOptimizer/Utils/OSSACanonicalizeOwned.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/MapVector.h" #include "llvm/ADT/PointerIntPair.h" diff --git a/lib/SILOptimizer/Mandatory/MoveOnlyWrappedTypeEliminator.cpp b/lib/SILOptimizer/Mandatory/MoveOnlyWrappedTypeEliminator.cpp index 34c588cb243bf..e1d847dc2c776 100644 --- a/lib/SILOptimizer/Mandatory/MoveOnlyWrappedTypeEliminator.cpp +++ b/lib/SILOptimizer/Mandatory/MoveOnlyWrappedTypeEliminator.cpp @@ -48,7 +48,7 @@ #include "swift/SILOptimizer/Analysis/NonLocalAccessBlockAnalysis.h" #include "swift/SILOptimizer/Analysis/PostOrderAnalysis.h" #include "swift/SILOptimizer/PassManager/Transforms.h" -#include "swift/SILOptimizer/Utils/CanonicalizeOSSALifetime.h" +#include "swift/SILOptimizer/Utils/OSSACanonicalizeOwned.h" using namespace swift; diff --git a/lib/SILOptimizer/Mandatory/PredictableMemOpt.cpp b/lib/SILOptimizer/Mandatory/PredictableMemOpt.cpp index 20e0211c91b5a..83a5694214c89 100644 --- a/lib/SILOptimizer/Mandatory/PredictableMemOpt.cpp +++ b/lib/SILOptimizer/Mandatory/PredictableMemOpt.cpp @@ -21,7 +21,7 @@ #include "swift/SIL/BasicBlockBits.h" #include "swift/SIL/BasicBlockUtils.h" #include "swift/SIL/LinearLifetimeChecker.h" -#include "swift/SIL/OSSALifetimeCompletion.h" +#include "swift/SIL/OSSACompleteLifetime.h" #include "swift/SIL/OwnershipUtils.h" #include "swift/SIL/SILBuilder.h" #include "swift/SILOptimizer/PassManager/Passes.h" @@ -2306,8 +2306,8 @@ void OptimizeDeadAlloc::removeDeadAllocation() { // post-dominating consuming use sets. This can happen if we have an enum that // is known dynamically none along a path. This is dynamically correct, but // can not be represented in OSSA so we insert these destroys along said path. - OSSALifetimeCompletion completion(TheMemory->getFunction(), domInfo, - deadEndBlocks); + OSSACompleteLifetime completion(TheMemory->getFunction(), domInfo, + deadEndBlocks); while (!valuesNeedingLifetimeCompletion.empty()) { auto optV = valuesNeedingLifetimeCompletion.pop_back_val(); @@ -2318,8 +2318,8 @@ void OptimizeDeadAlloc::removeDeadAllocation() { // don't end in unreachable. Force their lifetime to end immediately after // the last use instead. auto boundary = v->getType().isOrHasEnum() - ? OSSALifetimeCompletion::Boundary::Liveness - : OSSALifetimeCompletion::Boundary::Availability; + ? OSSACompleteLifetime::Boundary::Liveness + : OSSACompleteLifetime::Boundary::Availability; LLVM_DEBUG(llvm::dbgs() << "Completing lifetime of: "); LLVM_DEBUG(v->dump()); completion.completeOSSALifetime(v, boundary); diff --git a/lib/SILOptimizer/Mandatory/SILGenCleanup.cpp b/lib/SILOptimizer/Mandatory/SILGenCleanup.cpp index c61118536d728..40ee8c02f635f 100644 --- a/lib/SILOptimizer/Mandatory/SILGenCleanup.cpp +++ b/lib/SILOptimizer/Mandatory/SILGenCleanup.cpp @@ -21,7 +21,7 @@ #include "swift/SIL/BasicBlockBits.h" #include "swift/SIL/BasicBlockDatastructures.h" #include "swift/SIL/BasicBlockUtils.h" -#include "swift/SIL/OSSALifetimeCompletion.h" +#include "swift/SIL/OSSACompleteLifetime.h" #include "swift/SIL/PrettyStackTrace.h" #include "swift/SIL/PrunedLiveness.h" #include "swift/SIL/SILInstruction.h" @@ -110,7 +110,7 @@ struct SILGenCleanup : SILModuleTransform { bool completeOSSALifetimes(SILFunction *function); template bool completeLifetimesInRange(Range const &range, - OSSALifetimeCompletion &completion, + OSSACompleteLifetime &completion, BasicBlockSet &completed); }; @@ -267,9 +267,8 @@ bool SILGenCleanup::completeOSSALifetimes(SILFunction *function) { } bool changed = false; - OSSALifetimeCompletion completion( - function, /*DomInfo*/ nullptr, *deba, - OSSALifetimeCompletion::ExtendTrivialVariable); + OSSACompleteLifetime completion(function, /*DomInfo*/ nullptr, *deba, + OSSACompleteLifetime::ExtendTrivialVariable); BasicBlockSet completed(function); for (auto *root : roots) { if (root == function->getEntryBlock()) { @@ -296,7 +295,7 @@ bool SILGenCleanup::completeOSSALifetimes(SILFunction *function) { template bool SILGenCleanup::completeLifetimesInRange(Range const &range, - OSSALifetimeCompletion &completion, + OSSACompleteLifetime &completion, BasicBlockSet &completed) { bool changed = false; for (auto *block : range) { @@ -308,7 +307,7 @@ bool SILGenCleanup::completeLifetimesInRange(Range const &range, for (auto result : inst.getResults()) { LLVM_DEBUG(llvm::dbgs() << "completing " << result << "\n"); if (completion.completeOSSALifetime( - result, OSSALifetimeCompletion::Boundary::Availability) == + result, OSSACompleteLifetime::Boundary::Availability) == LifetimeCompletion::WasCompleted) { LLVM_DEBUG(llvm::dbgs() << "\tcompleted!\n"); changed = true; @@ -319,7 +318,7 @@ bool SILGenCleanup::completeLifetimesInRange(Range const &range, LLVM_DEBUG(llvm::dbgs() << "completing " << *arg << "\n"); assert(!arg->isReborrow() && "reborrows not legal at this SIL stage"); if (completion.completeOSSALifetime( - arg, OSSALifetimeCompletion::Boundary::Availability) == + arg, OSSACompleteLifetime::Boundary::Availability) == LifetimeCompletion::WasCompleted) { LLVM_DEBUG(llvm::dbgs() << "\tcompleted!\n"); changed = true; diff --git a/lib/SILOptimizer/SILCombiner/SILCombine.cpp b/lib/SILOptimizer/SILCombiner/SILCombine.cpp index 2efaeed6eb5c5..6ff18e4012d79 100644 --- a/lib/SILOptimizer/SILCombiner/SILCombine.cpp +++ b/lib/SILOptimizer/SILCombiner/SILCombine.cpp @@ -33,11 +33,11 @@ #include "swift/SILOptimizer/Analysis/SimplifyInstruction.h" #include "swift/SILOptimizer/PassManager/PassManager.h" #include "swift/SILOptimizer/PassManager/Transforms.h" -#include "swift/SILOptimizer/Utils/CanonicalizeBorrowScope.h" #include "swift/SILOptimizer/Utils/CanonicalizeInstruction.h" -#include "swift/SILOptimizer/Utils/CanonicalizeOSSALifetime.h" #include "swift/SILOptimizer/Utils/DebugOptUtils.h" #include "swift/SILOptimizer/Utils/InstOptUtils.h" +#include "swift/SILOptimizer/Utils/OSSACanonicalizeGuaranteed.h" +#include "swift/SILOptimizer/Utils/OSSACanonicalizeOwned.h" #include "swift/SILOptimizer/Utils/SILOptFunctionBuilder.h" #include "swift/SILOptimizer/Utils/StackNesting.h" #include "llvm/ADT/SmallPtrSet.h" @@ -311,7 +311,7 @@ void SILCombiner::canonicalizeOSSALifetimes(SILInstruction *currentInst) { // copyInst was either optimized by a SILCombine visitor or is a copy_value // produced by the visitor. Find the canonical def. auto recordCopiedDef = [&defsToCanonicalize](CopyValueInst *copyInst) { - SILValue def = CanonicalizeOSSALifetime::getCanonicalCopiedDef(copyInst); + SILValue def = OSSACanonicalizeOwned::getCanonicalCopiedDef(copyInst); // getCanonicalCopiedDef returns a copy whenever that the copy's source is // guaranteed. In that case, find the root of the borrowed lifetime. If it @@ -325,8 +325,9 @@ void SILCombiner::canonicalizeOSSALifetimes(SILInstruction *currentInst) { // fast convergence, rewriting borrow scopes should not be combined with // other unrelated transformations. if (auto *copyDef = dyn_cast(def)) { - if (SILValue borrowDef = CanonicalizeBorrowScope::getCanonicalBorrowedDef( - copyDef->getOperand())) { + if (SILValue borrowDef = + OSSACanonicalizeGuaranteed::getCanonicalBorrowedDef( + copyDef->getOperand())) { if (isa(borrowDef)) { def = borrowDef; } @@ -348,7 +349,7 @@ void SILCombiner::canonicalizeOSSALifetimes(SILInstruction *currentInst) { return; // Remove instructions deleted during canonicalization from SILCombine's - // worklist. CanonicalizeOSSALifetime invalidates operands before invoking + // worklist. OSSACanonicalizeOwned invalidates operands before invoking // the deletion callback. auto canonicalizeCallbacks = InstModCallbacks().onDelete([this](SILInstruction *instToDelete) { @@ -358,12 +359,12 @@ void SILCombiner::canonicalizeOSSALifetimes(SILInstruction *currentInst) { InstructionDeleter deleter(std::move(canonicalizeCallbacks)); DominanceInfo *domTree = DA->get(&Builder.getFunction()); - CanonicalizeOSSALifetime canonicalizer( + OSSACanonicalizeOwned canonicalizer( DontPruneDebugInsts, MaximizeLifetime_t(!parentTransform->getFunction()->shouldOptimize()), parentTransform->getFunction(), NLABA, DEBA, domTree, CA, deleter); - CanonicalizeBorrowScope borrowCanonicalizer(parentTransform->getFunction(), - deleter); + OSSACanonicalizeGuaranteed borrowCanonicalizer(parentTransform->getFunction(), + deleter); while (!defsToCanonicalize.empty()) { SILValue def = defsToCanonicalize.pop_back_val(); diff --git a/lib/SILOptimizer/SILCombiner/SILCombiner.h b/lib/SILOptimizer/SILCombiner/SILCombiner.h index ae052d17de554..a884295da361f 100644 --- a/lib/SILOptimizer/SILCombiner/SILCombiner.h +++ b/lib/SILOptimizer/SILCombiner/SILCombiner.h @@ -341,7 +341,7 @@ class SILCombiner : /// try to visit it. bool trySinkOwnedForwardingInst(SingleValueInstruction *svi); - /// Apply CanonicalizeOSSALifetime to the extended lifetime of any copy + /// Apply OSSACanonicalizeOwned to the extended lifetime of any copy /// introduced during SILCombine for an owned value. void canonicalizeOSSALifetimes(SILInstruction *currentInst); diff --git a/lib/SILOptimizer/SemanticARC/CopyValueOpts.cpp b/lib/SILOptimizer/SemanticARC/CopyValueOpts.cpp index 329c4a23b5747..0df7f3d65af4a 100644 --- a/lib/SILOptimizer/SemanticARC/CopyValueOpts.cpp +++ b/lib/SILOptimizer/SemanticARC/CopyValueOpts.cpp @@ -14,7 +14,7 @@ /// /// Contains optimizations that eliminate redundant copy values. /// -/// FIXME: CanonicalizeOSSALifetime likely replaces everything this file. +/// FIXME: OSSACanonicalizeOwned likely replaces everything this file. /// //===----------------------------------------------------------------------===// @@ -73,7 +73,7 @@ bool SemanticARCOptVisitor::performGuaranteedCopyValueOptimization( LLVM_DEBUG(llvm::dbgs() << "Looking at "); LLVM_DEBUG(cvi->dump()); - // All mandatory copy optimization is handled by CanonicalizeOSSALifetime, + // All mandatory copy optimization is handled by OSSACanonicalizeOwned, // which knows how to preserve lifetimes for debugging. if (ctx.onlyMandatoryOpts) return false; @@ -273,7 +273,7 @@ bool SemanticARCOptVisitor::performGuaranteedCopyValueOptimization( /// If cvi only has destroy value users, then cvi is a dead live range. Lets /// eliminate all such dead live ranges. /// -/// FIXME: CanonicalizeOSSALifetime replaces this. +/// FIXME: OSSACanonicalizeOwned replaces this. bool SemanticARCOptVisitor::eliminateDeadLiveRangeCopyValue( CopyValueInst *cvi) { // This is a cheap optimization generally. @@ -665,7 +665,7 @@ static bool tryJoiningIfCopyOperandHasSingleDestroyValue( // begin_borrow. Because of that we can not shrink lifetimes and instead rely on // SILGen's correctness. // -// FIXME: CanonicalizeOSSALifetime replaces this. +// FIXME: OSSACanonicalizeOwned replaces this. bool SemanticARCOptVisitor::tryJoiningCopyValueLiveRangeWithOperand( CopyValueInst *cvi) { // First do a quick check if our operand is owned. If it is not owned, we can @@ -771,7 +771,7 @@ bool SemanticARCOptVisitor::tryJoiningCopyValueLiveRangeWithOperand( /// value and is not consumed, eliminate the copy. bool SemanticARCOptVisitor::tryPerformOwnedCopyValueOptimization( CopyValueInst *cvi) { - // All mandatory copy optimization is handled by CanonicalizeOSSALifetime, + // All mandatory copy optimization is handled by OSSACanonicalizeOwned, // which knows how to preserve lifetimes for debugging. if (ctx.onlyMandatoryOpts) return false; diff --git a/lib/SILOptimizer/SemanticARC/OwnershipLiveRange.cpp b/lib/SILOptimizer/SemanticARC/OwnershipLiveRange.cpp index 316d92020a57e..33b68d5db0d09 100644 --- a/lib/SILOptimizer/SemanticARC/OwnershipLiveRange.cpp +++ b/lib/SILOptimizer/SemanticARC/OwnershipLiveRange.cpp @@ -15,7 +15,7 @@ #include "swift/Basic/Assertions.h" #include "swift/SIL/BasicBlockUtils.h" -#include "swift/SIL/OSSALifetimeCompletion.h" +#include "swift/SIL/OSSACompleteLifetime.h" #include "swift/SIL/OwnershipUtils.h" using namespace swift; @@ -163,9 +163,9 @@ OwnershipLiveRange::OwnershipLiveRange( } liveness.updateForUse(use.first->getUser(), /*lifetimeEnding=*/true); } - OSSALifetimeCompletion::visitAvailabilityBoundary( + OSSACompleteLifetime::visitAvailabilityBoundary( def, liveness, [&tmpDestroyingUses](auto *inst, auto end) { - if (end != OSSALifetimeCompletion::LifetimeEnd::Boundary) { + if (end != OSSACompleteLifetime::LifetimeEnd::Boundary) { return; } tmpDestroyingUses.push_back(inst); diff --git a/lib/SILOptimizer/Transforms/CopyPropagation.cpp b/lib/SILOptimizer/Transforms/CopyPropagation.cpp index e4fb0a24a74ce..894a8251dd487 100644 --- a/lib/SILOptimizer/Transforms/CopyPropagation.cpp +++ b/lib/SILOptimizer/Transforms/CopyPropagation.cpp @@ -20,8 +20,8 @@ /// This pass operates independently on each extended lifetime--the lifetime of /// an OSSA reference after propagating that reference through all copies. For /// owned references, this is a simple process of canonicalization that can be -/// invoked separately via the CanonicalizeOSSALifetime utility. The -/// CanonicalizeBorrowScope utility handles borrowed references, but this is +/// invoked separately via the OSSACanonicalizeOwned utility. The +/// OSSACanonicalizeGuaranteed utility handles borrowed references, but this is /// much more involved. It requires coordination to cleanup owned lifetimes /// outside the borrow scope after canonicalizing the scope itself. /// @@ -59,9 +59,9 @@ #include "swift/SILOptimizer/Analysis/DeadEndBlocksAnalysis.h" #include "swift/SILOptimizer/PassManager/Passes.h" #include "swift/SILOptimizer/PassManager/Transforms.h" -#include "swift/SILOptimizer/Utils/CanonicalizeBorrowScope.h" -#include "swift/SILOptimizer/Utils/CanonicalizeOSSALifetime.h" #include "swift/SILOptimizer/Utils/InstOptUtils.h" +#include "swift/SILOptimizer/Utils/OSSACanonicalizeGuaranteed.h" +#include "swift/SILOptimizer/Utils/OSSACanonicalizeOwned.h" #include "swift/SILOptimizer/Utils/OwnershipOptUtils.h" #include "llvm/ADT/SetVector.h" @@ -102,13 +102,13 @@ struct CanonicalDefWorklist { return; while (true) { - def = CanonicalizeOSSALifetime::getCanonicalCopiedDef(def); + def = OSSACanonicalizeOwned::getCanonicalCopiedDef(def); // If the copy's source is guaranteed, find the root of a borrowed // extended lifetime. if (auto *copy = dyn_cast(def)) { if (SILValue borrowDef = - CanonicalizeBorrowScope::getCanonicalBorrowedDef( + OSSACanonicalizeGuaranteed::getCanonicalBorrowedDef( copy->getOperand())) { if (canonicalizeBorrows || isa(borrowDef)) { borrowedValues.insert(borrowDef); @@ -123,7 +123,7 @@ struct CanonicalDefWorklist { // Look through hoistable owned forwarding instructions on the // use-def chain. if (SILInstruction *defInst = def->getDefiningInstruction()) { - if (CanonicalizeBorrowScope::isRewritableOSSAForward(defInst)) { + if (OSSACanonicalizeGuaranteed::isRewritableOSSAForward(defInst)) { SILValue forwardedDef = defInst->getOperand(0); if (forwardedDef->getOwnershipKind() == OwnershipKind::Owned) { def = forwardedDef; @@ -151,7 +151,7 @@ struct CanonicalDefWorklist { useWorklist.append(copy->getUses().begin(), copy->getUses().end()); continue; } - if (!CanonicalizeBorrowScope::isRewritableOSSAForward(user)) + if (!OSSACanonicalizeGuaranteed::isRewritableOSSAForward(user)) continue; if (!ownedForwards.insert(user)) @@ -210,7 +210,7 @@ struct CanonicalDefWorklist { /// This allows the ownership of '%src' to be forwarded to its member. /// /// This utility runs during copy propagation as a prerequisite to -/// CanonicalizeBorrowScopes. +/// OSSACanonicalizeGuaranteeds. /// /// TODO: generalize this to handle multiple nondebug uses of the /// struct_extract. @@ -359,7 +359,7 @@ static void findPreheadersOnControlEquivalentPath( /// Sink \p ownedForward to its uses. /// /// Owned forwarding instructions are identified by -/// CanonicalizeOSSALifetime::isRewritableOSSAForward(). +/// OSSACanonicalizeOwned::isRewritableOSSAForward(). /// /// Assumes that the uses of ownedForward jointly postdominate it (valid OSSA). /// @@ -485,7 +485,7 @@ void CopyPropagation::propagateCopies( // canonicalizer performs all modifications through deleter's callbacks, so we // don't need to explicitly check for changes. - CanonicalizeOSSALifetime canonicalizer( + OSSACanonicalizeOwned canonicalizer( pruneDebug, MaximizeLifetime_t(!getFunction()->shouldOptimize()), getFunction(), accessBlockAnalysis, deadEndBlocksAnalysis, domTree, calleeAnalysis, deleter); @@ -496,9 +496,9 @@ void CopyPropagation::propagateCopies( bool firstRun = true; // Run the sequence of utilities: // - ShrinkBorrowScope - // - CanonicalizeOSSALifetime(borrowee) + // - OSSACanonicalizeOwned(borrowee) // - LexicalDestroyFolding - // - CanonicalizeOSSALifetime(folded) + // - OSSACanonicalizeOwned(folded) // at least once and then until each stops making changes. while (true) { SmallVector modifiedCopyValueInsts; @@ -512,7 +512,7 @@ void CopyPropagation::propagateCopies( if (!shrunk && !firstRun) break; - // If borrowed value is not owned, neither CanonicalizeOSSALifetime nor + // If borrowed value is not owned, neither OSSACanonicalizeOwned nor // LexicalDestroyFolding will do anything with it. Just bail out now. auto borrowee = bbi->getOperand(); if (borrowee->getOwnershipKind() != OwnershipKind::Owned) @@ -562,7 +562,7 @@ void CopyPropagation::propagateCopies( } // borrowCanonicalizer performs all modifications through deleter's // callbacks, so we don't need to explicitly check for changes. - CanonicalizeBorrowScope borrowCanonicalizer(f, deleter); + OSSACanonicalizeGuaranteed borrowCanonicalizer(f, deleter); // The utilities in this loop cannot delete borrows before they are popped // from the worklist. while (true) { @@ -581,7 +581,7 @@ void CopyPropagation::propagateCopies( // Canonicalize a forwarded owned value before sinking the forwarding // instruction, and sink the instruction before canonicalizing the owned // value being forwarded. Process 'ownedForwards' in reverse since - // they may be chained, and CanonicalizeBorrowScopes pushes them + // they may be chained, and OSSACanonicalizeGuaranteeds pushes them // top-down. for (auto result : ownedForward->getResults()) { if (!continueWithNextSubpassRun(result)) @@ -596,10 +596,10 @@ void CopyPropagation::propagateCopies( // operand. This handles chained forwarding instructions that were // pushed onto the list out-of-order. if (SILInstruction *forwardDef = - CanonicalizeOSSALifetime::getCanonicalCopiedDef( + OSSACanonicalizeOwned::getCanonicalCopiedDef( ownedForward->getOperand(0)) ->getDefiningInstruction()) { - if (CanonicalizeBorrowScope::isRewritableOSSAForward(forwardDef)) { + if (OSSACanonicalizeGuaranteed::isRewritableOSSAForward(forwardDef)) { defWorklist.ownedForwards.insert(forwardDef); } } diff --git a/lib/SILOptimizer/Transforms/DeadCodeElimination.cpp b/lib/SILOptimizer/Transforms/DeadCodeElimination.cpp index d1bcd5fcaaefa..f79aab4be0a02 100644 --- a/lib/SILOptimizer/Transforms/DeadCodeElimination.cpp +++ b/lib/SILOptimizer/Transforms/DeadCodeElimination.cpp @@ -17,7 +17,7 @@ #include "swift/SIL/DebugUtils.h" #include "swift/SIL/MemAccessUtils.h" #include "swift/SIL/NodeBits.h" -#include "swift/SIL/OSSALifetimeCompletion.h" +#include "swift/SIL/OSSACompleteLifetime.h" #include "swift/SIL/OwnershipUtils.h" #include "swift/SIL/SILArgument.h" #include "swift/SIL/SILBasicBlock.h" @@ -835,12 +835,12 @@ bool DCE::removeDead() { } } - OSSALifetimeCompletion completion(F, DT, *deadEndBlocks); + OSSACompleteLifetime completion(F, DT, *deadEndBlocks); for (auto value : valuesToComplete) { if (!value.has_value()) continue; completion.completeOSSALifetime(*value, - OSSALifetimeCompletion::Boundary::Liveness); + OSSACompleteLifetime::Boundary::Liveness); } return Changed; diff --git a/lib/SILOptimizer/Transforms/SILMem2Reg.cpp b/lib/SILOptimizer/Transforms/SILMem2Reg.cpp index 8d4efa8ad420c..699a5f3a04323 100644 --- a/lib/SILOptimizer/Transforms/SILMem2Reg.cpp +++ b/lib/SILOptimizer/Transforms/SILMem2Reg.cpp @@ -27,7 +27,7 @@ #include "swift/Basic/TaggedUnion.h" #include "swift/SIL/BasicBlockDatastructures.h" #include "swift/SIL/Dominance.h" -#include "swift/SIL/OSSALifetimeCompletion.h" +#include "swift/SIL/OSSACompleteLifetime.h" #include "swift/SIL/Projection.h" #include "swift/SIL/SILBuilder.h" #include "swift/SIL/SILFunction.h" @@ -40,9 +40,9 @@ #include "swift/SILOptimizer/PassManager/Passes.h" #include "swift/SILOptimizer/PassManager/Transforms.h" #include "swift/SILOptimizer/Utils/CFGOptUtils.h" -#include "swift/SILOptimizer/Utils/CanonicalizeBorrowScope.h" -#include "swift/SILOptimizer/Utils/CanonicalizeOSSALifetime.h" #include "swift/SILOptimizer/Utils/InstOptUtils.h" +#include "swift/SILOptimizer/Utils/OSSACanonicalizeGuaranteed.h" +#include "swift/SILOptimizer/Utils/OSSACanonicalizeOwned.h" #include "swift/SILOptimizer/Utils/OwnershipOptUtils.h" #include "swift/SILOptimizer/Utils/ScopeOptUtils.h" #include "llvm/ADT/DenseMap.h" @@ -1823,8 +1823,8 @@ void StackAllocationPromoter::run(BasicBlockSetVector &livePhiBlocks) { deleter.forceDeleteWithUsers(asi); // Now, complete lifetimes! - OSSALifetimeCompletion completion(function, domInfo, - *deadEndBlocksAnalysis->get(function)); + OSSACompleteLifetime completion(function, domInfo, + *deadEndBlocksAnalysis->get(function)); // We may have incomplete lifetimes for enum locations on trivial paths. // After promoting them, complete lifetime here. @@ -1832,7 +1832,7 @@ void StackAllocationPromoter::run(BasicBlockSetVector &livePhiBlocks) { // Set forceBoundaryCompletion as true so that we complete at boundary for // lexical values as well. completion.completeOSSALifetime(it, - OSSALifetimeCompletion::Boundary::Liveness); + OSSACompleteLifetime::Boundary::Liveness); } } @@ -2149,28 +2149,29 @@ void MemoryToRegisters::canonicalizeValueLifetimes( break; } } - CanonicalizeOSSALifetime canonicalizer( + OSSACanonicalizeOwned canonicalizer( PruneDebugInsts, MaximizeLifetime_t(!f.shouldOptimize()), &f, accessBlockAnalysis, deadEndBlocksAnalysis, domInfo, calleeAnalysis, deleter); for (auto value : owned) { if (isa(value) || value->isMarkedAsDeleted()) continue; - auto root = CanonicalizeOSSALifetime::getCanonicalCopiedDef(value); + auto root = OSSACanonicalizeOwned::getCanonicalCopiedDef(value); if (auto *copy = dyn_cast(root)) { - if (SILValue borrowDef = CanonicalizeBorrowScope::getCanonicalBorrowedDef( - copy->getOperand())) { + if (SILValue borrowDef = + OSSACanonicalizeGuaranteed::getCanonicalBorrowedDef( + copy->getOperand())) { guaranteed.push_back(copy); continue; } } canonicalizer.canonicalizeValueLifetime(root); } - CanonicalizeBorrowScope borrowCanonicalizer(&f, deleter); + OSSACanonicalizeGuaranteed borrowCanonicalizer(&f, deleter); for (auto value : guaranteed) { if (isa(value) || value->isMarkedAsDeleted()) continue; - auto borrowee = CanonicalizeBorrowScope::getCanonicalBorrowedDef(value); + auto borrowee = OSSACanonicalizeGuaranteed::getCanonicalBorrowedDef(value); if (!borrowee) continue; BorrowedValue borrow(borrowee); diff --git a/lib/SILOptimizer/Utils/CMakeLists.txt b/lib/SILOptimizer/Utils/CMakeLists.txt index 43187c612694b..125f37032ef88 100644 --- a/lib/SILOptimizer/Utils/CMakeLists.txt +++ b/lib/SILOptimizer/Utils/CMakeLists.txt @@ -2,8 +2,8 @@ target_sources(swiftSILOptimizer PRIVATE BasicBlockOptUtils.cpp CFGOptUtils.cpp CanonicalizeInstruction.cpp - CanonicalizeOSSALifetime.cpp - CanonicalizeBorrowScope.cpp + OSSACanonicalizeOwned.cpp + OSSACanonicalizeGuaranteed.cpp CastOptimizer.cpp CheckedCastBrJumpThreading.cpp CompileTimeInterpolationUtils.cpp diff --git a/lib/SILOptimizer/Utils/LexicalDestroyFolding.cpp b/lib/SILOptimizer/Utils/LexicalDestroyFolding.cpp index 91403fa8e62f6..2d7f2457ff199 100644 --- a/lib/SILOptimizer/Utils/LexicalDestroyFolding.cpp +++ b/lib/SILOptimizer/Utils/LexicalDestroyFolding.cpp @@ -9,7 +9,7 @@ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// -/// After ShrinkBorrowScope and CanonicalizeOSSALifetime both run, when a final +/// After ShrinkBorrowScope and OSSACanonicalizeOwned both run, when a final /// use of the extended simple lifetime of a begin_borrow [lexical] is as an /// owned argument, we will have the following pattern: /// @@ -89,9 +89,9 @@ #include "swift/SIL/Test.h" #include "swift/SILOptimizer/Analysis/Reachability.h" #include "swift/SILOptimizer/PassManager/Transforms.h" -#include "swift/SILOptimizer/Utils/CanonicalizeBorrowScope.h" -#include "swift/SILOptimizer/Utils/CanonicalizeOSSALifetime.h" #include "swift/SILOptimizer/Utils/InstructionDeleter.h" +#include "swift/SILOptimizer/Utils/OSSACanonicalizeGuaranteed.h" +#include "swift/SILOptimizer/Utils/OSSACanonicalizeOwned.h" #include "swift/SILOptimizer/Utils/SILSSAUpdater.h" #include "llvm/ADT/SmallVector.h" @@ -218,7 +218,7 @@ class FindCandidates final { /// /// apply /// end_borrow - /// ... // instructions which CanonicalizeOSSALifetime will not + /// ... // instructions which OSSACanonicalizeOwned will not /// // hoist destroys over /// destroy_value %borrowee /// @@ -235,13 +235,13 @@ class FindCandidates final { /// sequence of "inconsequential" instructions the last of which destroys /// %borrowee. /// - /// CanonicalizeOSSALifetime will put destroy_value instructions after every + /// OSSACanonicalizeOwned will put destroy_value instructions after every /// final non-consuming use of %borrowee. So it will put a /// destroy_value after an /// end_borrow %lifetime /// if there are no subsequent uses of %borrowee. However, if there /// is already one or more other instructions whose opcodes satisfy - /// CanonicalizeOSSALifetime::ignoredByDestroyHoisting just after + /// OSSACanonicalizeOwned::ignoredByDestroyHoisting just after /// end_borrow %lifetime, /// it won't hoist the /// destroy_value %borrowee @@ -692,9 +692,9 @@ FindCandidates::definesMatchingInstructionSequence(SILInstruction *inst) const { DestroyValueInst * FindCandidates::findNextBorroweeDestroy(SILInstruction *from) const { for (auto *inst = from; inst; inst = inst->getNextInstruction()) { - if (!CanonicalizeOSSALifetime::ignoredByDestroyHoisting(inst->getKind())) { - // This is not an instruction that CanonicalizeOSSALifetime would not - // hoist a destroy above. In other words, CanonicalizeOSSALifetime would + if (!OSSACanonicalizeOwned::ignoredByDestroyHoisting(inst->getKind())) { + // This is not an instruction that OSSACanonicalizeOwned would not + // hoist a destroy above. In other words, OSSACanonicalizeOwned would // have hoisted // destroy_value %borrowee // over this instruction if it could have. Stop looking. diff --git a/lib/SILOptimizer/Utils/CanonicalizeBorrowScope.cpp b/lib/SILOptimizer/Utils/OSSACanonicalizeGuaranteed.cpp similarity index 91% rename from lib/SILOptimizer/Utils/CanonicalizeBorrowScope.cpp rename to lib/SILOptimizer/Utils/OSSACanonicalizeGuaranteed.cpp index e068d4cd2f3f6..5695e1091c072 100644 --- a/lib/SILOptimizer/Utils/CanonicalizeBorrowScope.cpp +++ b/lib/SILOptimizer/Utils/OSSACanonicalizeGuaranteed.cpp @@ -1,4 +1,4 @@ -//===--- CanonicalizeBorrowScope.cpp - Canonicalize OSSA borrow scopes ----===// +//===-- OSSACanonicalizeGuaranteed.cpp - Canonicalize OSSA borrow scopes --===// // // This source file is part of the Swift.org open source project // @@ -22,16 +22,16 @@ #define DEBUG_TYPE "copy-propagation" +#include "swift/SILOptimizer/Utils/OSSACanonicalizeGuaranteed.h" #include "swift/Basic/Assertions.h" -#include "swift/SILOptimizer/Utils/CanonicalizeBorrowScope.h" #include "swift/Basic/Defer.h" #include "swift/SIL/InstructionUtils.h" #include "swift/SIL/OwnershipUtils.h" #include "swift/SIL/Test.h" #include "swift/SILOptimizer/Utils/CFGOptUtils.h" -#include "swift/SILOptimizer/Utils/CanonicalizeOSSALifetime.h" #include "swift/SILOptimizer/Utils/DebugOptUtils.h" #include "swift/SILOptimizer/Utils/InstructionDeleter.h" +#include "swift/SILOptimizer/Utils/OSSACanonicalizeOwned.h" #include "swift/SILOptimizer/Utils/ValueLifetime.h" #include "llvm/ADT/Statistic.h" @@ -88,7 +88,7 @@ static void deleteCopyAndMoveChain(SILValue v, InstructionDeleter &deleter) { /// Enum, InitExistential, MarkDependence /// Struct, Tuple /// SelectEnum, SwitchEnum, CheckCastBranch -bool CanonicalizeBorrowScope::isRewritableOSSAForward(SILInstruction *inst) { +bool OSSACanonicalizeGuaranteed::isRewritableOSSAForward(SILInstruction *inst) { if (!inst->isTriviallyDuplicatable()) return false; @@ -124,7 +124,7 @@ bool CanonicalizeBorrowScope::isRewritableOSSAForward(SILInstruction *inst) { /// Return the root of a borrowed extended lifetime for \p def or invalid. /// /// \p def may be any guaranteed value. -SILValue CanonicalizeBorrowScope::getCanonicalBorrowedDef(SILValue def) { +SILValue OSSACanonicalizeGuaranteed::getCanonicalBorrowedDef(SILValue def) { while (true) { if (def->getOwnershipKind() != OwnershipKind::Guaranteed) break; @@ -151,7 +151,7 @@ SILValue CanonicalizeBorrowScope::getCanonicalBorrowedDef(SILValue def) { if (!defInst) break; - if (!CanonicalizeBorrowScope::isRewritableOSSAForward(defInst)) + if (!OSSACanonicalizeGuaranteed::isRewritableOSSAForward(defInst)) break; def = defInst->getOperand(0); @@ -159,7 +159,7 @@ SILValue CanonicalizeBorrowScope::getCanonicalBorrowedDef(SILValue def) { return SILValue(); } -bool CanonicalizeBorrowScope::computeBorrowLiveness() { +bool OSSACanonicalizeGuaranteed::computeBorrowLiveness() { switch (borrowedValue.kind) { case BorrowedValueKind::Invalid: llvm_unreachable("Used invalid"); @@ -189,7 +189,7 @@ bool CanonicalizeBorrowScope::computeBorrowLiveness() { /// Return the source of a use within a borrow scope. This is the use-def /// equivalent to the logic in visitBorrowScopeUses that recurses through /// copies. The use-def and def-use logic must be consistent. -SILValue CanonicalizeBorrowScope::findDefInBorrowScope(SILValue value) { +SILValue OSSACanonicalizeGuaranteed::findDefInBorrowScope(SILValue value) { while (auto *inst = asCopyOrMove(value)) { auto *copy = dyn_cast(inst); if (copy && isPersistentCopy(copy)) @@ -219,8 +219,8 @@ SILValue CanonicalizeBorrowScope::findDefInBorrowScope(SILValue value) { /// \p innerValue is either the initial begin_borrow, or a forwarding operation /// within the borrow scope. template -bool CanonicalizeBorrowScope::visitBorrowScopeUses(SILValue innerValue, - Visitor &visitor) { +bool OSSACanonicalizeGuaranteed::visitBorrowScopeUses(SILValue innerValue, + Visitor &visitor) { // defUseWorklist is used recursively here. // This avoids revisiting uses in case we ever recurse through // both structs and destructures. @@ -288,7 +288,7 @@ bool CanonicalizeBorrowScope::visitBorrowScopeUses(SILValue innerValue, case OperandOwnership::GuaranteedForwarding: case OperandOwnership::ForwardingConsume: - if (CanonicalizeBorrowScope::isRewritableOSSAForward(user)) { + if (OSSACanonicalizeGuaranteed::isRewritableOSSAForward(user)) { if (!visitor.visitForwardingUse(use)) { return false; } @@ -313,13 +313,13 @@ bool CanonicalizeBorrowScope::visitBorrowScopeUses(SILValue innerValue, namespace { -using OuterUsers = CanonicalizeBorrowScope::OuterUsers; +using OuterUsers = OSSACanonicalizeGuaranteed::OuterUsers; /// Find all potential outer uses within a borrow scope. /// /// Implements visitBorrowScopeUses class FindBorrowScopeUses { - CanonicalizeBorrowScope &scope; + OSSACanonicalizeGuaranteed &scope; /// useInsts are the potentially outer use instructions. This set is built up /// recursively. It is pared down to only the outer uses outside this class by @@ -327,7 +327,7 @@ class FindBorrowScopeUses { OuterUsers useInsts; public: - FindBorrowScopeUses(CanonicalizeBorrowScope &scope) : scope(scope) {} + FindBorrowScopeUses(OSSACanonicalizeGuaranteed &scope) : scope(scope) {} std::optional findUses() && { scope.beginVisitBorrowScopeUses(); @@ -341,7 +341,7 @@ class FindBorrowScopeUses { // A guaranteed use can never be outside this borrow scope if (use->get()->getOwnershipKind() == OwnershipKind::Guaranteed) return true; - + auto *user = use->getUser(); if (!isUserInLiveOutBlock(user)) { useInsts.insert(user); @@ -351,12 +351,12 @@ class FindBorrowScopeUses { // points. Note: The logic in filterOuterBorrowUseInsts that checks // whether a borrow scope is an outer use must visit the same set of uses. if (!borrowingOper.visitExtendedScopeEndingUses([&](Operand *endBorrow) { - auto *endInst = endBorrow->getUser(); - if (!isUserInLiveOutBlock(endInst)) { - useInsts.insert(endInst); - } - return true; - })) { + auto *endInst = endBorrow->getUser(); + if (!isUserInLiveOutBlock(endInst)) { + useInsts.insert(endInst); + } + return true; + })) { // Bail out on dead borrow scopes and scopes with unknown uses. return false; } @@ -381,8 +381,8 @@ class FindBorrowScopeUses { protected: bool isUserInLiveOutBlock(SILInstruction *user) { - return (scope.getLiveness().getBlockLiveness(user->getParent()) - == PrunedLiveBlocks::LiveOut); + return (scope.getLiveness().getBlockLiveness(user->getParent()) == + PrunedLiveBlocks::LiveOut); return false; }; }; @@ -390,7 +390,7 @@ class FindBorrowScopeUses { } // namespace /// Erase users from \p outerUseInsts that are actually within the borrow scope. -void CanonicalizeBorrowScope::filterOuterBorrowUseInsts( +void OSSACanonicalizeGuaranteed::filterOuterBorrowUseInsts( OuterUsers &outerUseInsts) { auto *beginBorrow = cast(borrowedValue.value); SmallVector scopeEndingInsts; @@ -427,12 +427,12 @@ namespace { /// /// The visitor callbacks must always return true since this rewrites in-place. class RewriteInnerBorrowUses { - CanonicalizeBorrowScope &scope; + OSSACanonicalizeGuaranteed &scope; public: - RewriteInnerBorrowUses(CanonicalizeBorrowScope &scope): scope(scope) {} + RewriteInnerBorrowUses(OSSACanonicalizeGuaranteed &scope) : scope(scope) {} - CanonicalizeBorrowScope &getScope() const { return scope; } + OSSACanonicalizeGuaranteed &getScope() const { return scope; } // Implements visitBorrowScopeUses bool visitUse(Operand *use) { @@ -473,7 +473,7 @@ class RewriteInnerBorrowUses { // Implements visitBorrowScopeUses bool visitForwardingUse(Operand *use) { auto *user = use->getUser(); - assert(CanonicalizeBorrowScope::isRewritableOSSAForward(user)); + assert(OSSACanonicalizeGuaranteed::isRewritableOSSAForward(user)); for (auto result : user->getResults()) { if (!hasValueOwnership(result)) { @@ -504,7 +504,7 @@ class RewriteInnerBorrowUses { /// /// The visitor callbacks must always return true since this rewrites in-place. class RewriteOuterBorrowUses { - CanonicalizeBorrowScope &scope; + OSSACanonicalizeGuaranteed &scope; RewriteInnerBorrowUses &innerRewriter; @@ -523,12 +523,12 @@ class RewriteOuterBorrowUses { RewriteOuterBorrowUses(RewriteInnerBorrowUses &innerRewriter, const OuterUsers &outerUseInsts, InnerToOuterMap &innerToOuterMap) - : scope(innerRewriter.getScope()), innerRewriter(innerRewriter), - outerUseInsts(outerUseInsts), innerToOuterMap(innerToOuterMap) {} + : scope(innerRewriter.getScope()), innerRewriter(innerRewriter), + outerUseInsts(outerUseInsts), innerToOuterMap(innerToOuterMap) {} public: static void rewrite(BeginBorrowInst *beginBorrow, - CanonicalizeBorrowScope &scope, + OSSACanonicalizeGuaranteed &scope, const OuterUsers &outerUseInsts) { SILBuilderWithScope builder(beginBorrow); @@ -558,10 +558,9 @@ class RewriteOuterBorrowUses { // instructions are outside the current scope (this can happen if any copy // has occurred on the def-use chain within the current scope). if (auto borrowingOper = BorrowingOperand(use)) { - if (!borrowingOper.visitExtendedScopeEndingUses( - [&](Operand *endBorrow) { - return !outerUseInsts.count(endBorrow->getUser()); - })) { + if (!borrowingOper.visitExtendedScopeEndingUses([&](Operand *endBorrow) { + return !outerUseInsts.count(endBorrow->getUser()); + })) { rewriteOuterUse(use); return true; } @@ -575,7 +574,7 @@ class RewriteOuterBorrowUses { // Implements visitBorrowScopeUses bool visitForwardingUse(Operand *use) { auto *user = use->getUser(); - assert(CanonicalizeBorrowScope::isRewritableOSSAForward(user)); + assert(OSSACanonicalizeGuaranteed::isRewritableOSSAForward(user)); if (outerUseInsts.count(user)) { rewriteOuterUse(use); return true; @@ -621,7 +620,7 @@ class RewriteOuterBorrowUses { // have no outer uses of its first block. static CopyValueInst *createOuterCopy(SILValue incomingValue, SILBuilder &builder, SILLocation loc, - CanonicalizeBorrowScope &scope) { + OSSACanonicalizeGuaranteed &scope) { auto *copy = builder.createCopyValue(loc, incomingValue); scope.getCallbacks().createdNewInst(copy); scope.recordOuterCopy(copy); @@ -686,7 +685,7 @@ SILValue RewriteOuterBorrowUses::createOuterValues(SILValue innerValue) { return iter->second; } auto *innerInst = innerValue->getDefiningInstruction(); - assert(CanonicalizeBorrowScope::isRewritableOSSAForward(innerInst)); + assert(OSSACanonicalizeGuaranteed::isRewritableOSSAForward(innerInst)); SILValue incomingInnerVal = innerInst->getOperand(0); auto incomingOuterVal = createOuterValues(incomingInnerVal); @@ -724,8 +723,8 @@ void RewriteOuterBorrowUses::cleanupOuterValue(SILValue outerValue) { outerUses); auto createDestroy = [&](SILBuilder &b, SILLocation loc) { - auto *dvi = b.createDestroyValue(loc, outerValue); - scope.getCallbacks().createdNewInst(dvi); + auto *dvi = b.createDestroyValue(loc, outerValue); + scope.getCallbacks().createdNewInst(dvi); }; if (outerUses.empty()) { SILBuilder b(outerValue->getNextInstruction()); @@ -749,9 +748,8 @@ void RewriteOuterBorrowUses::cleanupOuterValue(SILValue outerValue) { if (unclaimedConsumingUsers.erase(lastUser)) continue; - SILBuilderWithScope::insertAfter(lastUser, [&](SILBuilder &b) { - createDestroy(b, lastUser->getLoc()); - }); + SILBuilderWithScope::insertAfter( + lastUser, [&](SILBuilder &b) { createDestroy(b, lastUser->getLoc()); }); } // Add copies for consuming users of outerValue. for (auto *use : consumingUses) { @@ -774,7 +772,7 @@ void RewriteOuterBorrowUses::cleanupOuterValue(SILValue outerValue) { // TODO: Canonicalize multi-block borrow scopes, load_borrow scope, and phi // borrow scopes by adding one copy per block to persistentCopies for // each block that dominates an outer use. -bool CanonicalizeBorrowScope::consolidateBorrowScope() { +bool OSSACanonicalizeGuaranteed::consolidateBorrowScope() { OuterUsers outerUseInsts; if (!isa(borrowedValue.value)) { // getCanonicalCopiedDef ensures that if currentDef is a guaranteed value, @@ -809,10 +807,10 @@ bool CanonicalizeBorrowScope::consolidateBorrowScope() { } //===----------------------------------------------------------------------===// -// MARK: Top-Level CanonicalizeBorrowScope +// MARK: Top-Level OSSACanonicalizeGuaranteed //===----------------------------------------------------------------------===// -bool CanonicalizeBorrowScope::canonicalizeFunctionArgument( +bool OSSACanonicalizeGuaranteed::canonicalizeFunctionArgument( SILFunctionArgument *arg) { BorrowedValue borrow(arg); if (!borrow) @@ -838,7 +836,7 @@ static FunctionTest CanonicalizeFunctionArgumentTest( [](auto &function, auto &arguments, auto &test) { auto *argument = cast(arguments.takeBlockArgument()); InstructionDeleter deleter; - CanonicalizeBorrowScope canonicalizer(&function, deleter); + OSSACanonicalizeGuaranteed canonicalizer(&function, deleter); canonicalizer.canonicalizeFunctionArgument(argument); function.print(llvm::outs()); }); @@ -847,8 +845,8 @@ static FunctionTest CanonicalizeFunctionArgumentTest( /// Canonicalize a worklist of extended lifetimes. This iterates after rewriting /// borrow scopes to handle new outer copies and new owned lifetimes from /// forwarding operations. -bool CanonicalizeBorrowScope:: -canonicalizeBorrowScope(BorrowedValue borrowedValue) { +bool OSSACanonicalizeGuaranteed::canonicalizeBorrowScope( + BorrowedValue borrowedValue) { BitfieldRef::StackState livenessBitfieldContainer( liveness, function); @@ -872,14 +870,14 @@ namespace swift::test { // - SILValue: value to canonicalize // Dumps: // - function after value canonicalization -static FunctionTest CanonicalizeBorrowScopeTest( - "canonicalize_borrow_scope", +static FunctionTest OSSACanonicalizeGuaranteedTest( + "ossa_canonicalize_guaranteed", [](auto &function, auto &arguments, auto &test) { auto value = arguments.takeValue(); auto borrowedValue = BorrowedValue(value); assert(borrowedValue && "specified value isn't a BorrowedValue!?"); InstructionDeleter deleter; - CanonicalizeBorrowScope canonicalizer(value->getFunction(), deleter); + OSSACanonicalizeGuaranteed canonicalizer(value->getFunction(), deleter); canonicalizer.canonicalizeBorrowScope(borrowedValue); function.print(llvm::outs()); }); diff --git a/lib/SILOptimizer/Utils/CanonicalizeOSSALifetime.cpp b/lib/SILOptimizer/Utils/OSSACanonicalizeOwned.cpp similarity index 92% rename from lib/SILOptimizer/Utils/CanonicalizeOSSALifetime.cpp rename to lib/SILOptimizer/Utils/OSSACanonicalizeOwned.cpp index 52f85ed36178c..339e0abb9f931 100644 --- a/lib/SILOptimizer/Utils/CanonicalizeOSSALifetime.cpp +++ b/lib/SILOptimizer/Utils/OSSACanonicalizeOwned.cpp @@ -1,4 +1,4 @@ -//===-- CanonicalizeOSSALifetime.cpp - Canonicalize OSSA value lifetimes --===// +//===-- OSSACanonicalizeOwned.cpp - Canonicalize OSSA value lifetimes --===// // // This source file is part of the Swift.org open source project // @@ -12,7 +12,7 @@ /// /// This top-level API rewrites the extended lifetime of a SILValue: /// -/// bool CanonicalizeOSSALifetime::canonicalizeValueLifetime(SILValue def) +/// bool OSSACanonicalizeOwned::canonicalizeValueLifetime(SILValue def) /// /// Each time it's called on a single OSSA value, `def`, it performs four /// steps: @@ -35,7 +35,7 @@ /// 6. Rewrite `def`s original copies and destroys, inserting new copies where /// needed. Deletes original copies and destroys and inserts new copies. /// -/// See CanonicalizeOSSALifetime.h for examples. +/// See OSSACanonicalizeOwned.h for examples. /// /// TODO: Canonicalization currently bails out if any uses of the def has /// OperandOwnership::PointerEscape. Once project_box is protected by a borrow @@ -65,11 +65,11 @@ #define DEBUG_TYPE "copy-propagation" -#include "swift/SILOptimizer/Utils/CanonicalizeOSSALifetime.h" +#include "swift/SILOptimizer/Utils/OSSACanonicalizeOwned.h" #include "swift/Basic/Assertions.h" #include "swift/SIL/InstructionUtils.h" #include "swift/SIL/NodeDatastructures.h" -#include "swift/SIL/OSSALifetimeCompletion.h" +#include "swift/SIL/OSSACompleteLifetime.h" #include "swift/SIL/OwnershipUtils.h" #include "swift/SIL/PrunedLiveness.h" #include "swift/SIL/Test.h" @@ -129,7 +129,7 @@ static bool isDestroyOfCopyOf(SILInstruction *instruction, SILValue def) { // MARK: Step 1. Compute pruned liveness //===----------------------------------------------------------------------===// -bool CanonicalizeOSSALifetime::computeCanonicalLiveness() { +bool OSSACanonicalizeOwned::computeCanonicalLiveness() { LLVM_DEBUG(llvm::dbgs() << "Computing canonical liveness from:\n"; getCurrentDef()->print(llvm::dbgs())); SmallVector indexWorklist; @@ -186,8 +186,8 @@ bool CanonicalizeOSSALifetime::computeCanonicalLiveness() { if (auto *dvi = dyn_cast(user)) { // Only instructions potentially outside current pruned liveness are // interesting. - if (liveness->getBlockLiveness(dvi->getParent()) - != PrunedLiveBlocks::LiveOut) { + if (liveness->getBlockLiveness(dvi->getParent()) != + PrunedLiveBlocks::LiveOut) { recordDebugValue(dvi); } continue; @@ -231,9 +231,10 @@ bool CanonicalizeOSSALifetime::computeCanonicalLiveness() { recordConsumingUse(use); break; case OperandOwnership::Borrow: - if (liveness->updateForBorrowingOperand(use) - != InnerBorrowKind::Contained) { - LLVM_DEBUG(llvm::dbgs() << " Inner borrow can't be contained! Giving up\n"); + if (liveness->updateForBorrowingOperand(use) != + InnerBorrowKind::Contained) { + LLVM_DEBUG(llvm::dbgs() + << " Inner borrow can't be contained! Giving up\n"); return false; } break; @@ -293,16 +294,16 @@ bool CanonicalizeOSSALifetime::computeCanonicalLiveness() { /// apply %foo() // deinit barrier /// // Must extend lifetime of %def up to this point per language rules. /// unreachable -void CanonicalizeOSSALifetime::extendLexicalLivenessToDeadEnds() { - // TODO: OSSALifetimeCompletion: Once lifetimes are always complete, delete +void OSSACanonicalizeOwned::extendLexicalLivenessToDeadEnds() { + // TODO: OSSACompleteLifetime: Once lifetimes are always complete, delete // this method. SmallVector directDiscoverdBlocks; SSAPrunedLiveness directLiveness(function, &directDiscoverdBlocks); directLiveness.initializeDef(getCurrentDef()); directLiveness.computeSimple(); - OSSALifetimeCompletion::visitAvailabilityBoundary( + OSSACompleteLifetime::visitAvailabilityBoundary( getCurrentDef(), directLiveness, [&](auto *unreachable, auto end) { - if (end == OSSALifetimeCompletion::LifetimeEnd::Boundary) { + if (end == OSSACompleteLifetime::LifetimeEnd::Boundary) { recordUnreachableLifetimeEnd(unreachable); } unreachable->visitPriorInstructions([&](auto *inst) { @@ -324,8 +325,8 @@ void CanonicalizeOSSALifetime::extendLexicalLivenessToDeadEnds() { /// // destroy_value could be inserted within a borrow scope or interior /// // pointer use. /// unreachable -void CanonicalizeOSSALifetime::extendLivenessToDeadEnds() { - // TODO: OSSALifetimeCompletion: Once lifetimes are always complete, delete +void OSSACanonicalizeOwned::extendLivenessToDeadEnds() { + // TODO: OSSACompleteLifetime: Once lifetimes are always complete, delete // this method. SmallVector discoveredBlocks(this->discoveredBlocks); SSAPrunedLiveness completeLiveness(*liveness, &discoveredBlocks); @@ -338,7 +339,7 @@ void CanonicalizeOSSALifetime::extendLivenessToDeadEnds() { // Demote consuming uses within complete liveness to non-consuming uses. // - // OSSALifetimeCompletion considers the lifetime of a single value. Such + // OSSACompleteLifetime considers the lifetime of a single value. Such // lifetimes never continue beyond consumes. std::optional> lastUsers; auto isConsumeOnBoundary = [&](SILInstruction *instruction) -> bool { @@ -373,9 +374,9 @@ void CanonicalizeOSSALifetime::extendLivenessToDeadEnds() { completeLiveness.updateForUse(pair.first, /*lifetimeEnding=*/false); } - OSSALifetimeCompletion::visitAvailabilityBoundary( + OSSACompleteLifetime::visitAvailabilityBoundary( getCurrentDef(), completeLiveness, [&](auto *unreachable, auto end) { - if (end == OSSALifetimeCompletion::LifetimeEnd::Boundary) { + if (end == OSSACompleteLifetime::LifetimeEnd::Boundary) { recordUnreachableLifetimeEnd(unreachable); } unreachable->visitPriorInstructions([&](auto *inst) { @@ -385,12 +386,11 @@ void CanonicalizeOSSALifetime::extendLivenessToDeadEnds() { }); } -void CanonicalizeOSSALifetime::extendLivenessToDeinitBarriers() { +void OSSACanonicalizeOwned::extendLivenessToDeinitBarriers() { SmallVector ends; if (endingLifetimeAtExplicitEnds()) { visitExtendedUnconsumedBoundary( - explicitLifetimeEnds, - [&ends](auto *instruction, auto lifetimeEnding) { + explicitLifetimeEnds, [&ends](auto *instruction, auto lifetimeEnding) { instruction->visitSubsequentInstructions([&](auto *next) { ends.push_back(next); return true; @@ -409,28 +409,28 @@ void CanonicalizeOSSALifetime::extendLivenessToDeinitBarriers() { auto *defBlock = getCurrentDef()->getParentBlock(); auto initialBlocks = defBlock ? InitialBlocks(defBlock) : InitialBlocks(); ReachableBarriers barriers; - findBarriersBackward(ends, initialBlocks, *getCurrentDef()->getFunction(), - barriers, [&](auto *inst) { - if (inst == def) - return true; - if (!isDeinitBarrier(inst, calleeAnalysis)) - return false; - // For the most part, instructions that are deinit - // barriers in the abstract are also deinit barriers - // for the purposes of canonicalizing def's lifetime. - // - // There is an important exception: transferring an - // owned lexical lifetime into a callee. If the - // instruction is a full apply which consumes def, - // then it isn't a deinit barrier. Keep looking for - // barriers above it. - auto apply = FullApplySite::isa(inst); - if (!apply) - return true; - return liveness->isInterestingUser(inst) != - PrunedLiveness::IsInterestingUser:: - LifetimeEndingUse; - }); + findBarriersBackward( + ends, initialBlocks, *getCurrentDef()->getFunction(), barriers, + [&](auto *inst) { + if (inst == def) + return true; + if (!isDeinitBarrier(inst, calleeAnalysis)) + return false; + // For the most part, instructions that are deinit + // barriers in the abstract are also deinit barriers + // for the purposes of canonicalizing def's lifetime. + // + // There is an important exception: transferring an + // owned lexical lifetime into a callee. If the + // instruction is a full apply which consumes def, + // then it isn't a deinit barrier. Keep looking for + // barriers above it. + auto apply = FullApplySite::isa(inst); + if (!apply) + return true; + return liveness->isInterestingUser(inst) != + PrunedLiveness::IsInterestingUser::LifetimeEndingUse; + }); for (auto *barrier : barriers.instructions) { liveness->extendToNonUse(barrier); } @@ -475,8 +475,8 @@ void CanonicalizeOSSALifetime::extendLivenessToDeinitBarriers() { // use %def // pruned liveness ends here // end_access // -bool CanonicalizeOSSALifetime:: -endsAccessOverlappingPrunedBoundary(SILInstruction *inst) { +bool OSSACanonicalizeOwned::endsAccessOverlappingPrunedBoundary( + SILInstruction *inst) { if (isa(inst)) { return true; } @@ -505,10 +505,9 @@ endsAccessOverlappingPrunedBoundary(SILInstruction *inst) { // endAccess if (std::find_if(std::next(beginAccess->getIterator()), beginBB->end(), [this](SILInstruction &nextInst) { - return liveness->isInterestingUser(&nextInst) - != PrunedLiveness::NonUser; - }) - != beginBB->end()) { + return liveness->isInterestingUser(&nextInst) != + PrunedLiveness::NonUser; + }) != beginBB->end()) { // An interesting use after the beginAccess means overlap. return true; } @@ -569,7 +568,7 @@ endsAccessOverlappingPrunedBoundary(SILInstruction *inst) { // // If the lifetime extension did not iterate, then def would be destroyed within // B's access scope when originally it was destroyed outside that scope. -void CanonicalizeOSSALifetime::extendLivenessThroughOverlappingAccess() { +void OSSACanonicalizeOwned::extendLivenessThroughOverlappingAccess() { this->accessBlocks = accessBlockAnalysis->get(getCurrentDef()->getFunction()); // Visit each original consuming use or destroy as the starting point for a @@ -620,20 +619,20 @@ void CanonicalizeOSSALifetime::extendLivenessThroughOverlappingAccess() { // We need to avoid extending liveness over end_accesses that occur after // original liveness ended. bool findLastConsume = - consumingBlocks.contains(bb) - && llvm::none_of(bb->getSuccessorBlocks(), [&](auto *successor) { - return blocksToVisit.contains(successor) - && liveness->getBlockLiveness(successor) - == PrunedLiveBlocks::Dead; - }); + consumingBlocks.contains(bb) && + llvm::none_of(bb->getSuccessorBlocks(), [&](auto *successor) { + return blocksToVisit.contains(successor) && + liveness->getBlockLiveness(successor) == + PrunedLiveBlocks::Dead; + }); for (auto &inst : llvm::reverse(*bb)) { if (findLastConsume) { findLastConsume = !destroys.contains(&inst); continue; } // Stop at the latest use. An earlier end_access does not overlap. - if (blockHasUse - && liveness->isInterestingUser(&inst) != PrunedLiveness::NonUser) { + if (blockHasUse && + liveness->isInterestingUser(&inst) != PrunedLiveness::NonUser) { break; } if (endsAccessOverlappingPrunedBoundary(&inst)) { @@ -655,7 +654,7 @@ void CanonicalizeOSSALifetime::extendLivenessThroughOverlappingAccess() { // liveness built up in step 1. //===----------------------------------------------------------------------===// -void CanonicalizeOSSALifetime::findOriginalBoundary( +void OSSACanonicalizeOwned::findOriginalBoundary( PrunedLivenessBoundary &boundary) { assert(boundary.lastUsers.size() == 0 && boundary.boundaryEdges.size() == 0 && boundary.deadDefs.size() == 0); @@ -693,7 +692,7 @@ void CanonicalizeOSSALifetime::findOriginalBoundary( /// with consumedAtExitBlocks, liveness should be extended to its original /// extent. /// [Extend liveness down to the boundary between green blocks and uncolored.] -void CanonicalizeOSSALifetime::visitExtendedUnconsumedBoundary( +void OSSACanonicalizeOwned::visitExtendedUnconsumedBoundary( ArrayRef consumes, llvm::function_ref visitor) { @@ -753,8 +752,8 @@ void CanonicalizeOSSALifetime::visitExtendedUnconsumedBoundary( for (auto *instruction : consumes) { if (destroys.contains(instruction)) continue; - if (liveness->isInterestingUser(instruction) - != PrunedLiveness::IsInterestingUser::LifetimeEndingUse) + if (liveness->isInterestingUser(instruction) != + PrunedLiveness::IsInterestingUser::LifetimeEndingUse) continue; worklist.push(instruction->getParent()); } @@ -797,7 +796,7 @@ void CanonicalizeOSSALifetime::visitExtendedUnconsumedBoundary( } } -void CanonicalizeOSSALifetime::extendUnconsumedLiveness( +void OSSACanonicalizeOwned::extendUnconsumedLiveness( PrunedLivenessBoundary const &boundary) { visitExtendedUnconsumedBoundary( boundary.lastUsers, [&](auto *instruction, auto lifetimeEnding) { @@ -862,7 +861,7 @@ class ExtendBoundaryToDestroys final { DestroyValueInst *retval = nullptr; for (auto *instruction = previous->getNextInstruction(); instruction; instruction = instruction->getNextInstruction()) { - if (!CanonicalizeOSSALifetime::ignoredByDestroyHoisting( + if (!OSSACanonicalizeOwned::ignoredByDestroyHoisting( instruction->getKind())) break; if (isDestroy(instruction)) @@ -1033,7 +1032,7 @@ class ExtendBoundaryToDestroys final { }; } // anonymous namespace -void CanonicalizeOSSALifetime::findExtendedBoundary( +void OSSACanonicalizeOwned::findExtendedBoundary( PrunedLivenessBoundary const &originalBoundary, PrunedLivenessBoundary &boundary) { assert(boundary.lastUsers.size() == 0 && boundary.boundaryEdges.size() == 0 && @@ -1056,7 +1055,7 @@ insertDestroyBeforeInstruction(SILInstruction *nextInstruction, CanonicalOSSAConsumeInfo &consumes, SmallVectorImpl &destroys, InstModCallbacks &callbacks) { - // OSSALifetimeCompletion: This conditional clause can be deleted with + // OSSACompleteLifetime: This conditional clause can be deleted with // complete lifetimes. if (consumes.isUnreachableLifetimeEnd(nextInstruction)) { // Don't create a destroy_value if the next instruction is an unreachable @@ -1148,7 +1147,7 @@ isDeadEndDestroy(SILInstruction *inst, /// consuming uses, including destroys on all return paths. /// - The postdominating consumes cannot be within nested loops. /// - Any blocks in nested loops are now marked LiveOut. -void CanonicalizeOSSALifetime::insertDestroysOnBoundary( +void OSSACanonicalizeOwned::insertDestroysOnBoundary( PrunedLivenessBoundary const &boundary, SmallVectorImpl &newDestroys) { BasicBlockSet semanticDestroyBlocks(getCurrentDef()->getFunction()); @@ -1253,7 +1252,7 @@ void swift::copyLiveUse(Operand *use, InstModCallbacks &instModCallbacks) { /// Revisit the def-use chain of currentDef. Mark unneeded original /// copies and destroys for deletion. Insert new copies for interior uses that /// require ownership of the used operand. -void CanonicalizeOSSALifetime::rewriteCopies( +void OSSACanonicalizeOwned::rewriteCopies( SmallVectorImpl const &newDestroys) { assert(getCurrentDef()->getOwnershipKind() == OwnershipKind::Owned); @@ -1378,7 +1377,7 @@ void CanonicalizeOSSALifetime::rewriteCopies( // MARK: Top-Level API //===----------------------------------------------------------------------===// -bool CanonicalizeOSSALifetime::computeLiveness() { +bool OSSACanonicalizeOwned::computeLiveness() { LLVM_DEBUG(llvm::dbgs() << " Canonicalizing: " << currentDef); if (currentDef->getOwnershipKind() != OwnershipKind::Owned) { @@ -1397,8 +1396,8 @@ bool CanonicalizeOSSALifetime::computeLiveness() { // NotifyWillBeDeleted will not work because copy rewriting removes operands // before deleting instructions. Also prohibit setUse callbacks just because // that would simply be unsound. - assert(!getCallbacks().notifyWillBeDeletedFunc - && !getCallbacks().setUseValueFunc && "unsupported"); + assert(!getCallbacks().notifyWillBeDeletedFunc && + !getCallbacks().setUseValueFunc && "unsupported"); // Step 1: compute liveness if (!computeCanonicalLiveness()) { @@ -1421,7 +1420,7 @@ bool CanonicalizeOSSALifetime::computeLiveness() { return true; } -void CanonicalizeOSSALifetime::rewriteLifetimes() { +void OSSACanonicalizeOwned::rewriteLifetimes() { // Step 2: compute original boundary PrunedLivenessBoundary originalBoundary; findOriginalBoundary(originalBoundary); @@ -1451,7 +1450,7 @@ void CanonicalizeOSSALifetime::rewriteLifetimes() { } /// Canonicalize a single extended owned lifetime. -bool CanonicalizeOSSALifetime::canonicalizeValueLifetime( +bool OSSACanonicalizeOwned::canonicalizeValueLifetime( SILValue def, ArrayRef lexicalLifetimeEnds) { LivenessState livenessState(*this, def, lexicalLifetimeEnds); @@ -1484,8 +1483,8 @@ namespace swift::test { // - [SILInstruction]: the lexicalLifetimeEnds to recognize // Dumps: // - function after value canonicalization -static FunctionTest CanonicalizeOSSALifetimeTest( - "canonicalize_ossa_lifetime", +static FunctionTest OSSACanonicalizeOwnedTest( + "ossa_canonicalize_lifetime", [](auto &function, auto &arguments, auto &test) { auto *accessBlockAnalysis = test.template getAnalysis(); @@ -1498,7 +1497,7 @@ static FunctionTest CanonicalizeOSSALifetimeTest( auto maximizeLifetimes = MaximizeLifetime_t(arguments.takeBool()); auto respectAccessScopes = arguments.takeBool(); InstructionDeleter deleter; - CanonicalizeOSSALifetime canonicalizer( + OSSACanonicalizeOwned canonicalizer( pruneDebug, maximizeLifetimes, &function, respectAccessScopes ? accessBlockAnalysis : nullptr, deadEndBlocksAnalysis, domTree, calleeAnalysis, deleter); @@ -1516,10 +1515,9 @@ static FunctionTest CanonicalizeOSSALifetimeTest( // MARK: Debugging //===----------------------------------------------------------------------===// -SWIFT_ASSERT_ONLY_DECL( - void CanonicalOSSAConsumeInfo::dump() const { - llvm::dbgs() << "Consumes:"; - for (auto &blockAndInst : finalBlockConsumes) { - llvm::dbgs() << " " << *blockAndInst.getSecond(); - } - }) +SWIFT_ASSERT_ONLY_DECL(void CanonicalOSSAConsumeInfo::dump() const { + llvm::dbgs() << "Consumes:"; + for (auto &blockAndInst : finalBlockConsumes) { + llvm::dbgs() << " " << *blockAndInst.getSecond(); + } +}) diff --git a/lib/SILOptimizer/Utils/OptimizerBridging.cpp b/lib/SILOptimizer/Utils/OptimizerBridging.cpp index fbadf6b46f9fb..a41d498448100 100644 --- a/lib/SILOptimizer/Utils/OptimizerBridging.cpp +++ b/lib/SILOptimizer/Utils/OptimizerBridging.cpp @@ -14,7 +14,7 @@ #include "../../IRGen/IRGenModule.h" #include "swift/AST/SemanticAttrs.h" #include "swift/SIL/DynamicCasts.h" -#include "swift/SIL/OSSALifetimeCompletion.h" +#include "swift/SIL/OSSACompleteLifetime.h" #include "swift/SIL/SILCloner.h" #include "swift/SIL/Test.h" #include "swift/SILOptimizer/Analysis/Analysis.h" @@ -423,8 +423,9 @@ bool BridgedPassContext::completeLifetime(BridgedValue value) const { SILFunction *f = v->getFunction(); DeadEndBlocks *deb = invocation->getPassManager()->getAnalysis()->get(f); DominanceInfo *domInfo = invocation->getPassManager()->getAnalysis()->get(f); - OSSALifetimeCompletion completion(f, domInfo, *deb); - auto result = completion.completeOSSALifetime(v, OSSALifetimeCompletion::Boundary::Availability); + OSSACompleteLifetime completion(f, domInfo, *deb); + auto result = completion.completeOSSALifetime( + v, OSSACompleteLifetime::Boundary::Availability); return result == LifetimeCompletion::WasCompleted; } diff --git a/lib/SILOptimizer/Utils/ShrinkBorrowScope.cpp b/lib/SILOptimizer/Utils/ShrinkBorrowScope.cpp index da5909e5dcdb2..d7a6782bb6b84 100644 --- a/lib/SILOptimizer/Utils/ShrinkBorrowScope.cpp +++ b/lib/SILOptimizer/Utils/ShrinkBorrowScope.cpp @@ -10,7 +10,7 @@ // //===----------------------------------------------------------------------===// /// Shrink borrow scopes by hoisting end_borrows up to deinit barriers. After -/// this is done, CanonicalizeOSSALifetime is free to hoist the destroys of the +/// this is done, OSSACanonicalizeOwned is free to hoist the destroys of the /// owned value up to the end_borrow. In this way, the lexical lifetime of /// guaranteed values is preserved. //===----------------------------------------------------------------------===// @@ -26,9 +26,9 @@ #include "swift/SILOptimizer/Analysis/Reachability.h" #include "swift/SILOptimizer/Analysis/VisitBarrierAccessScopes.h" #include "swift/SILOptimizer/PassManager/Transforms.h" -#include "swift/SILOptimizer/Utils/CanonicalizeBorrowScope.h" #include "swift/SILOptimizer/Utils/InstOptUtils.h" #include "swift/SILOptimizer/Utils/InstructionDeleter.h" +#include "swift/SILOptimizer/Utils/OSSACanonicalizeGuaranteed.h" #include "llvm/ADT/STLExtras.h" #define DEBUG_TYPE "copy-propagation" diff --git a/test/SILOptimizer/canonicalize_borrow_scope_unit.sil b/test/SILOptimizer/canonicalize_borrow_scope_unit.sil index a4dfb1d05acfd..6aaf85b8120bb 100644 --- a/test/SILOptimizer/canonicalize_borrow_scope_unit.sil +++ b/test/SILOptimizer/canonicalize_borrow_scope_unit.sil @@ -19,17 +19,17 @@ struct Unmanaged where Instance : AnyObject { unowned(unsafe) var _value: @sil_unmanaged Instance } -// CHECK-LABEL: begin {{.*}} on copy_and_move_argument: canonicalize_borrow_scope +// CHECK-LABEL: begin {{.*}} on copy_and_move_argument: ossa_canonicalize_guaranteed // CHECK-LABEL: sil [ossa] @copy_and_move_argument : {{.*}} { // CHECK: {{bb[0-9]+}}([[INSTANCE:%[^,]+]] : // CHECK: [[UNMANAGED:%[^,]+]] = ref_to_unmanaged [[INSTANCE]] // CHECK: [[RETVAL:%[^,]+]] = struct $Unmanaged ([[UNMANAGED]] : $@sil_unmanaged Instance) // CHECK: return [[RETVAL]] // CHECK-LABEL: } // end sil function 'copy_and_move_argument' -// CHECK-LABEL: end {{.*}} on copy_and_move_argument: canonicalize_borrow_scope +// CHECK-LABEL: end {{.*}} on copy_and_move_argument: ossa_canonicalize_guaranteed sil [ossa] @copy_and_move_argument : $@convention(thin) (@guaranteed Instance) -> Unmanaged { bb0(%instance : @guaranteed $Instance): - specify_test "canonicalize_borrow_scope @argument" + specify_test "ossa_canonicalize_guaranteed @argument" %copy_1 = copy_value %instance : $Instance %copy_2 = copy_value %copy_1 : $Instance %move = move_value %copy_2 : $Instance @@ -44,17 +44,17 @@ bb0(%instance : @guaranteed $Instance): return %retval : $Unmanaged } -// CHECK-LABEL: begin {{.*}} on copy_and_move_lexical_argument: canonicalize_borrow_scope +// CHECK-LABEL: begin {{.*}} on copy_and_move_lexical_argument: ossa_canonicalize_guaranteed // CHECK-LABEL: sil [ossa] @copy_and_move_lexical_argument : {{.*}} { // CHECK: {{bb[0-9]+}}([[INSTANCE:%[^,]+]] : // CHECK: [[UNMANAGED:%[^,]+]] = ref_to_unmanaged [[INSTANCE]] // CHECK: [[RETVAL:%[^,]+]] = struct $Unmanaged ([[UNMANAGED]] : $@sil_unmanaged Instance) // CHECK: return [[RETVAL]] // CHECK-LABEL: } // end sil function 'copy_and_move_lexical_argument' -// CHECK-LABEL: end {{.*}} on copy_and_move_lexical_argument: canonicalize_borrow_scope +// CHECK-LABEL: end {{.*}} on copy_and_move_lexical_argument: ossa_canonicalize_guaranteed sil [ossa] @copy_and_move_lexical_argument : $@convention(thin) (@guaranteed Instance) -> Unmanaged { bb0(%instance : @guaranteed $Instance): - specify_test "canonicalize_borrow_scope @argument" + specify_test "ossa_canonicalize_guaranteed @argument" %copy_1 = copy_value %instance : $Instance %copy_2 = copy_value %copy_1 : $Instance %move = move_value [lexical] %copy_2 : $Instance @@ -69,7 +69,7 @@ bb0(%instance : @guaranteed $Instance): return %retval : $Unmanaged } -// CHECK-LABEL: begin running test {{.*}} on dont_rewrite_inner_forwarding_user: canonicalize_borrow_scope +// CHECK-LABEL: begin running test {{.*}} on dont_rewrite_inner_forwarding_user: ossa_canonicalize_guaranteed // CHECK-LABEL: sil [ossa] @dont_rewrite_inner_forwarding_user : {{.*}} { // CHECK: [[GET_C:%[^,]+]] = function_ref @getD // CHECK: [[TAKE_C:%[^,]+]] = function_ref @takeC @@ -84,12 +84,12 @@ bb0(%instance : @guaranteed $Instance): // CHECK: destroy_value [[C]] // CHECK: return [[OUTER_UPCAST]] // CHECK-LABEL: } // end sil function 'dont_rewrite_inner_forwarding_user' -// CHECK-LABEL: end running test {{.*}} on dont_rewrite_inner_forwarding_user: canonicalize_borrow_scope +// CHECK-LABEL: end running test {{.*}} on dont_rewrite_inner_forwarding_user: ossa_canonicalize_guaranteed sil [ossa] @dont_rewrite_inner_forwarding_user : $@convention(thin) () -> (@owned C) { %getD = function_ref @getD : $@convention(thin) () -> (@owned D) %takeC = function_ref @takeC : $@convention(thin) (@owned C) -> () %d = apply %getD() : $@convention(thin) () -> (@owned D) - specify_test "canonicalize_borrow_scope @instruction" + specify_test "ossa_canonicalize_guaranteed @instruction" %b = begin_borrow %d : $D %c2 = copy_value %b : $D %u2 = upcast %c2 : $D to $C @@ -101,7 +101,7 @@ sil [ossa] @dont_rewrite_inner_forwarding_user : $@convention(thin) () -> (@owne return %u2 : $C } -// CHECK-LABEL: begin running test {{.*}} on dont_hoist_inner_destructure: canonicalize_borrow_scope +// CHECK-LABEL: begin running test {{.*}} on dont_hoist_inner_destructure: ossa_canonicalize_guaranteed // CHECK-LABEL: sil [ossa] @dont_hoist_inner_destructure : {{.*}} { // CHECK: {{bb[0-9]+}}([[S:%[^,]+]] : // CHECK: [[OUTER_COPY:%[^,]+]] = copy_value [[S]] @@ -123,10 +123,10 @@ sil [ossa] @dont_rewrite_inner_forwarding_user : $@convention(thin) () -> (@owne // CHECK: br [[EXIT]] // CHECK: [[EXIT]]: // CHECK-LABEL: } // end sil function 'dont_hoist_inner_destructure' -// CHECK-LABEL: end running test {{.*}} on dont_hoist_inner_destructure: canonicalize_borrow_scope +// CHECK-LABEL: end running test {{.*}} on dont_hoist_inner_destructure: ossa_canonicalize_guaranteed sil [ossa] @dont_hoist_inner_destructure : $@convention(thin) (@owned S) -> () { entry(%s : @owned $S): - specify_test "canonicalize_borrow_scope @instruction" + specify_test "ossa_canonicalize_guaranteed @instruction" %s_borrow = begin_borrow %s : $S %s_copy = copy_value %s_borrow : $S cond_br undef, left, right diff --git a/test/SILOptimizer/canonicalize_ossa_lifetime_unit.sil b/test/SILOptimizer/canonicalize_ossa_lifetime_unit.sil index 9d61203ca1bbd..21cf083411929 100644 --- a/test/SILOptimizer/canonicalize_ossa_lifetime_unit.sil +++ b/test/SILOptimizer/canonicalize_ossa_lifetime_unit.sil @@ -27,11 +27,11 @@ struct S {} struct MoS: ~Copyable {} struct MoE: ~Copyable {} -// CHECK-LABEL: begin running test 1 of 1 on fn: canonicalize_ossa_lifetime with: true, true, true, @trace -// CHECK-LABEL: end running test 1 of 1 on fn: canonicalize_ossa_lifetime with: true, true, true, @trace +// CHECK-LABEL: begin running test 1 of 1 on fn: ossa_canonicalize_lifetime with: true, true, true, @trace +// CHECK-LABEL: end running test 1 of 1 on fn: ossa_canonicalize_lifetime with: true, true, true, @trace sil [ossa] @fn : $@convention(thin) () -> () { entry: - specify_test "canonicalize_ossa_lifetime true true true @trace" + specify_test "ossa_canonicalize_lifetime true true true @trace" %getC = function_ref @getC : $@convention(thin) () -> @owned C %c = apply %getC() : $@convention(thin) () -> @owned C debug_value [trace] %c : $C @@ -45,7 +45,7 @@ entry: // When access scopes are respected, the lifetime which previously extended // beyond the access scope still extends beyond it. -// CHECK-LABEL: begin running test 1 of 2 on retract_value_lifetime_into_access_scope_when_access_scopes_not_respected: canonicalize_ossa_lifetime with: true, false, true, @trace +// CHECK-LABEL: begin running test 1 of 2 on retract_value_lifetime_into_access_scope_when_access_scopes_not_respected: ossa_canonicalize_lifetime with: true, false, true, @trace // CHECK-LABEL: sil [ossa] @retract_value_lifetime_into_access_scope_when_access_scopes_not_respected {{.*}} { // CHECK: {{bb[0-9]+}}([[ADDR:%[^,]+]] : // CHECK: [[INSTANCE:%[^,]+]] = apply @@ -55,11 +55,11 @@ entry: // CHECK: end_access [[ACCESS]] // CHECK: destroy_value [[INSTANCE]] // CHECK-LABEL: } // end sil function 'retract_value_lifetime_into_access_scope_when_access_scopes_not_respected' -// CHECK-LABEL: end running test 1 of 2 on retract_value_lifetime_into_access_scope_when_access_scopes_not_respected: canonicalize_ossa_lifetime with: true, false, true, @trace +// CHECK-LABEL: end running test 1 of 2 on retract_value_lifetime_into_access_scope_when_access_scopes_not_respected: ossa_canonicalize_lifetime with: true, false, true, @trace // When access scopes are not respected, the lifetime which previously extended // beyond the access scope is retracted into the scope. -// CHECK-LABEL: begin running test 2 of 2 on retract_value_lifetime_into_access_scope_when_access_scopes_not_respected: canonicalize_ossa_lifetime with: true, false, false, @trace +// CHECK-LABEL: begin running test 2 of 2 on retract_value_lifetime_into_access_scope_when_access_scopes_not_respected: ossa_canonicalize_lifetime with: true, false, false, @trace // CHECK-LABEL: sil [ossa] @retract_value_lifetime_into_access_scope_when_access_scopes_not_respected {{.*}} { // CHECK: {{bb[0-9]+}}([[ADDR:%[^,]+]] : // CHECK: [[INSTANCE:%[^,]+]] = apply @@ -67,15 +67,15 @@ entry: // CHECK: store [[INSTANCE]] to [init] [[ACCESS]] // CHECK: end_access [[ACCESS]] // CHECK-LABEL: } // end sil function 'retract_value_lifetime_into_access_scope_when_access_scopes_not_respected' -// CHECK-LABEL: end running test 2 of 2 on retract_value_lifetime_into_access_scope_when_access_scopes_not_respected: canonicalize_ossa_lifetime with: true, false, false, @trace +// CHECK-LABEL: end running test 2 of 2 on retract_value_lifetime_into_access_scope_when_access_scopes_not_respected: ossa_canonicalize_lifetime with: true, false, false, @trace sil [ossa] @retract_value_lifetime_into_access_scope_when_access_scopes_not_respected : $@convention(thin) () -> @out C { bb0(%addr : $*C): %instance = apply undef() : $@convention(thin) () -> @owned C debug_value [trace] %instance : $C // respect access scopes // VVVV - specify_test "canonicalize_ossa_lifetime true false true @trace" - specify_test "canonicalize_ossa_lifetime true false false @trace" + specify_test "ossa_canonicalize_lifetime true false true @trace" + specify_test "ossa_canonicalize_lifetime true false false @trace" // ^^^^^ // respect access scopes %copy = copy_value %instance : $C @@ -88,17 +88,17 @@ bb0(%addr : $*C): } -// CHECK-LABEL: begin running test 1 of 1 on reuse_destroy_after_barrier_phi: canonicalize_ossa_lifetime with: true, false, true, @trace +// CHECK-LABEL: begin running test 1 of 1 on reuse_destroy_after_barrier_phi: ossa_canonicalize_lifetime with: true, false, true, @trace // CHECK-LABEL: sil [ossa] @reuse_destroy_after_barrier_phi : {{.*}} { // CHECK: {{bb[0-9]+}}([[INSTANCE:%[^,]+]] : // CHECK: {{bb[0-9]+}}({{%[^,]+}} // CHECK: destroy_value [[INSTANCE]] // CHECK-LABEL: } // end sil function 'reuse_destroy_after_barrier_phi' -// CHECK-LABEL: end running test 1 of 1 on reuse_destroy_after_barrier_phi: canonicalize_ossa_lifetime with: true, false, true, @trace +// CHECK-LABEL: end running test 1 of 1 on reuse_destroy_after_barrier_phi: ossa_canonicalize_lifetime with: true, false, true, @trace sil [ossa] @reuse_destroy_after_barrier_phi : $@convention(thin) (@owned C) -> @owned C { entry(%instance : @owned $C): debug_value [trace] %instance : $C - specify_test "canonicalize_ossa_lifetime true false true @trace" + specify_test "ossa_canonicalize_lifetime true false true @trace" %get = function_ref @getOwned : $@convention(thin) () -> @owned C cond_br undef, through, loop @@ -115,16 +115,16 @@ exit(%out : @owned $C): return %out : $C } -// CHECK-LABEL: begin running test 1 of 1 on store_arg_to_out_addr: canonicalize_ossa_lifetime with: true, false, true, @trace +// CHECK-LABEL: begin running test 1 of 1 on store_arg_to_out_addr: ossa_canonicalize_lifetime with: true, false, true, @trace // CHECK-LABEL: sil [ossa] @store_arg_to_out_addr : $@convention(thin) (@owned C) -> @out C { // CHECK: {{bb[0-9]+}}([[ADDR:%[^,]+]] : $*C, [[INSTANCE:%[^,]+]] : // CHECK: store [[INSTANCE]] to [init] [[ADDR]] // CHECK-LABEL: } // end sil function 'store_arg_to_out_addr' -// CHECK-LABEL: end running test 1 of 1 on store_arg_to_out_addr: canonicalize_ossa_lifetime with: true, false, true, @trace +// CHECK-LABEL: end running test 1 of 1 on store_arg_to_out_addr: ossa_canonicalize_lifetime with: true, false, true, @trace sil [ossa] @store_arg_to_out_addr : $@convention(thin) (@owned C) -> @out C { bb0(%0 : $*C, %instance : @owned $C): debug_value [trace] %instance : $C - specify_test "canonicalize_ossa_lifetime true false true @trace" + specify_test "ossa_canonicalize_lifetime true false true @trace" %copy = copy_value %instance : $C store %copy to [init] %0 : $*C destroy_value %instance : $C @@ -132,7 +132,7 @@ bb0(%0 : $*C, %instance : @owned $C): return %retval : $() } -// CHECK-LABEL: begin running test 1 of 1 on store_arg_to_out_addr_with_barrier: canonicalize_ossa_lifetime with: true, false, true, @trace +// CHECK-LABEL: begin running test 1 of 1 on store_arg_to_out_addr_with_barrier: ossa_canonicalize_lifetime with: true, false, true, @trace // CHECK-LABEL: sil [ossa] @store_arg_to_out_addr_with_barrier : $@convention(thin) (@owned C) -> @out C { // CHECK: {{bb[0-9]+}}([[ADDR:%[^,]+]] : $*C, [[INSTANCE:%[^,]+]] : // CHECK: [[BARRIER:%[^,]+]] = function_ref @barrier @@ -141,12 +141,12 @@ bb0(%0 : $*C, %instance : @owned $C): // CHECK: apply [[BARRIER]]() // CHECK: destroy_value [[INSTANCE]] // CHECK-LABEL: } // end sil function 'store_arg_to_out_addr_with_barrier' -// CHECK-LABEL: end running test 1 of 1 on store_arg_to_out_addr_with_barrier: canonicalize_ossa_lifetime with: true, false, true, @trace +// CHECK-LABEL: end running test 1 of 1 on store_arg_to_out_addr_with_barrier: ossa_canonicalize_lifetime with: true, false, true, @trace sil [ossa] @store_arg_to_out_addr_with_barrier : $@convention(thin) (@owned C) -> @out C { bb0(%0 : $*C, %instance : @owned $C): %barrier = function_ref @barrier : $@convention(thin) () -> () debug_value [trace] %instance : $C - specify_test "canonicalize_ossa_lifetime true false true @trace" + specify_test "ossa_canonicalize_lifetime true false true @trace" %copy = copy_value %instance : $C store %copy to [init] %0 : $*C apply %barrier() : $@convention(thin) () -> () @@ -167,7 +167,7 @@ right2(%c2p : @owned $C): exit(%phi : @owned $C, %typhi : $S): debug_value [trace] %phi : $C - specify_test "canonicalize_ossa_lifetime true false true @trace" + specify_test "ossa_canonicalize_lifetime true false true @trace" destroy_value %phi : $C %retval = tuple () return %retval : $() @@ -182,16 +182,16 @@ bb0: // Even though the apply of %empty is not a deinit barrier, verify that the // destroy is not hoisted, because MoS is move-only. -// CHECK-LABEL: begin running test {{.*}} on dont_move_destroy_value_of_moveonly_struct: canonicalize_ossa_lifetime with: true, false, true, @argument +// CHECK-LABEL: begin running test {{.*}} on dont_move_destroy_value_of_moveonly_struct: ossa_canonicalize_lifetime with: true, false, true, @argument // CHECK-LABEL: sil [ossa] @dont_move_destroy_value_of_moveonly_struct : {{.*}} { // CHECK: {{bb[0-9]+}}([[INSTANCE:%[^,]+]] : // CHECK: apply // CHECK: destroy_value [[INSTANCE]] // CHECK-LABEL: } // end sil function 'dont_move_destroy_value_of_moveonly_struct' -// CHECK-LABEL: end running test {{.*}} on dont_move_destroy_value_of_moveonly_struct: canonicalize_ossa_lifetime with: true, false, true, @argument +// CHECK-LABEL: end running test {{.*}} on dont_move_destroy_value_of_moveonly_struct: ossa_canonicalize_lifetime with: true, false, true, @argument sil [ossa] @dont_move_destroy_value_of_moveonly_struct : $@convention(thin) (@owned MoS) -> () { entry(%instance : @owned $MoS): - specify_test "canonicalize_ossa_lifetime true false true @argument" + specify_test "ossa_canonicalize_lifetime true false true @argument" %empty = function_ref @empty : $@convention(thin) () -> () apply %empty() : $@convention(thin) () -> () destroy_value %instance : $MoS @@ -199,16 +199,16 @@ entry(%instance : @owned $MoS): return %retval : $() } -// CHECK-LABEL: begin running test {{.*}} on dont_move_destroy_value_of_moveonly_enum: canonicalize_ossa_lifetime with: true, false, true, @argument +// CHECK-LABEL: begin running test {{.*}} on dont_move_destroy_value_of_moveonly_enum: ossa_canonicalize_lifetime with: true, false, true, @argument // CHECK-LABEL: sil [ossa] @dont_move_destroy_value_of_moveonly_enum : {{.*}} { // CHECK: {{bb[0-9]+}}([[INSTANCE:%[^,]+]] : // CHECK: apply // CHECK: destroy_value [[INSTANCE]] // CHECK-LABEL: } // end sil function 'dont_move_destroy_value_of_moveonly_enum' -// CHECK-LABEL: end running test {{.*}} on dont_move_destroy_value_of_moveonly_enum: canonicalize_ossa_lifetime with: true, false, true, @argument +// CHECK-LABEL: end running test {{.*}} on dont_move_destroy_value_of_moveonly_enum: ossa_canonicalize_lifetime with: true, false, true, @argument sil [ossa] @dont_move_destroy_value_of_moveonly_enum : $@convention(thin) (@owned MoE) -> () { entry(%instance : @owned $MoE): - specify_test "canonicalize_ossa_lifetime true false true @argument" + specify_test "ossa_canonicalize_lifetime true false true @argument" %empty = function_ref @empty : $@convention(thin) () -> () apply %empty() : $@convention(thin) () -> () destroy_value %instance : $MoE @@ -230,7 +230,7 @@ entry(%instance : @owned $MoE): // CHECK-LABEL: end running test 1 of 1 on respect_boundary_edges_when_extending_to_deinit_barriers sil [ossa] @respect_boundary_edges_when_extending_to_deinit_barriers : $@convention(thin) (@owned C) -> () { entry(%instance : @owned $C): - specify_test "canonicalize_ossa_lifetime true false true @argument" + specify_test "ossa_canonicalize_lifetime true false true @argument" %barrier = function_ref @barrier : $@convention(thin) () -> () apply %barrier() : $@convention(thin) () -> () cond_br undef, die, destroy @@ -258,7 +258,7 @@ destroy: // CHECK-LABEL: end running test {{.*}} on respect_boundary_edges_when_extending_to_deinit_barriers_2 sil [ossa] @respect_boundary_edges_when_extending_to_deinit_barriers_2 : $@convention(thin) (@owned C) -> () { entry(%instance : @owned $C): - specify_test "canonicalize_ossa_lifetime true false true @argument" + specify_test "ossa_canonicalize_lifetime true false true @argument" %barrier = function_ref @barrier : $@convention(thin) () -> () apply %barrier() : $@convention(thin) () -> () cond_br undef, die, destroy @@ -291,7 +291,7 @@ destroy: // CHECK-LABEL: end running test {{.*}} on respect_boundary_edges_when_extending_to_deinit_barriers_3 sil [ossa] @respect_boundary_edges_when_extending_to_deinit_barriers_3 : $@convention(thin) (@owned C) -> () { entry(%instance : @owned $C): - specify_test "canonicalize_ossa_lifetime true false true @argument" + specify_test "ossa_canonicalize_lifetime true false true @argument" %barrier = function_ref @barrier : $@convention(thin) () -> () apply %barrier() : $@convention(thin) () -> () cond_br undef, die, destroy @@ -323,7 +323,7 @@ destroy: // CHECK-LABEL: end running test 1 of 1 on respect_preexisting_destroy_values_when_extending_to_deinit_barriers sil [ossa] @respect_preexisting_destroy_values_when_extending_to_deinit_barriers : $@convention(thin) (@owned C) -> () { entry(%instance : @owned $C): - specify_test "canonicalize_ossa_lifetime true false true @argument" + specify_test "ossa_canonicalize_lifetime true false true @argument" %barrier = function_ref @barrier : $@convention(thin) () -> () cond_br undef, die, destroy @@ -345,7 +345,7 @@ destroy: // CHECK-LABEL: end running test {{.*}} on preserve_dead_end_1 sil [ossa] @preserve_dead_end_1 : $@convention(thin) () -> () { entry: - specify_test "canonicalize_ossa_lifetime true false true %c" + specify_test "ossa_canonicalize_lifetime true false true %c" %get = function_ref @getOwned : $@convention(thin) () -> @owned C %barrier = function_ref @barrier : $@convention(thin) () -> () @@ -363,7 +363,7 @@ entry: // CHECK-LABEL: end running test {{.*}} on preserve_dead_end_2 sil [ossa] @preserve_dead_end_2 : $@convention(thin) () -> () { entry: - specify_test "canonicalize_ossa_lifetime true false true %c" + specify_test "ossa_canonicalize_lifetime true false true %c" %get = function_ref @getOwned : $@convention(thin) () -> @owned C %barrier = function_ref @barrier : $@convention(thin) () -> () @@ -386,7 +386,7 @@ entry: // CHECK-LABEL: end running test {{.*}} on preserve_dead_end_3 sil [ossa] @preserve_dead_end_3 : $@convention(thin) () -> () { entry: - specify_test "canonicalize_ossa_lifetime true false true %c" + specify_test "ossa_canonicalize_lifetime true false true %c" %get = function_ref @getOwned : $@convention(thin) () -> @owned C %barrier = function_ref @barrier : $@convention(thin) () -> () @@ -411,7 +411,7 @@ die: // CHECK-LABEL: end running test {{.*}} on preserve_dead_end_4 sil [ossa] @preserve_dead_end_4 : $@convention(thin) () -> () { entry: - specify_test "canonicalize_ossa_lifetime true false true %c" + specify_test "ossa_canonicalize_lifetime true false true %c" %get = function_ref @getOwned : $@convention(thin) () -> @owned C %barrier = function_ref @barrier : $@convention(thin) () -> () @@ -441,7 +441,7 @@ die: // CHECK-LABEL: end running test {{.*}} on preserve_dead_end_5 sil [ossa] @preserve_dead_end_5 : $@convention(thin) () -> () { entry: - specify_test "canonicalize_ossa_lifetime true false true %c" + specify_test "ossa_canonicalize_lifetime true false true %c" %get = function_ref @getOwned : $@convention(thin) () -> @owned C %barrier = function_ref @barrier : $@convention(thin) () -> () @@ -464,7 +464,7 @@ entry: // CHECK-LABEL: end running test {{.*}} on preserve_dead_end_6 sil [ossa] @preserve_dead_end_6 : $@convention(thin) () -> () { entry: - specify_test "canonicalize_ossa_lifetime true false true %c" + specify_test "ossa_canonicalize_lifetime true false true %c" %get = function_ref @getOwned : $@convention(thin) () -> @owned C %barrier = function_ref @barrier : $@convention(thin) () -> () @@ -493,7 +493,7 @@ die2: // CHECK-LABEL: end running test {{.*}} on preserve_dead_end_7 sil [ossa] @preserve_dead_end_7 : $@convention(thin) () -> () { entry: - specify_test "canonicalize_ossa_lifetime true false true %c" + specify_test "ossa_canonicalize_lifetime true false true %c" %get = function_ref @getOwned : $@convention(thin) () -> @owned C %barrier = function_ref @barrier : $@convention(thin) () -> () @@ -516,7 +516,7 @@ die2: } // (1) When no end is specified, the lifetime ends after the barrier. -// CHECK-LABEL: begin running test {{.*}} on lexical_end_at_end_1: canonicalize_ossa_lifetime +// CHECK-LABEL: begin running test {{.*}} on lexical_end_at_end_1: ossa_canonicalize_lifetime // CHECK-LABEL: sil [ossa] @lexical_end_at_end_1 : {{.*}} { // CHECK: bb0([[C1:%[^,]+]] : // CHECK: [[TAKE_C:%[^,]+]] = function_ref @takeC @@ -527,9 +527,9 @@ die2: // CHECK: apply [[BARRIER]]() // CHECK: destroy_value [[C1]] // CHECK-LABEL: } // end sil function 'lexical_end_at_end_1' -// CHECK-LABEL: end running test {{.*}} on lexical_end_at_end_1: canonicalize_ossa_lifetime +// CHECK-LABEL: end running test {{.*}} on lexical_end_at_end_1: ossa_canonicalize_lifetime // (2) When the move_value is specified as a lexical-lifetime-end, the lifetime doesn't extend to the destroy. -// CHECK-LABEL: begin running test {{.*}} on lexical_end_at_end_1: canonicalize_ossa_lifetime +// CHECK-LABEL: begin running test {{.*}} on lexical_end_at_end_1: ossa_canonicalize_lifetime // CHECK-LABEL: sil [ossa] @lexical_end_at_end_1 : {{.*}} { // CHECK: bb0([[C1:%[^,]+]] : // CHECK: [[TAKE_C:%[^,]+]] = function_ref @takeC @@ -538,11 +538,11 @@ die2: // CHECK: apply [[TAKE_C]]([[M]]) // CHECK: apply [[BARRIER]]() // CHECK-LABEL: } // end sil function 'lexical_end_at_end_1' -// CHECK-LABEL: end running test {{.*}} on lexical_end_at_end_1: canonicalize_ossa_lifetime +// CHECK-LABEL: end running test {{.*}} on lexical_end_at_end_1: ossa_canonicalize_lifetime sil [ossa] @lexical_end_at_end_1 : $@convention(thin) (@owned C) -> () { entry(%c1 : @owned $C): - specify_test "canonicalize_ossa_lifetime true false true @argument" - specify_test "canonicalize_ossa_lifetime true false true @argument %m" + specify_test "ossa_canonicalize_lifetime true false true @argument" + specify_test "ossa_canonicalize_lifetime true false true @argument %m" %takeC = function_ref @takeC : $@convention(thin) (@owned C) -> () %barrier = function_ref @barrier : $@convention(thin) () -> () %c2 = copy_value %c1 : $C @@ -555,7 +555,7 @@ entry(%c1 : @owned $C): } // (1) When no end is specified, the lifetime ends after the barrier. -// CHECK-LABEL: begin running test {{.*}} on lexical_end_at_end_2: canonicalize_ossa_lifetime +// CHECK-LABEL: begin running test {{.*}} on lexical_end_at_end_2: ossa_canonicalize_lifetime // CHECK-LABEL: sil [ossa] @lexical_end_at_end_2 : {{.*}} { // CHECK: bb0([[C1:%[^,]+]] : // CHECK: [[TAKE_C:%[^,]+]] = function_ref @takeC @@ -573,11 +573,11 @@ entry(%c1 : @owned $C): // CHECK: apply [[BARRIER]]() // CHECK: destroy_value [[C1]] // CHECK-LABEL: } // end sil function 'lexical_end_at_end_2' -// CHECK-LABEL: end running test {{.*}} on lexical_end_at_end_2: canonicalize_ossa_lifetime +// CHECK-LABEL: end running test {{.*}} on lexical_end_at_end_2: ossa_canonicalize_lifetime // (2) When the move_value is specified as a lexical-lifetime-end, the lifetime // doesn't extend to the destroy. But it DOES extend beyond barriers in // blocks where unaffected by the move_value. -// CHECK-LABEL: begin running test {{.*}} on lexical_end_at_end_2: canonicalize_ossa_lifetime +// CHECK-LABEL: begin running test {{.*}} on lexical_end_at_end_2: ossa_canonicalize_lifetime // CHECK-LABEL: sil [ossa] @lexical_end_at_end_2 : {{.*}} { // CHECK: bb0([[C1:%[^,]+]] : @owned $C): // CHECK: [[TAKE_C:%[^,]+]] = function_ref @takeC @@ -594,11 +594,11 @@ entry(%c1 : @owned $C): // CHECK: [[EXIT]]: // CHECK: apply [[BARRIER]]() // CHECK-LABEL: } // end sil function 'lexical_end_at_end_2' -// CHECK-LABEL: end running test {{.*}} on lexical_end_at_end_2: canonicalize_ossa_lifetime +// CHECK-LABEL: end running test {{.*}} on lexical_end_at_end_2: ossa_canonicalize_lifetime sil [ossa] @lexical_end_at_end_2 : $@convention(thin) (@owned C) -> () { entry(%c1 : @owned $C): - specify_test "canonicalize_ossa_lifetime true false true @argument" - specify_test "canonicalize_ossa_lifetime true false true @argument %m" + specify_test "ossa_canonicalize_lifetime true false true @argument" + specify_test "ossa_canonicalize_lifetime true false true @argument %m" %takeC = function_ref @takeC : $@convention(thin) (@owned C) -> () %barrier = function_ref @barrier : $@convention(thin) () -> () cond_br undef, left, right @@ -618,7 +618,7 @@ exit: } // Check barriers on branching unconsumed paths are respected. -// CHECK-LABEL: begin running test {{.*}} on lexical_end_at_end_3: canonicalize_ossa_lifetime +// CHECK-LABEL: begin running test {{.*}} on lexical_end_at_end_3: ossa_canonicalize_lifetime // CHECK-LABEL: sil [ossa] @lexical_end_at_end_3 : {{.*}} { // CHECK: bb0([[C1:%[^,]+]] : // CHECK: [[TAKE_C:%[^,]+]] = function_ref @takeC @@ -645,8 +645,8 @@ exit: // CHECK: apply [[BARRIER]]() // CHECK: destroy_value [[C1]] // CHECK-LABEL: } // end sil function 'lexical_end_at_end_3' -// CHECK-LABEL: end running test {{.*}} on lexical_end_at_end_3: canonicalize_ossa_lifetime -// CHECK-LABEL: begin running test {{.*}} on lexical_end_at_end_3: canonicalize_ossa_lifetime +// CHECK-LABEL: end running test {{.*}} on lexical_end_at_end_3: ossa_canonicalize_lifetime +// CHECK-LABEL: begin running test {{.*}} on lexical_end_at_end_3: ossa_canonicalize_lifetime // CHECK-LABEL: sil [ossa] @lexical_end_at_end_3 : {{.*}} { // CHECK: bb0([[C1:%[^,]+]] : // CHECK: [[TAKE_C:%[^,]+]] = function_ref @takeC @@ -672,11 +672,11 @@ exit: // CHECK: bb6: // CHECK: apply [[BARRIER]]() // CHECK-LABEL: } // end sil function 'lexical_end_at_end_3' -// CHECK-LABEL: end running test {{.*}} on lexical_end_at_end_3: canonicalize_ossa_lifetime +// CHECK-LABEL: end running test {{.*}} on lexical_end_at_end_3: ossa_canonicalize_lifetime sil [ossa] @lexical_end_at_end_3 : $@convention(thin) (@owned C) -> () { entry(%c1 : @owned $C): - specify_test "canonicalize_ossa_lifetime true false true @argument" - specify_test "canonicalize_ossa_lifetime true false true @argument %m" + specify_test "ossa_canonicalize_lifetime true false true @argument" + specify_test "ossa_canonicalize_lifetime true false true @argument %m" %takeC = function_ref @takeC : $@convention(thin) (@owned C) -> () %barrier = function_ref @barrier : $@convention(thin) () -> () cond_br undef, left, right_top @@ -704,7 +704,7 @@ exit: return %retval : $() } -// CHECK-LABEL: begin running test {{.*}} on lexical_end_at_end_4: canonicalize_ossa_lifetime +// CHECK-LABEL: begin running test {{.*}} on lexical_end_at_end_4: ossa_canonicalize_lifetime // CHECK-LABEL: sil [ossa] @lexical_end_at_end_4 : {{.*}} { // CHECK: bb0([[C1:%[^,]+]] : // CHECK: [[TAKE_C:%[^,]+]] = function_ref @takeC @@ -732,8 +732,8 @@ exit: // CHECK: apply [[BARRIER]]() // CHECK: destroy_value [[C1]] // CHECK-LABEL: } // end sil function 'lexical_end_at_end_4' -// CHECK-LABEL: end running test {{.*}} on lexical_end_at_end_4: canonicalize_ossa_lifetime -// CHECK-LABEL: begin running test {{.*}} on lexical_end_at_end_4: canonicalize_ossa_lifetime +// CHECK-LABEL: end running test {{.*}} on lexical_end_at_end_4: ossa_canonicalize_lifetime +// CHECK-LABEL: begin running test {{.*}} on lexical_end_at_end_4: ossa_canonicalize_lifetime // CHECK-LABEL: sil [ossa] @lexical_end_at_end_4 : {{.*}} { // CHECK: bb0([[C1:%[^,]+]] : // CHECK: [[TAKE_C:%[^,]+]] = function_ref @takeC : $@convention(thin) (@owned C) -> () @@ -759,11 +759,11 @@ exit: // CHECK: [[EXIT]]: // CHECK: apply [[BARRIER]]() // CHECK-LABEL: } // end sil function 'lexical_end_at_end_4' -// CHECK-LABEL: end running test {{.*}} on lexical_end_at_end_4: canonicalize_ossa_lifetime +// CHECK-LABEL: end running test {{.*}} on lexical_end_at_end_4: ossa_canonicalize_lifetime sil [ossa] @lexical_end_at_end_4 : $@convention(thin) (@owned C) -> () { entry(%c1 : @owned $C): - specify_test "canonicalize_ossa_lifetime true false true @argument" - specify_test "canonicalize_ossa_lifetime true false true @argument %m %m2" + specify_test "ossa_canonicalize_lifetime true false true @argument" + specify_test "ossa_canonicalize_lifetime true false true @argument %m %m2" %takeC = function_ref @takeC : $@convention(thin) (@owned C) -> () %barrier = function_ref @barrier : $@convention(thin) () -> () cond_br undef, left, right_top @@ -800,7 +800,7 @@ exit: sil [ossa] @dead_arg_debug_dead_end : $@convention(thin) (@owned C) -> () { entry(%c : @owned $C): debug_value %c : $C - specify_test "canonicalize_ossa_lifetime true false true %c" + specify_test "ossa_canonicalize_lifetime true false true %c" unreachable } @@ -817,7 +817,7 @@ bb0(%instance : @owned $C): br bb1(%instance : $C, %borrow : $C) bb1(%instance2 : @owned $C, %reborrowed : @reborrow $C): - specify_test "canonicalize_ossa_lifetime true false true %instance2" + specify_test "ossa_canonicalize_lifetime true false true %instance2" %reborrow = borrowed %reborrowed : $C from (%instance2 : $C) cond_br undef, bb2, bb3 @@ -847,7 +847,7 @@ bb0(%instance : @owned $C): br bb1(%instance : $C, %borrow : $C) bb1(%instance2 : @owned $C, %reborrowed : @reborrow $C): - specify_test "canonicalize_ossa_lifetime true false true %instance2" + specify_test "ossa_canonicalize_lifetime true false true %instance2" %reborrow = borrowed %reborrowed : $C from (%instance2 : $C) cond_br undef, bb2, bb3 @@ -889,7 +889,7 @@ exit: die: %move = move_value [lexical] %c %copy = copy_value %move - specify_test "canonicalize_ossa_lifetime true false true %move" + specify_test "ossa_canonicalize_lifetime true false true %move" apply undef(%move) : $@convention(thin) (@owned C) -> () %addr = alloc_stack $C %token = store_borrow %copy to %addr @@ -916,7 +916,7 @@ exit: die: %move = move_value %c %copy = copy_value %move - specify_test "canonicalize_ossa_lifetime true false true %move" + specify_test "ossa_canonicalize_lifetime true false true %move" apply undef(%move) : $@convention(thin) (@owned C) -> () %addr = alloc_stack $C %token = store_borrow %copy to %addr @@ -945,7 +945,7 @@ sil [ossa] @destroy_after_pa_copy_destroy : $@convention(thin) (@owned C) -> () entry(%a: @owned $C): // To defeat deinit barriers (apply undef). %c = move_value %a - specify_test "canonicalize_ossa_lifetime true false true %c" + specify_test "ossa_canonicalize_lifetime true false true %c" %callee = function_ref @borrowC : $@convention(thin) (@guaranteed C) -> () %pa = partial_apply [callee_guaranteed] [on_stack] %callee(%c) : $@convention(thin) (@guaranteed C) -> () @@ -967,7 +967,7 @@ entry(%a: @owned $C): // CHECK-LABEL: end running test {{.*}} on extend_lifetime_to_deadend_despite_copy_consume sil [ossa] @extend_lifetime_to_deadend_despite_copy_consume : $@convention(thin) (@owned C) -> () { entry(%c : @owned $C): - specify_test "canonicalize_ossa_lifetime true false true @argument" + specify_test "ossa_canonicalize_lifetime true false true @argument" %cc = copy_value %c %takeC = function_ref @takeC : $@convention(thin) (@owned C) -> () apply %takeC(%cc) : $@convention(thin) (@owned C) -> () @@ -989,7 +989,7 @@ entry: %getPointer = function_ref @getPointer : $@convention(thin) () -> (@owned Pointer) %c = apply %getC() : $@convention(thin) () -> (@owned C) %pointer = apply %getPointer() : $@convention(thin) () -> (@owned Pointer) - specify_test "canonicalize_ossa_lifetime true false true %c" + specify_test "ossa_canonicalize_lifetime true false true %c" %rawPointer = struct_extract %pointer, #Pointer.rawValue %o = pointer_to_address %rawPointer to [strict] $*Int32 %dependent = mark_dependence [nonescaping] %o on %c diff --git a/test/SILOptimizer/copy_propagation_borrow.sil b/test/SILOptimizer/copy_propagation_borrow.sil index 501cc1a7338d7..e8c4fca35810f 100644 --- a/test/SILOptimizer/copy_propagation_borrow.sil +++ b/test/SILOptimizer/copy_propagation_borrow.sil @@ -1041,7 +1041,7 @@ bb0(%0 : @guaranteed $C): } // TODO: Remove this copy inside a borrow scope by shrinking the scope . -// rdar://79149830 (Shrink borrow scopes in CanonicalizeBorrowScope) +// rdar://79149830 (Shrink borrow scopes in OSSACanonicalizeGuaranteed) // // Note: shrinking borrow scopes needs to happen even when most borrow // scopes are eliminated because some "defined" borrow scopes cannot be removed. @@ -1070,7 +1070,7 @@ bb0(%0 : @owned $HasObject): // Test a more complicated/realistic example of useless borrows // // TODO: Remove this copy inside a borrow scope by shrinking the scope . -// rdar://79149830 (Shrink borrow scopes in CanonicalizeBorrowScope) +// rdar://79149830 (Shrink borrow scopes in OSSACanonicalizeGuaranteed) // // It only has one trivial struct_extract. But copy propagation // currently only removes completely dead borrows. diff --git a/test/SILOptimizer/dead_code_elimination_nontrivial_ossa.sil b/test/SILOptimizer/dead_code_elimination_nontrivial_ossa.sil index e2d105fa66009..7089ac1fbb62e 100644 --- a/test/SILOptimizer/dead_code_elimination_nontrivial_ossa.sil +++ b/test/SILOptimizer/dead_code_elimination_nontrivial_ossa.sil @@ -514,7 +514,7 @@ bb1(%newborrow : @guaranteed $Klass, %borrow2 : @guaranteed $Klass): // Here %newborrowo and %newborrowi are both dead phis. // First end_borrow for the incoming value of %newborrowi is added // It is non straight forward to find the insert pt for the end_borrow of the incoming value of %newborrowo -// This may not be important once CanonicalizeOSSALifetime supports rewrite of multi-block borrows. +// This may not be important once OSSACanonicalizeOwned supports rewrite of multi-block borrows. sil [ossa] @dce_nestedborrowlifetime3 : $@convention(thin) (@guaranteed Klass) -> () { bb0(%0 : @guaranteed $Klass): %borrowo = begin_borrow %0 : $Klass diff --git a/test/SILOptimizer/ossa_lifetime_completion.sil b/test/SILOptimizer/ossa_lifetime_completion.sil index 6a641adf2c065..12ed252aeb776 100644 --- a/test/SILOptimizer/ossa_lifetime_completion.sil +++ b/test/SILOptimizer/ossa_lifetime_completion.sil @@ -32,15 +32,15 @@ typealias AnyObject = Builtin.AnyObject protocol P : AnyObject {} -// CHECK-LABEL: begin running test 1 of 1 on eagerConsumeOwnedArg: ossa_lifetime_completion with: @argument +// CHECK-LABEL: begin running test 1 of 1 on eagerConsumeOwnedArg: ossa_complete_lifetime with: @argument // CHECK-LABEL: OSSA lifetime completion on liveness boundary: %0 = argument of bb0 : $C // CHECK: sil [ossa] @eagerConsumeOwnedArg : $@convention(thin) (@owned C) -> () { // CHECK: bb0(%0 : @_eagerMove @owned $C): // CHECK-NEXT: destroy_value %0 : $C -// CHECK-LABEL: end running test 1 of 1 on eagerConsumeOwnedArg: ossa_lifetime_completion with: @argument +// CHECK-LABEL: end running test 1 of 1 on eagerConsumeOwnedArg: ossa_complete_lifetime with: @argument sil [ossa] @eagerConsumeOwnedArg : $@convention(thin) (@owned C) -> () { entry(%0 : @_eagerMove @owned $C): - specify_test "ossa_lifetime_completion @argument liveness" + specify_test "ossa_complete_lifetime @argument liveness" br exit exit: @@ -48,7 +48,7 @@ exit: return %retval : $() } -// CHECK-LABEL: begin running test 1 of 1 on lexicalOwnedArg: ossa_lifetime_completion with: @argument +// CHECK-LABEL: begin running test 1 of 1 on lexicalOwnedArg: ossa_complete_lifetime with: @argument // CHECK: OSSA lifetime completion on availability boundary: %0 = argument of bb0 : $C // user: %4 // CHECK: sil [ossa] @lexicalOwnedArg : $@convention(thin) (@owned C) -> () { // CHECK: bb0(%0 : @owned $C): @@ -57,10 +57,10 @@ exit: // CHECK-NEXT: destroy_value [dead_end] %0 : $C // CHECK-NEXT: unreachable // CHECK: } // end sil function 'lexicalOwnedArg' -// CHECK-LABEL: end running test 1 of 1 on lexicalOwnedArg: ossa_lifetime_completion with: @argument +// CHECK-LABEL: end running test 1 of 1 on lexicalOwnedArg: ossa_complete_lifetime with: @argument sil [ossa] @lexicalOwnedArg : $@convention(thin) (@owned C) -> () { bb0(%0 : @owned $C): - specify_test "ossa_lifetime_completion @argument availability" + specify_test "ossa_complete_lifetime @argument availability" cond_br undef, bb1, bb2 bb1: br bb3 @@ -79,7 +79,7 @@ bb3: // CHECK-LABEL: } // end sil function 'borrowTest' sil [ossa] @borrowTest : $@convention(method) (@owned C) -> () { bb0(%0 : @owned $C): - specify_test "ossa_lifetime_completion @instruction[0] availability" + specify_test "ossa_complete_lifetime @instruction[0] availability" %borrow = begin_borrow %0 : $C cond_br undef, bb1, bb2 @@ -104,7 +104,7 @@ bb3: // CHECK-LABEL: } // end sil function 'enumTest' sil [ossa] @enumTest : $@convention(method) (@guaranteed FakeOptional) -> () { bb0(%0 : @guaranteed $FakeOptional): - specify_test "ossa_lifetime_completion @instruction[0] liveness" + specify_test "ossa_complete_lifetime @instruction[0] liveness" %copy = copy_value %0 : $FakeOptional %borrow = begin_borrow %copy : $FakeOptional switch_enum %borrow : $FakeOptional, case #FakeOptional.some!enumelt: bb1, case #FakeOptional.none!enumelt: bb2 @@ -127,7 +127,7 @@ sil @use_guaranteed : $@convention(thin) (@guaranteed C) -> () sil [ossa] @argTest : $@convention(method) (@owned C) -> () { bb0(%0 : @owned $C): - specify_test "ossa_lifetime_completion @argument availability" + specify_test "ossa_complete_lifetime @argument availability" debug_value %0 : $C cond_br undef, bb1, bb2 @@ -151,7 +151,7 @@ bb4: // Ensure no assert fires while inserting dead end blocks to the worklist sil [ossa] @testLexicalLifetimeCompletion : $@convention(thin) (@owned C) -> () { bb0(%0 : @owned $C): - specify_test "ossa_lifetime_completion @argument availability" + specify_test "ossa_complete_lifetime @argument availability" debug_value %0 : $C, let, name "newElements", argno 1 cond_br undef, bb1, bb2 @@ -194,7 +194,7 @@ sil @foo : $@convention(thin) (@guaranteed C) -> () // Ensure no assert fires while handling lifetime end of partial_apply sil [ossa] @testPartialApplyStack1 : $@convention(thin) (@guaranteed C) -> () { bb0(%0 : @guaranteed $C): - specify_test "ossa_lifetime_completion @instruction[0] availability" + specify_test "ossa_complete_lifetime @instruction[0] availability" %8 = copy_value %0 : $C %9 = begin_borrow %8 : $C %80 = function_ref @foo : $@convention(thin) (@guaranteed C) -> () @@ -218,7 +218,7 @@ bb3: // Ensure no assert fires while handling lifetime end of partial_apply sil [ossa] @testPartialApplyStack2 : $@convention(thin) (@owned C) -> () { bb0(%0 : @owned $C): - specify_test "ossa_lifetime_completion @instruction[1] availability" + specify_test "ossa_complete_lifetime @instruction[1] availability" %2 = alloc_stack $C %3 = copy_value %0 : $C store %0 to [init] %2 @@ -260,7 +260,7 @@ sil [ossa] @availability_boundary_1 : $@convention(thin) () -> () { entry: %value = apply undef() : $@convention(thin) () -> @owned C %lexical = move_value [lexical] %value : $C // required (for lexicality) - specify_test "ossa_lifetime_completion %lexical availability" + specify_test "ossa_complete_lifetime %lexical availability" br condition_1 condition_1: @@ -317,7 +317,7 @@ sil [ossa] @availability_boundary_2_after_loop : $@convention(thin) () -> () { entry: %value = apply undef() : $@convention(thin) () -> @owned C %lexical = move_value [lexical] %value : $C // required (for lexicality) - specify_test "ossa_lifetime_completion %lexical availability" + specify_test "ossa_complete_lifetime %lexical availability" br condition_1 condition_1: @@ -382,7 +382,7 @@ sil [ossa] @availability_boundary_3_after_loop : $@convention(thin) () -> () { entry: %value = apply undef() : $@convention(thin) () -> @owned C %lexical = move_value [lexical] %value : $C // required (for lexicality) - specify_test "ossa_lifetime_completion %lexical availability" + specify_test "ossa_complete_lifetime %lexical availability" br condition_1 condition_1: @@ -432,7 +432,7 @@ sil [ossa] @project_box_deadend : $@convention(thin) (@owned C) -> () { bb0(%0 : @owned $C): %2 = alloc_box ${ var C } %3 = begin_borrow %2 : ${ var C } - specify_test "ossa_lifetime_completion %3 availability" + specify_test "ossa_complete_lifetime %3 availability" %4 = project_box %3 : ${ var C }, 0 store %0 to [init] %4 : $*C unreachable @@ -460,7 +460,7 @@ entry(%ie : @owned $IndirectEnumNontrivialPayload): switch_enum %ie : $IndirectEnumNontrivialPayload, case #IndirectEnumNontrivialPayload.c!enumelt: one_case one_case(%box : @owned ${ var C }): - specify_test "ossa_lifetime_completion %box availability" + specify_test "ossa_complete_lifetime %box availability" %c_addr = project_box %box : ${ var C }, 0 %c = load_borrow %c_addr : $*C cond_br undef, left, right @@ -490,7 +490,7 @@ bb0: %callee_pa = partial_apply [callee_guaranteed] undef() : $@convention(thin) @async @substituted <τ_0_0> () -> (@out τ_0_0, @error any Error) for <()> %callee_noescape = convert_escape_to_noescape [not_guaranteed] %callee_pa : $@async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error any Error) for <()> to $@noescape @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error any Error) for <()> - specify_test "ossa_lifetime_completion %callee_noescape availability" + specify_test "ossa_complete_lifetime %callee_noescape availability" %async_let = builtin "startAsyncLetWithLocalBuffer"<()>( %task_options : $Optional, %callee_noescape : $@noescape @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error any Error) for <()>, @@ -506,16 +506,16 @@ bb0: return %retval : $() } -// CHECK-LABEL: begin running test {{.*}} on alloc_box: ossa_lifetime_completion +// CHECK-LABEL: begin running test {{.*}} on alloc_box: ossa_complete_lifetime // CHECK-LABEL: sil [ossa] @alloc_box : {{.*}} { // CHECK: [[BOX:%[^,]+]] = alloc_box // CHECK: dealloc_box [dead_end] [[BOX]] // CHECK-LABEL: } // end sil function 'alloc_box' -// CHECK-LABEL: end running test {{.*}} on alloc_box: ossa_lifetime_completion +// CHECK-LABEL: end running test {{.*}} on alloc_box: ossa_complete_lifetime sil [ossa] @alloc_box : $@convention(thin) (@owned C) -> () { entry(%instance : @owned $C): %box = alloc_box ${ var C } - specify_test "ossa_lifetime_completion %box availability" + specify_test "ossa_complete_lifetime %box availability" %addr = project_box %box : ${ var C }, 0 store %instance to [init] %addr : $*C unreachable @@ -533,7 +533,7 @@ entry(%instance : @owned $C): sil [ossa] @begin_apply : $@convention(thin) () -> () { entry: (%_, %token) = begin_apply undef() : $@yield_once @convention(thin) () -> (@yields @in_guaranteed ()) - specify_test "ossa_lifetime_completion %token availability" + specify_test "ossa_complete_lifetime %token availability" cond_br undef, left, right left: @@ -548,7 +548,7 @@ right: // CHECK-LABEL: begin running test {{.*}} on loopy: liveness_partial_boundary_outside_users with: %o // CHECK: end_borrow // CHECK-LABEL: end running test {{.*}} on loopy: liveness_partial_boundary_outside_users with: %o -// CHECK-LABEL: begin running test {{.*}} on loopy: ossa_lifetime_completion +// CHECK-LABEL: begin running test {{.*}} on loopy: ossa_complete_lifetime // CHECK-LABEL: sil [ossa] @loopy : {{.*}} { // CHECK: [[O:%[^,]+]] = apply undef // CHECK: [[B:%[^,]+]] = begin_borrow [[O]] @@ -558,13 +558,13 @@ right: // CHECK: bb1: // CHECK: br bb1 // CHECK-LABEL: } // end sil function 'loopy' -// CHECK-LABEL: end running test {{.*}} on loopy: ossa_lifetime_completion +// CHECK-LABEL: end running test {{.*}} on loopy: ossa_complete_lifetime // CHECK-LABEL: begin running test {{.*}} on loopy: liveness_partial_boundary_outside_users with: %o // CHECK-NEXT: end running test {{.*}} on loopy: liveness_partial_boundary_outside_users with: %o sil [ossa] @loopy : $@convention(thin) () -> () { %o = apply undef() : $@convention(thin) () -> (@owned C) specify_test "liveness_partial_boundary_outside_users %o" - specify_test "ossa_lifetime_completion %o availability" + specify_test "ossa_complete_lifetime %o availability" specify_test "liveness_partial_boundary_outside_users %o" %b = begin_borrow %o : $C end_borrow %b : $C @@ -576,7 +576,7 @@ loop: sil [ossa] @loopyComplete : $@convention(thin) () -> () { %o = apply undef() : $@convention(thin) () -> (@owned C) - specify_test "ossa_lifetime_completion %o availability" + specify_test "ossa_complete_lifetime %o availability" specify_test "liveness_partial_boundary_outside_users %o" %b = begin_borrow %o : $C end_borrow %b : $C @@ -588,16 +588,16 @@ loop: } // When there are no users in the loop, do not extend the lifetime into it. -// CHECK-LABEL: begin running test {{.*}} on loopy_sometimes: ossa_lifetime_completion with: %c, availability +// CHECK-LABEL: begin running test {{.*}} on loopy_sometimes: ossa_complete_lifetime with: %c, availability // CHECK-LABEL: sil [ossa] @loopy_sometimes : {{.*}} { // CHECK-NOT: extend_lifetime // CHECK-LABEL: } // end sil function 'loopy_sometimes' -// CHECK-LABEL: end running test {{.*}} on loopy_sometimes: ossa_lifetime_completion with: %c, availability +// CHECK-LABEL: end running test {{.*}} on loopy_sometimes: ossa_complete_lifetime with: %c, availability // CHECK-LABEL: begin running test {{.*}} on loopy_sometimes: liveness_partial_boundary_outside_users with: %c // CHECK-NEXT: end running test {{.*}} on loopy_sometimes: liveness_partial_boundary_outside_users with: %c sil [ossa] @loopy_sometimes : $@convention(thin) (@owned C) -> () { entry(%c : @owned $C): - specify_test "ossa_lifetime_completion %c availability" + specify_test "ossa_complete_lifetime %c availability" specify_test "liveness_partial_boundary_outside_users %c" cond_br undef, header, exit @@ -614,17 +614,17 @@ exit: } // When there are no users in the loop, do not extend the lifetime into it. -// CHECK-LABEL: begin running test {{.*}} on loopy_sometimes_guaranteed: ossa_lifetime_completion with: %b, availability +// CHECK-LABEL: begin running test {{.*}} on loopy_sometimes_guaranteed: ossa_complete_lifetime with: %b, availability // CHECK-LABEL: sil [ossa] @loopy_sometimes_guaranteed : {{.*}} { // CHECK-NOT: extend_lifetime // CHECK-LABEL: } // end sil function 'loopy_sometimes_guaranteed' -// CHECK-LABEL: end running test {{.*}} on loopy_sometimes_guaranteed: ossa_lifetime_completion with: %b, availability +// CHECK-LABEL: end running test {{.*}} on loopy_sometimes_guaranteed: ossa_complete_lifetime with: %b, availability // CHECK-LABEL: begin running test {{.*}} on loopy_sometimes_guaranteed: liveness_partial_boundary_outside_users with: %b // CHECK-LABEL: end running test {{.*}} on loopy_sometimes_guaranteed: liveness_partial_boundary_outside_users with: %b sil [ossa] @loopy_sometimes_guaranteed : $@convention(thin) (@owned C) -> () { entry(%c : @owned $C): %b = begin_borrow %c : $C - specify_test "ossa_lifetime_completion %b availability" + specify_test "ossa_complete_lifetime %b availability" specify_test "liveness_partial_boundary_outside_users %b" cond_br undef, header, exit @@ -641,7 +641,7 @@ exit: return %retval : $() } -// CHECK-LABEL: begin running test {{.*}} on loopy_sometimes_2: ossa_lifetime_completion with: %c, availability +// CHECK-LABEL: begin running test {{.*}} on loopy_sometimes_2: ossa_complete_lifetime with: %c, availability // CHECK-LABEL: sil [ossa] @loopy_sometimes_2 : {{.*}} { // CHECK: bb0([[O:%[^,]+]] : // CHECK: cond_br undef, [[HEADER:bb[0-9]+]], [[EXIT:bb[0-9]+]] @@ -655,10 +655,10 @@ exit: // CHECK: [[EXIT]]: // CHECK: destroy_value [[O]] // CHECK-LABEL: } // end sil function 'loopy_sometimes_2' -// CHECK-LABEL: end running test {{.*}} on loopy_sometimes_2: ossa_lifetime_completion with: %c, availability +// CHECK-LABEL: end running test {{.*}} on loopy_sometimes_2: ossa_complete_lifetime with: %c, availability sil [ossa] @loopy_sometimes_2 : $@convention(thin) (@owned C) -> () { entry(%c : @owned $C): - specify_test "ossa_lifetime_completion %c availability" + specify_test "ossa_complete_lifetime %c availability" specify_test "liveness_partial_boundary_outside_users %c" cond_br undef, header, exit @@ -676,7 +676,7 @@ exit: return %retval : $() } -// CHECK-LABEL: begin running test {{.*}} on loopy_sometimes_2_guaranteed: ossa_lifetime_completion with: %c, availability +// CHECK-LABEL: begin running test {{.*}} on loopy_sometimes_2_guaranteed: ossa_complete_lifetime with: %c, availability // CHECK-LABEL: sil [ossa] @loopy_sometimes_2_guaranteed : {{.*}} { // CHECK: bb0([[C:%[^,]+]] : // CHECK: [[B:%[^,]+]] = begin_borrow [[C]] @@ -692,13 +692,13 @@ exit: // CHECK: end_borrow [[B]] // CHECK: destroy_value [[C]] // CHECK-LABEL: } // end sil function 'loopy_sometimes_2_guaranteed' -// CHECK-LABEL: end running test {{.*}} on loopy_sometimes_2_guaranteed: ossa_lifetime_completion with: %c, availability +// CHECK-LABEL: end running test {{.*}} on loopy_sometimes_2_guaranteed: ossa_complete_lifetime with: %c, availability // CHECK-LABEL: begin running test {{.*}} on loopy_sometimes_2_guaranteed: liveness_partial_boundary_outside_users with: %c // CHECK-NEXT: end running test {{.*}} on loopy_sometimes_2_guaranteed: liveness_partial_boundary_outside_users with: %c sil [ossa] @loopy_sometimes_2_guaranteed : $@convention(thin) (@owned C) -> () { entry(%c : @owned $C): %b = begin_borrow %c : $C - specify_test "ossa_lifetime_completion %c availability" + specify_test "ossa_complete_lifetime %c availability" specify_test "liveness_partial_boundary_outside_users %c" cond_br undef, header, exit @@ -728,7 +728,7 @@ bb0(%existential : @owned $any P): return %ref_existential : $AnyObject } -// CHECK-LABEL: begin running test {{.*}} on root_of_reborrow: ossa_lifetime_completion +// CHECK-LABEL: begin running test {{.*}} on root_of_reborrow: ossa_complete_lifetime // Verify that no instructions were inserted after backedge2's terminator. (In // fact, if they were, the test would crash.) // CHECK-LABEL: sil [ossa] @root_of_reborrow : {{.*}} { @@ -738,7 +738,7 @@ bb0(%existential : @owned $any P): // CHECK-NEXT: destroy_value [[C0]] // CHECK-NEXT: br // CHECK-LABEL: } // end sil function 'root_of_reborrow' -// CHECK-LABEL: end running test {{.*}} on root_of_reborrow: ossa_lifetime_completion +// CHECK-LABEL: end running test {{.*}} on root_of_reborrow: ossa_complete_lifetime sil [ossa] @root_of_reborrow : $@convention(thin) () -> () { entry: %getC = function_ref @getC : $@convention(thin) () -> (@owned C) @@ -760,14 +760,14 @@ backedge: br backedge2(%c1 : $C, %b1 : $C) backedge2(%c2 : @owned $C, %b2 : @reborrow $C): %b2f = borrowed %b2 : $C from (%c2 : $C) - specify_test "ossa_lifetime_completion %c2 availability" + specify_test "ossa_complete_lifetime %c2 availability" br header(%c2 : $C, %b2f : $C) exit: unreachable } -// CHECK-LABEL: begin running test {{.*}} on test_borrowed_from: ossa_lifetime_completion +// CHECK-LABEL: begin running test {{.*}} on test_borrowed_from: ossa_complete_lifetime // CHECK-LABEL: sil [ossa] @test_borrowed_from : {{.*}} { // CHECK: bb1([[A:%.*]] : @reborrow $C): // CHECK: [[BF:%.*]] = borrowed [[A]] : $C from (%0 : $C) @@ -775,7 +775,7 @@ exit: // CHECK-NEXT: end_borrow [[BF]] : $C // CHECK-NEXT: unreachable // CHECK-LABEL: } // end sil function 'test_borrowed_from' -// CHECK-LABEL: end running test {{.*}} on test_borrowed_from: ossa_lifetime_completion +// CHECK-LABEL: end running test {{.*}} on test_borrowed_from: ossa_complete_lifetime sil [ossa] @test_borrowed_from : $@convention(thin) (@owned C) -> @owned C { bb0(%0 : @owned $C): %1 = begin_borrow %0 : $C @@ -783,7 +783,7 @@ bb0(%0 : @owned $C): bb1(%3 : @reborrow $C): %4 = borrowed %3 : $C from (%0 : $C) - specify_test "ossa_lifetime_completion %3 availability" + specify_test "ossa_complete_lifetime %3 availability" cond_br undef, bb2, bb3 bb2: @@ -794,7 +794,7 @@ bb3: return %0 : $C } -// CHECK-LABEL: begin running test {{.*}} on store_borrow: ossa_lifetime_completion +// CHECK-LABEL: begin running test {{.*}} on store_borrow: ossa_complete_lifetime // CHECK-LABEL: sil [ossa] @store_borrow : {{.*}} { // CHECK: [[TOKEN:%[^,]+]] = store_borrow // CHECK: cond_br undef, {{bb[0-9]+}}, [[DIE:bb[0-9]+]] @@ -802,10 +802,10 @@ bb3: // CHECK-NEXT: end_borrow [[TOKEN]] // CHECK-NEXT: unreachable // CHECK-LABEL: } // end sil function 'store_borrow' -// CHECK-LABEL: end running test {{.*}} on store_borrow: ossa_lifetime_completion +// CHECK-LABEL: end running test {{.*}} on store_borrow: ossa_complete_lifetime sil [ossa] @store_borrow : $@convention(thin) (@guaranteed C) -> () { entry(%instance : @guaranteed $C): - specify_test "ossa_lifetime_completion %token availability" + specify_test "ossa_complete_lifetime %token availability" %addr = alloc_stack $C %token = store_borrow %instance to %addr : $*C cond_br undef, exit, die @@ -819,7 +819,7 @@ die: unreachable } -// CHECK-LABEL: begin running test {{.*}} on load_borrow_of_store_borrow_1: ossa_lifetime_completion +// CHECK-LABEL: begin running test {{.*}} on load_borrow_of_store_borrow_1: ossa_complete_lifetime // CHECK-LABEL: sil [ossa] @load_borrow_of_store_borrow_1 : {{.*}} { // CHECK: [[TOKEN:%[^,]+]] = store_borrow // CHECK: [[LOAD:%[^,]+]] = load_borrow [[TOKEN]] @@ -831,10 +831,10 @@ die: // CHECK-NEXT: end_borrow [[TOKEN]] // CHECK-NEXT: unreachable // CHECK-LABEL: } // end sil function 'load_borrow_of_store_borrow_1' -// CHECK-LABEL: end running test {{.*}} on load_borrow_of_store_borrow_1: ossa_lifetime_completion +// CHECK-LABEL: end running test {{.*}} on load_borrow_of_store_borrow_1: ossa_complete_lifetime sil [ossa] @load_borrow_of_store_borrow_1 : $@convention(thin) (@guaranteed C) -> () { entry(%instance : @guaranteed $C): - specify_test "ossa_lifetime_completion %token availability" + specify_test "ossa_complete_lifetime %token availability" %addr = alloc_stack $C %token = store_borrow %instance to %addr %load = load_borrow %token @@ -852,7 +852,7 @@ die: unreachable } -// CHECK-LABEL: begin running test {{.*}} on load_borrow_of_store_borrow_2: ossa_lifetime_completion +// CHECK-LABEL: begin running test {{.*}} on load_borrow_of_store_borrow_2: ossa_complete_lifetime // CHECK-LABEL: sil [ossa] @load_borrow_of_store_borrow_2 : {{.*}} { // CHECK: [[TOKEN:%[^,]+]] = store_borrow // CHECK: [[LOAD:%[^,]+]] = load_borrow [[TOKEN]] @@ -864,10 +864,10 @@ die: // CHECK-NEXT: end_borrow [[TOKEN]] // CHECK-NEXT: unreachable // CHECK-LABEL: } // end sil function 'load_borrow_of_store_borrow_2' -// CHECK-LABEL: end running test {{.*}} on load_borrow_of_store_borrow_2: ossa_lifetime_completion +// CHECK-LABEL: end running test {{.*}} on load_borrow_of_store_borrow_2: ossa_complete_lifetime sil [ossa] @load_borrow_of_store_borrow_2 : $@convention(thin) (@guaranteed C) -> () { entry(%instance : @guaranteed $C): - specify_test "ossa_lifetime_completion %token availability" + specify_test "ossa_complete_lifetime %token availability" %addr = alloc_stack $C %token = store_borrow %instance to %addr %load = load_borrow %token @@ -889,7 +889,7 @@ die: sil [ossa] @load_borrow_1 : $@convention(thin) (@in_guaranteed C) -> () { entry(%addr : $*C): - specify_test "ossa_lifetime_completion %load availability" + specify_test "ossa_complete_lifetime %load availability" %load = load_borrow %addr %borrow = begin_borrow %load cond_br undef, exit, die @@ -903,7 +903,7 @@ die: unreachable } -// CHECK-LABEL: begin running test {{.*}} on begin_access: ossa_lifetime_completion +// CHECK-LABEL: begin running test {{.*}} on begin_access: ossa_complete_lifetime // CHECK-LABEL: sil [ossa] @begin_access : {{.*}} { // CHECK: [[TOKEN:%[^,]+]] = begin_access // CHECK: cond_br undef, {{bb[0-9]+}}, [[DIE:bb[0-9]+]] @@ -911,10 +911,10 @@ die: // CHECK-NEXT: end_access [[TOKEN]] // CHECK-NEXT: unreachable // CHECK-LABEL: } // end sil function 'begin_access' -// CHECK-LABEL: end running test {{.*}} on begin_access: ossa_lifetime_completion +// CHECK-LABEL: end running test {{.*}} on begin_access: ossa_complete_lifetime sil [ossa] @begin_access : $@convention(thin) (@guaranteed C) -> () { entry(%instance : @guaranteed $C): - specify_test "ossa_lifetime_completion %access availability" + specify_test "ossa_complete_lifetime %access availability" %addr = alloc_stack $C %access = begin_access [static] [read] %addr : $*C cond_br undef, exit, die @@ -928,7 +928,7 @@ die: unreachable } -// CHECK-LABEL: begin running test {{.*}} on load_borrow_of_begin_access: ossa_lifetime_completion +// CHECK-LABEL: begin running test {{.*}} on load_borrow_of_begin_access: ossa_complete_lifetime // CHECK-LABEL: sil [ossa] @load_borrow_of_begin_access : {{.*}} { // CHECK: [[ACCESS:%[^,]+]] = begin_access // CHECK: [[LOAD:%[^,]+]] = load_borrow [[ACCESS]] @@ -940,10 +940,10 @@ die: // CHECK-NEXT: end_access [[ACCESS]] // CHECK-NEXT: unreachable // CHECK-LABEL: } // end sil function 'load_borrow_of_begin_access' -// CHECK-LABEL: end running test {{.*}} on load_borrow_of_begin_access: ossa_lifetime_completion +// CHECK-LABEL: end running test {{.*}} on load_borrow_of_begin_access: ossa_complete_lifetime sil [ossa] @load_borrow_of_begin_access : $@convention(thin) (@in_guaranteed C) -> () { entry(%addr : $*C): - specify_test "ossa_lifetime_completion %access availability" + specify_test "ossa_complete_lifetime %access availability" %access = begin_access [static] [read] %addr : $*C %load = load_borrow %access %borrow = begin_borrow %load @@ -965,31 +965,31 @@ struct Wrapper { var c: Klass } -// CHECK-LABEL: begin running test {{.*}} on testInteriorMarkDepNonEscAddressValue: ossa_lifetime_completion +// CHECK-LABEL: begin running test {{.*}} on testInteriorMarkDepNonEscAddressValue: ossa_complete_lifetime // CHECK-LABEL: sil [ossa] @testInteriorMarkDepNonEscAddressValue : {{.*}} { // CHECK: mark_dependence [nonescaping] // CHECK: end_borrow // CHECK-LABEL: } // end sil function 'testInteriorMarkDepNonEscAddressValue' -// CHECK-LABEL: end running test {{.*}} on testInteriorMarkDepNonEscAddressValue: ossa_lifetime_completion +// CHECK-LABEL: end running test {{.*}} on testInteriorMarkDepNonEscAddressValue: ossa_complete_lifetime sil [ossa] @testInteriorMarkDepNonEscAddressValue : $@convention(thin) (@owned Wrapper, @inout Klass) -> () { bb0(%0 : @owned $Wrapper, %1 : $*Klass): - specify_test "ossa_lifetime_completion %2 liveness" + specify_test "ossa_complete_lifetime %2 liveness" %2 = begin_borrow %0 : $Wrapper %3 = struct_extract %2 : $Wrapper, #Wrapper.c %4 = mark_dependence [nonescaping] %1 : $*Klass on %3 : $Klass unreachable } -// CHECK-LABEL: begin running test {{.*}} on testOwnedMarkDepNonEscAddressValue: ossa_lifetime_completion +// CHECK-LABEL: begin running test {{.*}} on testOwnedMarkDepNonEscAddressValue: ossa_complete_lifetime // CHECK-LABEL: sil [ossa] @testOwnedMarkDepNonEscAddressValue : {{.*}} { // CHECK: end_borrow // CHECK: mark_dependence [nonescaping] // CHECK: destroy_value [dead_end] %0 // CHECK-LABEL: } // end sil function 'testOwnedMarkDepNonEscAddressValue' -// CHECK-LABEL: end running test {{.*}} on testOwnedMarkDepNonEscAddressValue: ossa_lifetime_completion +// CHECK-LABEL: end running test {{.*}} on testOwnedMarkDepNonEscAddressValue: ossa_complete_lifetime sil [ossa] @testOwnedMarkDepNonEscAddressValue : $@convention(thin) (@owned Wrapper, @inout Klass) -> () { bb0(%0 : @owned $Wrapper, %1 : $*Klass): - specify_test "ossa_lifetime_completion %0 liveness" + specify_test "ossa_complete_lifetime %0 liveness" %2 = begin_borrow %0 : $Wrapper %3 = struct_extract %2 : $Wrapper, #Wrapper.c %4 = mark_dependence [nonescaping] %1 : $*Klass on %0 : $Wrapper diff --git a/test/SILOptimizer/simplify_cfg_checkcast.sil b/test/SILOptimizer/simplify_cfg_checkcast.sil index 35894aeb33931..24c226755c9e0 100644 --- a/test/SILOptimizer/simplify_cfg_checkcast.sil +++ b/test/SILOptimizer/simplify_cfg_checkcast.sil @@ -539,7 +539,7 @@ bb7: // Simplify down to a single diamond. // // TODO: Simplify some of the obviously dead copy/destroy/borrows -// on-the-fly after each simplify-cfg. Possible using CanonicalizeOSSALifetime. +// on-the-fly after each simplify-cfg. Possible using OSSACanonicalizeOwned. // // TODO-CHECK-LABEL: sil [ossa] @redundant_checked_cast_br_rauw_guaranteed_to_owned_merge : $@convention(method) (@owned Base) -> () { // TODO-CHECK: bb0(%0 : @owned $Base): diff --git a/validation-test/SILOptimizer/ossa_lifetime_completion_crash.sil b/validation-test/SILOptimizer/ossa_lifetime_completion_crash.sil index 335bdeb39b24f..17d0cf1ceb000 100644 --- a/validation-test/SILOptimizer/ossa_lifetime_completion_crash.sil +++ b/validation-test/SILOptimizer/ossa_lifetime_completion_crash.sil @@ -11,8 +11,8 @@ class C {} -// CHECK: Invalid SIL provided to OSSALifetimeCompletion?! -// CHECK: OSSALifetimeCompletion is visiting the availability boundary of %0 = argument of bb0 : $C +// CHECK: Invalid SIL provided to OSSACompleteLifetime?! +// CHECK: OSSACompleteLifetime is visiting the availability boundary of %0 = argument of bb0 : $C // CHECK: When walking forward from the def to the availability boundary a non-dead-end successor-less block was encountered: bb0 // CHECK: Its terminator must be an unreachable but is actually instead return undef : $() // id: %1 // CHECK: The walk stops at consumes, so reaching such a block means the value was leaked. The function with the leak is as follows: @@ -20,14 +20,14 @@ class C {} // CHECK: bb0(%0 : @owned $C): // CHECK: return undef : $() // CHECK: } // end sil function 'leak_c' -// CHECK: Invalid SIL provided to OSSALifetimeCompletion?! -// CHECK: Something that ran before OSSALifetimeCompletion (the current pass, an earlier pass, SILGen) has introduced a leak of this value. +// CHECK: Invalid SIL provided to OSSACompleteLifetime?! +// CHECK: Something that ran before OSSACompleteLifetime (the current pass, an earlier pass, SILGen) has introduced a leak of this value. // CHECK: Please rerun the crashing swift-frontend command with the following flags added and file a bug with the output: // CHECK: -sil-ownership-verify-all -Xllvm '-sil-print-function=leak_c' -Xllvm -sil-print-types -Xllvm -sil-print-module-on-error -// CHECK: Use the -disable-sil-ownership-verifier to disable this check. +// CHECK: Use the -disable-sil-ownership-verifier frontend flag to disable this check. // CHECK: Invalid lifetime of value whose availability boundary is being visited. sil [ossa] @leak_c : $@convention(thin) (@owned C) -> () { entry(%c : @owned $C): - specify_test "ossa_lifetime_completion @argument availability" + specify_test "ossa_complete_lifetime @argument availability" return undef : $() } diff --git a/validation-test/SILOptimizer/ossa_lifetime_completion_no_crash.sil b/validation-test/SILOptimizer/ossa_lifetime_completion_no_crash.sil index 21819d298444c..eba785e4210ee 100644 --- a/validation-test/SILOptimizer/ossa_lifetime_completion_no_crash.sil +++ b/validation-test/SILOptimizer/ossa_lifetime_completion_no_crash.sil @@ -11,6 +11,6 @@ class C {} // CHECK: end running test sil [ossa] @leak_c : $@convention(thin) (@owned C) -> () { entry(%c : @owned $C): - specify_test "ossa_lifetime_completion @argument availability" + specify_test "ossa_complete_lifetime @argument availability" return undef : $() }