Skip to content

Commit 9d95514

Browse files
committed
[borrowing/consuming] Be sure to visit boxes with trivial @moveonly types.
This was not caught on main since I wasn't the tests with -sil-verify-all enabled... but it seems that it was caught by the verifier on 5.9. I have since enabled sil-verify-all by default on both of those tests (noimplicitcopy_consuming_parameter.swift and noimplicitcopy_borrowing_parameter.swift). rdar://110364874
1 parent 0d36738 commit 9d95514

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

lib/SILOptimizer/Mandatory/MoveOnlyWrappedTypeEliminator.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,18 @@ struct SILMoveOnlyWrappedTypeEliminator {
279279

280280
} // namespace
281281

282+
/// Returns true if this is a moveonlywrapped type whose underlying type is a
283+
/// trivial type /or/ if this is a boxed type of that sort.
284+
static bool isMoveOnlyWrappedTrivial(SILValue value) {
285+
auto *fn = value->getFunction();
286+
SILType type = value->getType();
287+
if (type.removingMoveOnlyWrapper().isTrivial(fn))
288+
return true;
289+
if (type.isBoxedMoveOnlyWrappedType(fn))
290+
return type.getSILBoxFieldType(fn).removingMoveOnlyWrapper().isTrivial(fn);
291+
return false;
292+
}
293+
282294
bool SILMoveOnlyWrappedTypeEliminator::process() {
283295
bool madeChange = true;
284296

@@ -314,7 +326,7 @@ bool SILMoveOnlyWrappedTypeEliminator::process() {
314326
continue;
315327

316328
if (trivialOnly &&
317-
!v->getType().removingMoveOnlyWrapper().isTrivial(*fn))
329+
!isMoveOnlyWrappedTrivial(v))
318330
continue;
319331

320332
v->unsafelyEliminateMoveOnlyWrapper(fn);

0 commit comments

Comments
 (0)