Skip to content

Commit 37d60a0

Browse files
committed
[move-only] Rename mark_must_check -> mark_unresolved_non_copyable_value.
I was originally hoping to reuse mark_must_check for multiple types of checkers. In practice, this is not what happened... so giving it a name specifically to do with non copyable types makes more sense and makes the code clearer. Just a pure rename.
1 parent 52c732f commit 37d60a0

File tree

85 files changed

+1106
-974
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+1106
-974
lines changed

SwiftCompilerSources/Sources/Optimizer/Utilities/WalkUtils.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ extension ValueDefUseWalker {
350350
}
351351
case is BeginBorrowInst, is CopyValueInst, is MoveValueInst,
352352
is UpcastInst, is UncheckedRefCastInst, is EndCOWMutationInst,
353-
is RefToBridgeObjectInst, is BridgeObjectToRefInst, is MarkMustCheckInst:
353+
is RefToBridgeObjectInst, is BridgeObjectToRefInst, is MarkUnresolvedNonCopyableValueInst:
354354
return walkDownUses(ofValue: (instruction as! SingleValueInstruction), path: path)
355355
case let mdi as MarkDependenceInst:
356356
if operand.index == 0 {
@@ -492,7 +492,7 @@ extension AddressDefUseWalker {
492492
return walkDownUses(ofAddress: ia, path: subPath.push(.anyIndexedElement, index: 0))
493493
}
494494
return walkDownUses(ofAddress: ia, path: path)
495-
case let mmc as MarkMustCheckInst:
495+
case let mmc as MarkUnresolvedNonCopyableValueInst:
496496
return walkDownUses(ofAddress: mmc, path: path)
497497
case let ba as BeginAccessInst:
498498
// Don't treat `end_access` as leaf-use. Just ignore it.
@@ -656,7 +656,7 @@ extension ValueUseDefWalker {
656656
return walkUp(value: oer.existential, path: path.push(.existential, index: 0))
657657
case is BeginBorrowInst, is CopyValueInst, is MoveValueInst,
658658
is UpcastInst, is UncheckedRefCastInst, is EndCOWMutationInst,
659-
is RefToBridgeObjectInst, is BridgeObjectToRefInst, is MarkMustCheckInst:
659+
is RefToBridgeObjectInst, is BridgeObjectToRefInst, is MarkUnresolvedNonCopyableValueInst:
660660
return walkUp(value: (def as! Instruction).operands[0].value, path: path)
661661
case let arg as BlockArgument:
662662
if arg.isPhiArgument {
@@ -743,7 +743,7 @@ extension AddressUseDefWalker {
743743
path: path.push(.enumCase, index: (def as! EnumInstruction).caseIndex))
744744
case is InitExistentialAddrInst, is OpenExistentialAddrInst:
745745
return walkUp(address: (def as! Instruction).operands[0].value, path: path.push(.existential, index: 0))
746-
case is BeginAccessInst, is MarkMustCheckInst:
746+
case is BeginAccessInst, is MarkUnresolvedNonCopyableValueInst:
747747
return walkUp(address: (def as! Instruction).operands[0].value, path: path)
748748
case let ia as IndexAddrInst:
749749
if let idx = ia.constantSmallIndex {

SwiftCompilerSources/Sources/SIL/Instruction.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ final public class IsUniqueInst : SingleValueInstruction, UnaryInstruction {}
816816
final public class IsEscapingClosureInst : SingleValueInstruction, UnaryInstruction {}
817817

818818
final public
819-
class MarkMustCheckInst : SingleValueInstruction, UnaryInstruction {}
819+
class MarkUnresolvedNonCopyableValueInst : SingleValueInstruction, UnaryInstruction {}
820820

821821
final public class ObjectInst : SingleValueInstruction {
822822
public var baseOperands: OperandArray {

SwiftCompilerSources/Sources/SIL/Registration.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public func registerSILClasses() {
8080
register(UncheckedRefCastInst.self)
8181
register(UncheckedAddrCastInst.self)
8282
register(UncheckedTrivialBitCastInst.self)
83-
register(MarkMustCheckInst.self)
83+
register(MarkUnresolvedNonCopyableValueInst.self)
8484
register(ObjectInst.self)
8585
register(RawPointerToRefInst.self)
8686
register(AddressToPointerInst.self)

docs/SIL.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2817,7 +2817,7 @@ which codegens to the following SIL::
28172817
bb0(%0 : @noImplicitCopy $Klass):
28182818
%1 = copyable_to_moveonlywrapper [guaranteed] %0 : $@moveOnly Klass
28192819
%2 = copy_value %1 : $@moveOnly Klass
2820-
%3 = mark_must_check [no_consume_or_assign] %2 : $@moveOnly Klass
2820+
%3 = mark_unresolved_non_copyable_value [no_consume_or_assign] %2 : $@moveOnly Klass
28212821
debug_value %3 : $@moveOnly Klass, let, name "x", argno 1
28222822
%4 = begin_borrow %3 : $@moveOnly Klass
28232823
%5 = function_ref @$s4test5KlassC11doSomethingyyF : $@convention(method) (@guaranteed Klass) -> ()
@@ -2887,7 +2887,7 @@ Today this codegens to the following Swift::
28872887
bb0(%0 : @noImplicitCopy $Int):
28882888
%1 = copyable_to_moveonlywrapper [owned] %0 : $Int
28892889
%2 = move_value [lexical] %1 : $@moveOnly Int
2890-
%3 = mark_must_check [consumable_and_assignable] %2 : $@moveOnly Int
2890+
%3 = mark_unresolved_non_copyable_value [consumable_and_assignable] %2 : $@moveOnly Int
28912891
%5 = begin_borrow %3 : $@moveOnly Int
28922892
%6 = begin_borrow %3 : $@moveOnly Int
28932893
%7 = function_ref @addIntegers : $@convention(method) (Int, Int Int.Type) -> Int
@@ -2946,7 +2946,7 @@ A hypothetical SILGen for this code is as follows::
29462946
%3 = begin_borrow [lexical] %0 : $Klass
29472947
%4 = copy_value %3 : $Klass
29482948
%5 = copyable_to_moveonlywrapper [owned] %4 : $Klass
2949-
%6 = mark_must_check [consumable_and_assignable] %5 : $@moveOnly Klass
2949+
%6 = mark_unresolved_non_copyable_value [consumable_and_assignable] %5 : $@moveOnly Klass
29502950
debug_value %6 : $@moveOnly Klass, let, name "value"
29512951
%8 = begin_borrow %6 : $@moveOnly Klass
29522952
%9 = copy_value %8 : $@moveOnly Klass
@@ -8484,19 +8484,19 @@ The remaining components identify the SIL differentiability witness:
84848484
Optimizer Dataflow Marker Instructions
84858485
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
84868486

8487-
mark_must_check
8487+
mark_unresolved_non_copyable_value
84888488
```````````````
84898489
::
84908490

8491-
sil-instruction ::= 'mark_must_check'
8491+
sil-instruction ::= 'mark_unresolved_non_copyable_value'
84928492
'[' sil-optimizer-analysis-marker ']'
84938493

84948494
sil-optimizer-analysis-marker ::= 'consumable_and_assignable'
84958495
::= 'no_consume_or_assign'
84968496

84978497
A canary value inserted by a SIL generating frontend to signal to the move
84988498
checker to check a specific value. Valid only in Raw SIL. The relevant checkers
8499-
should remove the `mark_must_check`_ instruction after successfully running the
8499+
should remove the `mark_unresolved_non_copyable_value`_ instruction after successfully running the
85008500
relevant diagnostic. The idea here is that instead of needing to introduce
85018501
multiple "flagging" instructions for the optimizer, we can just reuse this one
85028502
instruction by varying the kind.

include/swift/AST/DiagnosticsParse.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ ERROR(sil_movevalue_invalid_optional_attribute,none,
680680
ERROR(sil_markmustcheck_invalid_attribute,none,
681681
"Attribute '[%0]' can not be applied to mark_value_as_moveonly", (StringRef))
682682
ERROR(sil_markmustcheck_requires_attribute,none,
683-
"mark_must_check requires an attribute like 'noImplicitCopy'", ())
683+
"mark_unresolved_non_copyable_value requires an attribute like 'noImplicitCopy'", ())
684684
ERROR(sil_moveonlytocopyable_invalid_attribute,none,
685685
"Attribute '[%0]' can not be applied to moveonlywrapper_to_copyable", (StringRef))
686686
ERROR(sil_moveonlytocopyable_requires_attribute,none,

include/swift/SIL/AddressWalker.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ TransitiveAddressWalker<Impl>::walk(SILValue projectedAddress) && {
217217
isa<InitExistentialAddrInst>(user) || isa<InitEnumDataAddrInst>(user) ||
218218
isa<BeginAccessInst>(user) || isa<TailAddrInst>(user) ||
219219
isa<IndexAddrInst>(user) || isa<StoreBorrowInst>(user) ||
220-
isa<UncheckedAddrCastInst>(user) || isa<MarkMustCheckInst>(user) ||
220+
isa<UncheckedAddrCastInst>(user) ||
221+
isa<MarkUnresolvedNonCopyableValueInst>(user) ||
221222
isa<MarkUninitializedInst>(user) || isa<DropDeinitInst>(user) ||
222223
isa<ProjectBlockStorageInst>(user) || isa<UpcastInst>(user) ||
223224
isa<TuplePackElementAddrInst>(user) ||

include/swift/SIL/MemAccessUtils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1634,7 +1634,7 @@ inline bool isAccessStorageIdentityCast(SingleValueInstruction *svi) {
16341634

16351635
// Simply pass-thru the incoming address.
16361636
case SILInstructionKind::MarkUninitializedInst:
1637-
case SILInstructionKind::MarkMustCheckInst:
1637+
case SILInstructionKind::MarkUnresolvedNonCopyableValueInst:
16381638
case SILInstructionKind::DropDeinitInst:
16391639
case SILInstructionKind::MarkUnresolvedReferenceBindingInst:
16401640
case SILInstructionKind::MarkDependenceInst:

include/swift/SIL/SILBuilder.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,11 +1439,11 @@ class SILBuilder {
14391439
getSILDebugLocation(loc), srcAddr, takeAddr));
14401440
}
14411441

1442-
MarkMustCheckInst *
1443-
createMarkMustCheckInst(SILLocation loc, SILValue src,
1444-
MarkMustCheckInst::CheckKind kind) {
1445-
return insert(new (getModule())
1446-
MarkMustCheckInst(getSILDebugLocation(loc), src, kind));
1442+
MarkUnresolvedNonCopyableValueInst *createMarkUnresolvedNonCopyableValueInst(
1443+
SILLocation loc, SILValue src,
1444+
MarkUnresolvedNonCopyableValueInst::CheckKind kind) {
1445+
return insert(new (getModule()) MarkUnresolvedNonCopyableValueInst(
1446+
getSILDebugLocation(loc), src, kind));
14471447
}
14481448

14491449
MarkUnresolvedReferenceBindingInst *createMarkUnresolvedReferenceBindingInst(

include/swift/SIL/SILCloner.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1949,9 +1949,10 @@ void SILCloner<ImplClass>::visitDropDeinitInst(DropDeinitInst *Inst) {
19491949
}
19501950

19511951
template <typename ImplClass>
1952-
void SILCloner<ImplClass>::visitMarkMustCheckInst(MarkMustCheckInst *Inst) {
1952+
void SILCloner<ImplClass>::visitMarkUnresolvedNonCopyableValueInst(
1953+
MarkUnresolvedNonCopyableValueInst *Inst) {
19531954
getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope()));
1954-
auto *MVI = getBuilder().createMarkMustCheckInst(
1955+
auto *MVI = getBuilder().createMarkUnresolvedNonCopyableValueInst(
19551956
getOpLocation(Inst->getLoc()), getOpValue(Inst->getOperand()),
19561957
Inst->getCheckKind());
19571958
recordClonedInstruction(Inst, MVI);

include/swift/SIL/SILInstruction.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8302,9 +8302,10 @@ class MarkUnresolvedMoveAddrInst
83028302
/// diagnostic based semantic checker. Example: no implicit copy. Only legal in
83038303
/// Raw SIL so that we can guarantee canonical SIL has had all SSA based
83048304
/// checking by the checkers that rely upon this instruction.
8305-
class MarkMustCheckInst
8306-
: public UnaryInstructionBase<SILInstructionKind::MarkMustCheckInst,
8307-
OwnershipForwardingSingleValueInstruction> {
8305+
class MarkUnresolvedNonCopyableValueInst
8306+
: public UnaryInstructionBase<
8307+
SILInstructionKind::MarkUnresolvedNonCopyableValueInst,
8308+
OwnershipForwardingSingleValueInstruction> {
83088309
friend class SILBuilder;
83098310

83108311
public:
@@ -8341,13 +8342,14 @@ class MarkMustCheckInst
83418342
private:
83428343
CheckKind kind;
83438344

8344-
MarkMustCheckInst(SILDebugLocation DebugLoc, SILValue operand,
8345-
CheckKind checkKind)
8345+
MarkUnresolvedNonCopyableValueInst(SILDebugLocation DebugLoc,
8346+
SILValue operand, CheckKind checkKind)
83468347
: UnaryInstructionBase(DebugLoc, operand, operand->getType(),
83478348
operand->getOwnershipKind()),
83488349
kind(checkKind) {
83498350
assert(operand->getType().isMoveOnly() &&
8350-
"mark_must_check can only take a move only typed value");
8351+
"mark_unresolved_non_copyable_value can only take a move only typed "
8352+
"value");
83518353
}
83528354

83538355
public:
@@ -10592,7 +10594,7 @@ OwnershipForwardingSingleValueInstruction::classof(SILInstructionKind kind) {
1059210594
case SILInstructionKind::TupleInst:
1059310595
case SILInstructionKind::LinearFunctionInst:
1059410596
case SILInstructionKind::DifferentiableFunctionInst:
10595-
case SILInstructionKind::MarkMustCheckInst:
10597+
case SILInstructionKind::MarkUnresolvedNonCopyableValueInst:
1059610598
case SILInstructionKind::MarkUnresolvedReferenceBindingInst:
1059710599
case SILInstructionKind::ConvertFunctionInst:
1059810600
case SILInstructionKind::UpcastInst:

0 commit comments

Comments
 (0)