Skip to content

Commit 6488da9

Browse files
committed
SILOptimizer: don't copy move-only partial_apply arguments to temporaries
Instead bail when trying to deleted a dead closure or when performing the apply-of-partial_apply optimization. TODO: In OSSA this should be solvable without the need of copies to temporaries.
1 parent 46abfa8 commit 6488da9

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

lib/SILOptimizer/Utils/InstOptUtils.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -990,6 +990,14 @@ static bool keepArgsOfPartialApplyAlive(PartialApplyInst *pai,
990990
return false;
991991
}
992992

993+
// We must not introduce copies for move only types.
994+
// TODO: in OSSA, instead of bailing, it's possible to destroy the arguments
995+
// without the need of copies.
996+
for (Operand *argOp : argsToHandle) {
997+
if (argOp->get()->getType().isMoveOnly())
998+
return false;
999+
}
1000+
9931001
for (Operand *argOp : argsToHandle) {
9941002
SILValue arg = argOp->get();
9951003

lib/SILOptimizer/Utils/PartialApplyCombiner.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,14 @@ bool PartialApplyCombiner::copyArgsToTemporaries(
108108
return false;
109109
}
110110

111+
// We must not introduce copies for move only types.
112+
// TODO: in OSSA, instead of bailing, it's possible to keep the arguments
113+
// alive without the need of copies.
114+
for (Operand *argOp : argsToHandle) {
115+
if (argOp->get()->getType().isMoveOnly())
116+
return false;
117+
}
118+
111119
for (Operand *argOp : argsToHandle) {
112120
SILValue arg = argOp->get();
113121
SILValue tmp = arg;

0 commit comments

Comments
 (0)