Skip to content

Commit cd14f4c

Browse files
committed
[NFC] PrunedLiveness: Factor out duplicated method
In preparation to make it more complex.
1 parent aa89c01 commit cd14f4c

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

lib/SIL/Utils/PrunedLiveness.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -489,17 +489,18 @@ bool PrunedLiveRange<LivenessWithDefs>::isWithinBoundary(
489489
llvm_unreachable("instruction must be in its parent block");
490490
}
491491

492+
static bool checkDeadEnd(SILInstruction *inst, DeadEndBlocks *deadEndBlocks) {
493+
return deadEndBlocks && deadEndBlocks->isDeadEnd(inst->getParent());
494+
}
495+
492496
template <typename LivenessWithDefs>
493497
bool PrunedLiveRange<LivenessWithDefs>::areUsesWithinBoundary(
494498
ArrayRef<Operand *> uses, DeadEndBlocks *deadEndBlocks) const {
495499
assert(asImpl().isInitialized());
496500

497-
auto checkDeadEnd = [deadEndBlocks](SILInstruction *inst) {
498-
return deadEndBlocks && deadEndBlocks->isDeadEnd(inst->getParent());
499-
};
500501
for (auto *use : uses) {
501502
auto *user = use->getUser();
502-
if (!asImpl().isWithinBoundary(user) && !checkDeadEnd(user))
503+
if (!asImpl().isWithinBoundary(user) && !checkDeadEnd(user, deadEndBlocks))
503504
return false;
504505
}
505506
return true;
@@ -510,12 +511,9 @@ bool PrunedLiveRange<LivenessWithDefs>::areUsesOutsideBoundary(
510511
ArrayRef<Operand *> uses, DeadEndBlocks *deadEndBlocks) const {
511512
assert(asImpl().isInitialized());
512513

513-
auto checkDeadEnd = [deadEndBlocks](SILInstruction *inst) {
514-
return deadEndBlocks && deadEndBlocks->isDeadEnd(inst->getParent());
515-
};
516514
for (auto *use : uses) {
517515
auto *user = use->getUser();
518-
if (asImpl().isWithinBoundary(user) || checkDeadEnd(user))
516+
if (asImpl().isWithinBoundary(user) || checkDeadEnd(user, deadEndBlocks))
519517
return false;
520518
}
521519
return true;

0 commit comments

Comments
 (0)