Skip to content

Commit f39b70a

Browse files
committed
[NFC] SIL: Extracted remove "any" m-o wrapping.
1 parent 78c1837 commit f39b70a

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

include/swift/SIL/SILType.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,9 @@ class SILType {
875875
return isMoveOnlyWrapped() || isBoxedMoveOnlyWrappedType(fn);
876876
}
877877

878+
/// Removes a direct wrapper from a type or a wrapper from a type in a box.
879+
SILType removingAnyMoveOnlyWrapping(const SILFunction *fn);
880+
878881
/// Returns a SILType with any archetypes mapped out of context.
879882
SILType mapTypeOutOfContext() const;
880883

include/swift/SIL/SILValue.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -601,12 +601,7 @@ class ValueBase : public SILNode, public SILAllocated<ValueBase> {
601601
bool unsafelyEliminateMoveOnlyWrapper(const SILFunction *fn) {
602602
if (!Type.hasAnyMoveOnlyWrapping(fn))
603603
return false;
604-
if (Type.isMoveOnlyWrapped()) {
605-
Type = Type.removingMoveOnlyWrapper();
606-
} else {
607-
assert(Type.isBoxedMoveOnlyWrappedType(fn));
608-
Type = Type.removingMoveOnlyWrapperFromBoxedType(fn);
609-
}
604+
Type = Type.removingAnyMoveOnlyWrapping(fn);
610605
return true;
611606
}
612607

lib/SIL/IR/SILType.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,6 +1284,17 @@ SILType SILType::removingMoveOnlyWrapperFromBoxedType(const SILFunction *fn) {
12841284
return SILType::getPrimitiveObjectType(newBoxType);
12851285
}
12861286

1287+
SILType SILType::removingAnyMoveOnlyWrapping(const SILFunction *fn) {
1288+
if (!isMoveOnlyWrapped() && !isBoxedMoveOnlyWrappedType(fn))
1289+
return *this;
1290+
1291+
if (isMoveOnlyWrapped())
1292+
return removingMoveOnlyWrapper();
1293+
1294+
assert(isBoxedMoveOnlyWrappedType(fn));
1295+
return removingMoveOnlyWrapperFromBoxedType(fn);
1296+
}
1297+
12871298
bool SILType::isSendable(SILFunction *fn) const {
12881299
return getASTType()->isSendableType();
12891300
}

0 commit comments

Comments
 (0)