Skip to content

Commit a717c35

Browse files
committed
FSPL: Generalize try_apply specific condition to handle other hypothetical def-on-edge cases.
1 parent 83b2593 commit a717c35

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
@@ -1323,11 +1323,21 @@ class FieldSensitiveMultiDefPrunedLiveRange
13231323
defBlocks.insert(defBlock, span);
13241324
initializeDefBlock(defBlock, span);
13251325

1326-
if (auto ta = dyn_cast<TryApplyInst>(node)) {
1327-
// The value becomes live on the success edge.
1328-
// Mark the basic block the try_apply terminates as a dead-to-live
1329-
// edge.
1330-
initializeDefBlock(ta->getParent(), span,
1326+
if (defBlock != node->getParentBlock()) {
1327+
// If the block the value becomes defined in is different from the
1328+
// defining instruction, then the def notionally occurs "on the edge"
1329+
// between the instruction (which must be a terminator) and the defined-in
1330+
// successor block. Mark the original block as a dead-to-live edge.
1331+
auto ti = cast<TermInst>(node);
1332+
1333+
assert(std::find(ti->getSuccessorBlocks().begin(),
1334+
ti->getSuccessorBlocks().end(),
1335+
defBlock) != ti->getSuccessorBlocks().end()
1336+
&& "defined-in block should be either the same block as the "
1337+
"defining instruction or a successor of the "
1338+
"defining terminator");
1339+
1340+
initializeDefBlock(ti->getParent(), span,
13311341
FieldSensitivePrunedLiveBlocks::DeadToLiveEdge);
13321342
}
13331343
}

0 commit comments

Comments
 (0)