Skip to content

Commit 2b072a5

Browse files
committed
Allow duplicating mark_dependence [nonescaping] on addresses
1 parent 26277c8 commit 2b072a5

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

lib/SIL/IR/SILInstruction.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,11 +1448,11 @@ bool SILInstruction::isTriviallyDuplicatable() const {
14481448
if (auto *PA = dyn_cast<PartialApplyInst>(this)) {
14491449
return !PA->isOnStack();
14501450
}
1451-
// Like partial_apply [onstack], mark_dependence [nonescaping] creates a
1452-
// borrow scope. We currently assume that a set of dominated scope-ending uses
1453-
// can be found.
1451+
// Like partial_apply [onstack], mark_dependence [nonescaping] on values
1452+
// creates a borrow scope. We currently assume that a set of dominated
1453+
// scope-ending uses can be found.
14541454
if (auto *MD = dyn_cast<MarkDependenceInst>(this)) {
1455-
return !MD->isNonEscaping();
1455+
return !MD->isNonEscaping() || MD->getType().isAddress();
14561456
}
14571457

14581458
if (isa<OpenExistentialAddrInst>(this) || isa<OpenExistentialRefInst>(this) ||

lib/SILOptimizer/Utils/LoopUtils.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,11 +264,11 @@ bool swift::canDuplicateLoopInstruction(SILLoop *L, SILInstruction *I) {
264264
return false;
265265
}
266266
}
267-
// Like partial_apply [onstack], mark_dependence [nonescaping] creates a
268-
// borrow scope. We currently assume that a set of dominated scope-ending uses
269-
// can be found.
267+
// Like partial_apply [onstack], mark_dependence [nonescaping] on values
268+
// creates a borrow scope. We currently assume that a set of dominated
269+
// scope-ending uses can be found.
270270
if (auto *MD = dyn_cast<MarkDependenceInst>(I)) {
271-
return !MD->isNonEscaping();
271+
return !MD->isNonEscaping() || MD->getType().isAddress();
272272
}
273273
// CodeGen can't build ssa for objc methods.
274274
if (auto *Method = dyn_cast<MethodInst>(I)) {

0 commit comments

Comments
 (0)