File tree Expand file tree Collapse file tree 3 files changed +9
-4
lines changed Expand file tree Collapse file tree 3 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ inline bool isForwardingConsume(SILValue value) {
78
78
return canOpcodeForwardOwnedValues (value);
79
79
}
80
80
81
- bool hasEscaped (BorrowedValue value);
81
+ bool hasPointerEscape (BorrowedValue value);
82
82
83
83
// / Find leaf "use points" of \p guaranteedValue that determine its lifetime
84
84
// / requirement. Return true if no PointerEscape use was found.
Original file line number Diff line number Diff line change 25
25
26
26
using namespace swift ;
27
27
28
- bool swift::hasEscaped (BorrowedValue value) {
28
+ bool swift::hasPointerEscape (BorrowedValue value) {
29
+ assert (value.kind == BorrowedValueKind::BeginBorrow ||
30
+ value.kind == BorrowedValueKind::LoadBorrow);
29
31
GraphNodeWorklist<Operand *, 8 > worklist;
30
32
for (Operand *use : value->getUses ()) {
31
33
if (use->getOperandOwnership () != OperandOwnership::NonUse)
@@ -42,14 +44,14 @@ bool swift::hasEscaped(BorrowedValue value) {
42
44
43
45
case OperandOwnership::ForwardingUnowned:
44
46
case OperandOwnership::PointerEscape:
45
- case OperandOwnership::BitwiseEscape:
46
47
return true ;
47
48
48
49
case OperandOwnership::Borrow:
49
50
case OperandOwnership::EndBorrow:
50
51
case OperandOwnership::InstantaneousUse:
51
52
case OperandOwnership::UnownedInstantaneousUse:
52
53
case OperandOwnership::InteriorPointer:
54
+ case OperandOwnership::BitwiseEscape:
53
55
break ;
54
56
55
57
case OperandOwnership::Reborrow: {
Original file line number Diff line number Diff line change @@ -303,7 +303,10 @@ void DCE::markLive() {
303
303
}
304
304
// Populate reborrowDependencies for this borrow
305
305
findReborrowDependencies (borrowInst);
306
- if (hasEscaped (BorrowedValue (borrowInst))) {
306
+ // Don't optimize a borrow scope if it is lexical or has a pointer
307
+ // escape.
308
+ if (borrowInst->isLexical () ||
309
+ hasPointerEscape (BorrowedValue (borrowInst))) {
307
310
// Visit all end_borrows and mark them live
308
311
visitTransitiveEndBorrows (borrowInst, [&](EndBorrowInst *endBorrow) {
309
312
markInstructionLive (endBorrow);
You can’t perform that action at this time.
0 commit comments