Skip to content

Commit 78c1837

Browse files
committed
[NFC] SIL: Extracted has "any" move-only wrapping.
This predicate is used in several places.
1 parent b5b637c commit 78c1837

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

include/swift/SIL/SILType.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,11 @@ class SILType {
870870
/// requires a SILFunction * and is specialized.
871871
SILType removingMoveOnlyWrapperFromBoxedType(const SILFunction *fn);
872872

873+
/// Whether there's a direct wrapper or a wrapper inside a box.
874+
bool hasAnyMoveOnlyWrapping(const SILFunction *fn) {
875+
return isMoveOnlyWrapped() || isBoxedMoveOnlyWrappedType(fn);
876+
}
877+
873878
/// Returns a SILType with any archetypes mapped out of context.
874879
SILType mapTypeOutOfContext() const;
875880

include/swift/SIL/SILValue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ class ValueBase : public SILNode, public SILAllocated<ValueBase> {
599599
/// NOTE: Please do not use this directly! It is only meant to be used by the
600600
/// optimizer pass: SILMoveOnlyWrappedTypeEliminator.
601601
bool unsafelyEliminateMoveOnlyWrapper(const SILFunction *fn) {
602-
if (!Type.isMoveOnlyWrapped() && !Type.isBoxedMoveOnlyWrappedType(fn))
602+
if (!Type.hasAnyMoveOnlyWrapping(fn))
603603
return false;
604604
if (Type.isMoveOnlyWrapped()) {
605605
Type = Type.removingMoveOnlyWrapper();

lib/SILOptimizer/Mandatory/MoveOnlyWrappedTypeEliminator.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,7 @@ bool SILMoveOnlyWrappedTypeEliminator::process() {
300300

301301
for (auto &bb : *fn) {
302302
for (auto *arg : bb.getArguments()) {
303-
if (!arg->getType().isMoveOnlyWrapped() &&
304-
!arg->getType().isBoxedMoveOnlyWrappedType(fn))
303+
if (!arg->getType().hasAnyMoveOnlyWrapping(fn))
305304
continue;
306305

307306
// If we are looking at trivial only, skip non-trivial function args.
@@ -322,8 +321,7 @@ bool SILMoveOnlyWrappedTypeEliminator::process() {
322321

323322
for (auto &ii : bb) {
324323
for (SILValue v : ii.getResults()) {
325-
if (!v->getType().isMoveOnlyWrapped() &&
326-
!v->getType().isBoxedMoveOnlyWrappedType(fn))
324+
if (!v->getType().hasAnyMoveOnlyWrapping(fn))
327325
continue;
328326

329327
if (trivialOnly &&

0 commit comments

Comments
 (0)