mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Fix visitNonEscapingLifetimeEnds to handle mark_dependence uses
Now it visits unknown uses separately rather than asserting.
This commit is contained in:
@@ -258,9 +258,13 @@ bool OwnershipUseVisitor<Impl>::visitInnerBorrow(Operand *borrowingOperand) {
|
||||
return false;
|
||||
|
||||
return BorrowingOperand(borrowingOperand)
|
||||
.visitScopeEndingUses([&](Operand *borrowEnd) {
|
||||
return visitInnerBorrowScopeEnd(borrowEnd);
|
||||
});
|
||||
.visitScopeEndingUses(
|
||||
[&](Operand *borrowEnd) {
|
||||
return visitInnerBorrowScopeEnd(borrowEnd);
|
||||
},
|
||||
[&](Operand *unknownUse) {
|
||||
return asImpl().handlePointerEscape(unknownUse);
|
||||
});
|
||||
}
|
||||
|
||||
template <typename Impl>
|
||||
|
||||
@@ -360,12 +360,16 @@ struct BorrowingOperand {
|
||||
/// over a region of code instead of just for a single instruction, visit
|
||||
/// those uses.
|
||||
///
|
||||
/// Returns false and early exits if the visitor \p func returns false.
|
||||
/// Returns false and early exits if the \p visitScopeEnd or \p
|
||||
/// visitUnknownUse returns false.
|
||||
///
|
||||
/// For an instantaneous borrow, such as apply, this visits no uses. For
|
||||
/// begin_apply it visits the end_apply uses. For borrow introducers, it
|
||||
/// visits the end of the introduced borrow scope.
|
||||
bool visitScopeEndingUses(function_ref<bool(Operand *)> func) const;
|
||||
bool visitScopeEndingUses(function_ref<bool(Operand *)> visitScopeEnd,
|
||||
function_ref<bool(Operand *)> visitUnknownUse
|
||||
= [](Operand *){ return false; })
|
||||
const;
|
||||
|
||||
/// Returns true for borrows that create a local borrow scope but have no
|
||||
/// scope-ending uses (presumably all paths are dead-end blocks). This does
|
||||
@@ -381,7 +385,10 @@ struct BorrowingOperand {
|
||||
/// BorrowingOperand.
|
||||
///
|
||||
/// Returns false and early exits if the visitor \p func returns false.
|
||||
bool visitExtendedScopeEndingUses(function_ref<bool(Operand *)> func) const;
|
||||
bool visitExtendedScopeEndingUses(
|
||||
function_ref<bool(Operand *)> func,
|
||||
function_ref<bool(Operand *)> visitUnknownUse
|
||||
= [](Operand *){ return false; }) const;
|
||||
|
||||
/// Returns true if this borrow scope operand consumes guaranteed
|
||||
/// values and produces a new scope afterwards.
|
||||
|
||||
@@ -289,8 +289,9 @@ private:
|
||||
/// scope. Reborrows within nested borrows scopes are already summarized by the
|
||||
/// outer borrow scope.
|
||||
enum class InnerBorrowKind {
|
||||
Contained, // any borrows are fully contained within this live range
|
||||
Reborrowed // at least one immediately nested borrow is reborrowed
|
||||
Contained, // any borrows are fully contained within this live range
|
||||
Reborrowed, // at least one immediately nested borrow is reborrowed
|
||||
Escaped // the end of the borrow scope is indeterminate
|
||||
};
|
||||
|
||||
inline InnerBorrowKind meet(InnerBorrowKind lhs, InnerBorrowKind rhs) {
|
||||
|
||||
@@ -8546,8 +8546,9 @@ public:
|
||||
}
|
||||
|
||||
/// Visit the instructions that end the lifetime of an OSSA on-stack closure.
|
||||
bool visitNonEscapingLifetimeEnds(llvm::function_ref<bool (Operand*)> func)
|
||||
const;
|
||||
bool visitNonEscapingLifetimeEnds(
|
||||
llvm::function_ref<bool (Operand*)> visitScopeEnd,
|
||||
llvm::function_ref<bool (Operand*)> visitUnknownUse) const;
|
||||
};
|
||||
|
||||
/// Promote an Objective-C block that is on the stack to the heap, or simply
|
||||
|
||||
Reference in New Issue
Block a user