@@ -1337,11 +1337,21 @@ class FieldSensitiveMultiDefPrunedLiveRange
1337
1337
defBlocks.insert (defBlock, span);
1338
1338
initializeDefBlock (defBlock, span);
1339
1339
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,
1345
1355
FieldSensitivePrunedLiveBlocks::DeadToLiveEdge);
1346
1356
}
1347
1357
}
0 commit comments