Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion lib/SILOptimizer/Mandatory/MoveOnlyWrappedTypeEliminator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,18 @@ struct SILMoveOnlyWrappedTypeEliminator {

} // namespace

/// Returns true if this is a moveonlywrapped type whose underlying type is a
/// trivial type /or/ if this is a boxed type of that sort.
static bool isMoveOnlyWrappedTrivial(SILValue value) {
auto *fn = value->getFunction();
SILType type = value->getType();
if (type.removingMoveOnlyWrapper().isTrivial(fn))
return true;
if (type.isBoxedMoveOnlyWrappedType(fn))
return type.getSILBoxFieldType(fn).removingMoveOnlyWrapper().isTrivial(fn);
return false;
}

bool SILMoveOnlyWrappedTypeEliminator::process() {
bool madeChange = true;

Expand Down Expand Up @@ -314,7 +326,7 @@ bool SILMoveOnlyWrappedTypeEliminator::process() {
continue;

if (trivialOnly &&
!v->getType().removingMoveOnlyWrapper().isTrivial(*fn))
!isMoveOnlyWrappedTrivial(v))
continue;

v->unsafelyEliminateMoveOnlyWrapper(fn);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %target-swift-frontend -emit-sil %s -verify
// RUN: %target-swift-frontend -emit-sil %s -verify -sil-verify-all

////////////////////////
// MARK: Declarations //
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %target-swift-frontend -emit-sil %s -verify
// RUN: %target-swift-frontend -emit-sil %s -verify -sil-verify-all

////////////////////////
// MARK: Declarations //
Expand Down