File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
lib/SILOptimizer/Transforms Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -281,7 +281,16 @@ void DCE::markLive() {
281281 }
282282 break ;
283283 }
284- case SILInstructionKind::EndBorrowInst:
284+ case SILInstructionKind::EndBorrowInst: {
285+ auto phi = PhiValue (I.getOperand (0 ));
286+ // If there is a pointer escape, disable DCE.
287+ if (phi && hasPointerEscape (phi)) {
288+ markInstructionLive (&I);
289+ }
290+ // The instruction is live only if it's operand value is also live
291+ addReverseDependency (I.getOperand (0 ), &I);
292+ break ;
293+ }
285294 case SILInstructionKind::EndLifetimeInst: {
286295 // The instruction is live only if it's operand value is also live
287296 addReverseDependency (I.getOperand (0 ), &I);
@@ -311,9 +320,8 @@ void DCE::markLive() {
311320 disableBorrowDCE (root);
312321 }
313322 }
314- // If we have a lexical borrow scope or a pointer escape, disable DCE.
315- if (borrowInst->isLexical () ||
316- hasPointerEscape (BorrowedValue (borrowInst))) {
323+ // If we have a lexical borrow scope, disable DCE.
324+ if (borrowInst->isLexical ()) {
317325 disableBorrowDCE (borrowInst);
318326 }
319327 break ;
You can’t perform that action at this time.
0 commit comments