Skip to content

Commit 4b361d5

Browse files
authored
Merge pull request #61145 from atrick/ossa-nonuse-liveness
Handle OperandOwnerhip::NonUse in PrunedLiveness::computeSSALiveness.
2 parents 0cfef8e + e1e59ac commit 4b361d5

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

lib/SIL/Utils/PrunedLiveness.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,26 @@ bool PrunedLiveness::areUsesOutsideBoundaryOfDef(
263263
// uses with no holes in the liverange. The lifetime-ending uses are also
264264
// recorded--destroy_value or end_borrow. However destroy_values may not
265265
// jointly-post dominate if dead-end blocks are present.
266+
//
267+
// Note: Uses with OperandOwnership::NonUse cannot be considered normal uses for
268+
// liveness. Otherwise, liveness would need to separately track non-uses
269+
// everywhere. Non-uses cannot be treated like normal non-lifetime-ending uses
270+
// because they can occur on both applies, which need to extend liveness to the
271+
// return point, and on forwarding instructions, like init_existential_ref,
272+
// which need to consume their use even when type-dependent operands exist.
266273
void PrunedLiveness::computeSSALiveness(SILValue def) {
267274
initializeDefBlock(def->getParentBlock());
268275
for (Operand *use : def->getUses()) {
269-
updateForUse(use->getUser(), use->isLifetimeEnding());
276+
switch (use->getOperandOwnership()) {
277+
default:
278+
updateForUse(use->getUser(), use->isLifetimeEnding());
279+
break;
280+
case OperandOwnership::NonUse:
281+
break;
282+
case OperandOwnership::Borrow:
283+
updateForBorrowingOperand(use);
284+
break;
285+
}
270286
}
271287
}
272288

0 commit comments

Comments
 (0)