File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -242,6 +242,10 @@ class PrunedLiveness {
242
242
return NonUser;
243
243
return useIter->second ? LifetimeEndingUse : NonLifetimeEndingUse;
244
244
}
245
+
246
+ // / Return true if \p inst occurs before the liveness boundary. Used when the
247
+ // / client already knows that inst occurs after the start of liveness.
248
+ bool isWithinBoundary (SILInstruction *inst);
245
249
};
246
250
247
251
} // namespace swift
Original file line number Diff line number Diff line change @@ -116,3 +116,28 @@ bool PrunedLiveness::updateForBorrowingOperand(Operand *op) {
116
116
}
117
117
return true ;
118
118
}
119
+
120
+ bool PrunedLiveness::isWithinBoundary (SILInstruction *inst) {
121
+ SILBasicBlock *block = inst->getParent ();
122
+ switch (getBlockLiveness (block)) {
123
+ case PrunedLiveBlocks::Dead:
124
+ return false ;
125
+ case PrunedLiveBlocks::LiveWithin:
126
+ break ;
127
+ case PrunedLiveBlocks::LiveOut:
128
+ return true ;
129
+ }
130
+ // The boundary is within this block. This instruction is before the boundary
131
+ // iff any interesting uses occur after it.
132
+ for (SILInstruction &inst :
133
+ make_range (std::next (inst->getIterator ()), block->end ())) {
134
+ switch (isInterestingUser (&inst)) {
135
+ case PrunedLiveness::NonUser:
136
+ break ;
137
+ case PrunedLiveness::NonLifetimeEndingUse:
138
+ case PrunedLiveness::LifetimeEndingUse:
139
+ return true ;
140
+ }
141
+ }
142
+ return false ;
143
+ }
You can’t perform that action at this time.
0 commit comments