Skip to content

Commit 3b830bf

Browse files
authored
Merge pull request #72509 from jckarter/fspl-def-edge-generalization
FSPL: Generalize `try_apply` specific condition to handle other hypothetical def-on-edge cases.
2 parents 41cd0ea + a717c35 commit 3b830bf

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

include/swift/SIL/FieldSensitivePrunedLiveness.h

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,11 +1337,21 @@ class FieldSensitiveMultiDefPrunedLiveRange
13371337
defBlocks.insert(defBlock, span);
13381338
initializeDefBlock(defBlock, span);
13391339

1340-
if (auto ta = dyn_cast<TryApplyInst>(node)) {
1341-
// The value becomes live on the success edge.
1342-
// Mark the basic block the try_apply terminates as a dead-to-live
1343-
// edge.
1344-
initializeDefBlock(ta->getParent(), span,
1340+
if (defBlock != node->getParentBlock()) {
1341+
// If the block the value becomes defined in is different from the
1342+
// defining instruction, then the def notionally occurs "on the edge"
1343+
// between the instruction (which must be a terminator) and the defined-in
1344+
// successor block. Mark the original block as a dead-to-live edge.
1345+
auto ti = cast<TermInst>(node);
1346+
1347+
assert(std::find(ti->getSuccessorBlocks().begin(),
1348+
ti->getSuccessorBlocks().end(),
1349+
defBlock) != ti->getSuccessorBlocks().end()
1350+
&& "defined-in block should be either the same block as the "
1351+
"defining instruction or a successor of the "
1352+
"defining terminator");
1353+
1354+
initializeDefBlock(ti->getParent(), span,
13451355
FieldSensitivePrunedLiveBlocks::DeadToLiveEdge);
13461356
}
13471357
}

0 commit comments

Comments
 (0)