Skip to content

Commit 738f01e

Browse files
committed
[NFC] SIL: Extracted remove "any" m-o wrapping.
1 parent 91ca16b commit 738f01e

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
@@ -862,6 +862,9 @@ class SILType {
862862
return isMoveOnlyWrapped() || isBoxedMoveOnlyWrappedType(fn);
863863
}
864864

865+
/// Removes a direct wrapper from a type or a wrapper from a type in a box.
866+
SILType removingAnyMoveOnlyWrapping(const SILFunction *fn);
867+
865868
/// Returns a SILType with any archetypes mapped out of context.
866869
SILType mapTypeOutOfContext() const;
867870

include/swift/SIL/SILValue.h

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

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)