Skip to content

Commit 91ca16b

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

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
@@ -857,6 +857,11 @@ class SILType {
857857
/// requires a SILFunction * and is specialized.
858858
SILType removingMoveOnlyWrapperFromBoxedType(const SILFunction *fn);
859859

860+
/// Whether there's a direct wrapper or a wrapper inside a box.
861+
bool hasAnyMoveOnlyWrapping(const SILFunction *fn) {
862+
return isMoveOnlyWrapped() || isBoxedMoveOnlyWrappedType(fn);
863+
}
864+
860865
/// Returns a SILType with any archetypes mapped out of context.
861866
SILType mapTypeOutOfContext() const;
862867

include/swift/SIL/SILValue.h

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

lib/SILOptimizer/Mandatory/MoveOnlyWrappedTypeEliminator.cpp

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

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

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

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

330328
if (trivialOnly &&

0 commit comments

Comments
 (0)