Skip to content

Commit 2c0a35a

Browse files
committed
[PrunedLiveness] Added areUsesOutsideBoundary.
1 parent d5cbc7e commit 2c0a35a

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

include/swift/SIL/PrunedLiveness.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,10 @@ class PrunedLiveness {
338338
bool areUsesWithinBoundary(ArrayRef<Operand *> uses,
339339
DeadEndBlocks *deadEndBlocks) const;
340340

341+
/// \p deadEndBlocks is optional.
342+
bool areUsesOutsideBoundary(ArrayRef<Operand *> uses,
343+
DeadEndBlocks *deadEndBlocks) const;
344+
341345
/// Compute liveness for a single SSA definition.
342346
void computeSSALiveness(SILValue def);
343347
};

lib/SIL/Utils/PrunedLiveness.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,20 @@ bool PrunedLiveness::areUsesWithinBoundary(ArrayRef<Operand *> uses,
167167
return true;
168168
}
169169

170+
bool PrunedLiveness::areUsesOutsideBoundary(
171+
ArrayRef<Operand *> uses, DeadEndBlocks *deadEndBlocks) const {
172+
auto checkDeadEnd = [deadEndBlocks](SILInstruction *inst) {
173+
return deadEndBlocks && deadEndBlocks->isDeadEnd(inst->getParent());
174+
};
175+
176+
for (auto *use : uses) {
177+
auto *user = use->getUser();
178+
if (isWithinBoundary(user) || checkDeadEnd(user))
179+
return false;
180+
}
181+
return true;
182+
}
183+
170184
// An SSA def meets all the criteria for pruned liveness--def dominates all uses
171185
// with no holes in the liverange. The lifetime-ending uses are also
172186
// recorded--destroy_value or end_borrow. However destroy_values may not

0 commit comments

Comments
 (0)