Skip to content

Commit 87bf0e4

Browse files
authored
Merge pull request swiftlang#39566 from atrick/comment-ossa
Minor source and doc comments related to OSSA
2 parents 704b370 + 5d21e22 commit 87bf0e4

File tree

9 files changed

+21
-7
lines changed

9 files changed

+21
-7
lines changed

docs/SIL.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3842,7 +3842,7 @@ mark_function_escape
38423842

38433843
sil-instruction ::= 'mark_function_escape' sil-operand (',' sil-operand)
38443844

3845-
%2 = mark_function_escape %1 : $*T
3845+
mark_function_escape %1 : $*T
38463846

38473847
Indicates that a function definition closes over a symbolic memory location.
38483848
This instruction is variadic, and all of its operands must be addresses.

include/swift/Basic/DAGNodeWorklist.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
///
2626
/// The primary API has two methods: intialize() and pop(). Others are provided
2727
/// for flexibility.
28+
///
29+
/// TODO: This also works well for cyclic graph traversal. Particularly CFG
30+
/// traversal. So we should probably just call it GraphNodeWorklist.
2831
template <typename T, unsigned SmallSize> struct DAGNodeWorklist {
2932
llvm::SmallPtrSet<T, SmallSize> nodeVisited;
3033
llvm::SmallVector<T, SmallSize> nodeVector;

include/swift/SIL/MemAccessUtils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
/// Each object's property or its tail storage is separately accessed.
7878
///
7979
/// In addition to the free-standing functions, the AccessBase and
80-
/// AccessStorage classes encapsulte the identity of an access. They can be
80+
/// AccessStorage classes encapsulate the identity of an access. They can be
8181
/// used to:
8282
/// - directly compare and hash access identities
8383
/// - exhaustively switch over the kinds of accesses

include/swift/SIL/OwnershipUtils.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,9 @@ class InteriorPointerOperandKind {
712712
/// object with guaranteed ownership. All transitive address uses of the
713713
/// interior pointer must be within the lifetime of the guaranteed lifetime. As
714714
/// such, these must be treated as implicit uses of the parent guaranteed value.
715+
///
716+
/// FIXME: This should probably also handle project_box once we support
717+
/// borrowing a box.
715718
struct InteriorPointerOperand {
716719
Operand *operand;
717720
InteriorPointerOperandKind kind;

include/swift/SIL/SILInstruction.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4038,6 +4038,10 @@ class BeginBorrowInst
40384038
lexical(isLexical) {}
40394039

40404040
public:
4041+
// FIXME: this does not return all instructions that end a local borrow
4042+
// scope. Branches can also end it via a reborrow, so APIs using this are
4043+
// incorrect. Instead, either iterate over all uses and return those with
4044+
// OperandOwnership::EndBorrow or Reborrow.
40414045
using EndBorrowRange =
40424046
decltype(std::declval<ValueBase>().getUsersOfType<EndBorrowInst>());
40434047

include/swift/SILOptimizer/Utils/OwnershipOptUtils.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ inline bool requiresOSSACleanup(SILValue v) {
3434
&& v.getOwnershipKind() != OwnershipKind::Unowned;
3535
}
3636

37-
// Defined in BasicBlockUtils.h
38-
struct JointPostDominanceSetComputer;
39-
4037
/// Given a new phi that may use a guaranteed value, create nested borrow scopes
4138
/// for its incoming operands and end_borrows that cover the phi's extended
4239
/// borrow scope, which transitively includes any phis that use this phi.

lib/SIL/Verifier/LinearLifetimeChecker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ void State::checkDataflowEndState(DeadEndBlocks &deBlocks) {
503503
}
504504
llvm::errs() << "Post Dominating Failure Blocks:\n";
505505
for (auto *succBlock : successorBlocksThatMustBeVisited) {
506-
llvm::errs() << "bb" << succBlock->getDebugID();
506+
llvm::errs() << " bb" << succBlock->getDebugID();
507507
}
508508
llvm::errs() << '\n';
509509
});

lib/SILOptimizer/Mandatory/OSLogOptimization.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,10 @@ static void replaceAllUsesAndFixLifetimes(SILValue foldedVal,
950950
// destroy foldedVal at the end of the borrow scope.
951951
assert(originalVal.getOwnershipKind() == OwnershipKind::Guaranteed);
952952

953+
// FIXME: getUniqueBorrowScopeIntroducingValue may look though various storage
954+
// casts. There's no reason to think that it's valid to replace uses of
955+
// originalVal with a new borrow of the the "introducing value". All casts
956+
// potentially need to be cloned.
953957
Optional<BorrowedValue> originalScopeBegin =
954958
getUniqueBorrowScopeIntroducingValue(originalVal);
955959
assert(originalScopeBegin &&

lib/SILOptimizer/Utils/CanonicalOSSALifetime.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,9 @@ void CanonicalizeOSSALifetime::findOrInsertDestroyInBlock(SILBasicBlock *bb) {
514514
/// consuming uses, including destroys on all return paths.
515515
/// - The postdominating consumes cannot be within nested loops.
516516
/// - Any blocks in nested loops are now marked LiveOut.
517+
///
518+
/// TODO: replace this with PrunedLivenessAnalysis::computeBoundary. Separate
519+
/// out destroy insertion, debug info, diagnostics, etc. as post-passes.
517520
void CanonicalizeOSSALifetime::findOrInsertDestroys() {
518521
this->accessBlocks = accessBlockAnalysis->get(getCurrentDef()->getFunction());
519522

@@ -525,7 +528,7 @@ void CanonicalizeOSSALifetime::findOrInsertDestroys() {
525528
switch (liveness.getBlockLiveness(bb)) {
526529
case PrunedLiveBlocks::LiveOut:
527530
// A lifetimeEndBlock may be determined to be LiveOut after analyzing the
528-
// extended It is irrelevent for finding the boundary.
531+
// liveness. It is irrelevent for finding the boundary.
529532
break;
530533
case PrunedLiveBlocks::LiveWithin: {
531534
// The liveness boundary is inside this block. Insert a final destroy

0 commit comments

Comments
 (0)