Skip to content

Commit 97e6b56

Browse files
authored
Merge pull request #66402 from gottesmm/main-rdar110364874
[borrowing/consuming] Be sure to visit boxes with trivial @moveonly types.
2 parents 861fd2f + 9d95514 commit 97e6b56

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
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);

test/SILOptimizer/noimplicitcopy_borrowing_parameters.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -emit-sil %s -verify
1+
// RUN: %target-swift-frontend -emit-sil %s -verify -sil-verify-all
22

33
////////////////////////
44
// MARK: Declarations //

test/SILOptimizer/noimplicitcopy_consuming_parameters.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -emit-sil %s -verify
1+
// RUN: %target-swift-frontend -emit-sil %s -verify -sil-verify-all
22

33
////////////////////////
44
// MARK: Declarations //

0 commit comments

Comments
 (0)