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() {
281
281
}
282
282
break ;
283
283
}
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
+ }
285
294
case SILInstructionKind::EndLifetimeInst: {
286
295
// The instruction is live only if it's operand value is also live
287
296
addReverseDependency (I.getOperand (0 ), &I);
@@ -311,9 +320,8 @@ void DCE::markLive() {
311
320
disableBorrowDCE (root);
312
321
}
313
322
}
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 ()) {
317
325
disableBorrowDCE (borrowInst);
318
326
}
319
327
break ;
You can’t perform that action at this time.
0 commit comments