Skip to content

Commit 7c06d4f

Browse files
committed
Remove the pinning built-ins.
They are not used anymore after removing the pinning adressors.
1 parent 192431b commit 7c06d4f

File tree

11 files changed

+1
-376
lines changed

11 files changed

+1
-376
lines changed

include/swift/AST/Builtins.def

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -166,14 +166,6 @@ BUILTIN_SIL_OPERATION(Release, "release", Special)
166166
/// autorelease: T -> ()
167167
BUILTIN_SIL_OPERATION(Autorelease, "autorelease", Special)
168168

169-
// The pin operations return T only because Optional isn't intrinsic.
170-
171-
/// tryPin: Builtin.NativeObject -> T
172-
BUILTIN_SIL_OPERATION(TryPin, "tryPin", Special)
173-
174-
/// unpin: T -> ()
175-
BUILTIN_SIL_OPERATION(Unpin, "unpin", Special)
176-
177169
/// Load has type (Builtin.RawPointer) -> T
178170
BUILTIN_SIL_OPERATION(Load, "load", Special)
179171

@@ -359,21 +351,12 @@ BUILTIN_SIL_OPERATION(FixLifetime, "fixLifetime", Special)
359351
/// references with a strong reference count of one.
360352
BUILTIN_SIL_OPERATION(IsUnique, "isUnique", Special)
361353

362-
/// isUniqueOrPinned : <T> (inout T[?]) -> Int1
363-
///
364-
/// This builtin has the same semantics as isUnique except that it also returns
365-
/// true if the object is marked pinned regardless of the reference count. This
366-
/// allows for simultaneous non-structural modification of multiple subobjects.
367-
BUILTIN_SIL_OPERATION(IsUniqueOrPinned, "isUniqueOrPinned", Special)
368-
369354
/// IsUnique_native : <T> (inout T[?]) -> Int1
370355
///
371356
/// These variants of isUnique implicitly cast to a non-null NativeObject before
372357
/// checking uniqueness. This allows an object reference statically typed as
373358
/// BridgeObject to be treated as a native object by the runtime.
374359
BUILTIN_SIL_OPERATION(IsUnique_native, "isUnique_native", Special)
375-
BUILTIN_SIL_OPERATION(IsUniqueOrPinned_native, "isUniqueOrPinned_native",
376-
Special)
377360

378361
/// bindMemory : <T> (Builtin.RawPointer, Builtin.Word, T.Type) -> ()
379362
BUILTIN_SIL_OPERATION(BindMemory, "bindMemory", Special)

lib/AST/Builtins.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,15 +1141,6 @@ static ValueDecl *getOnceOperation(ASTContext &Context,
11411141
}
11421142
}
11431143

1144-
static ValueDecl *getTryPinOperation(ASTContext &ctx, Identifier name) {
1145-
// <T> NativeObject -> T
1146-
// (T must actually be NativeObject?)
1147-
BuiltinGenericSignatureBuilder builder(ctx);
1148-
builder.addParameter(makeConcrete(ctx.TheNativeObjectType));
1149-
builder.setResult(makeGenericParam());
1150-
return builder.build(name);
1151-
}
1152-
11531144
/// An array of the overloaded builtin kinds.
11541145
static const OverloadedBuiltinKind OverloadedBuiltinKinds[] = {
11551146
OverloadedBuiltinKind::None,
@@ -1687,13 +1678,9 @@ ValueDecl *swift::getBuiltinValueDecl(ASTContext &Context, Identifier Id) {
16871678
#include "swift/AST/Builtins.def"
16881679
return getCastOperation(Context, Id, BV, Types);
16891680

1690-
case BuiltinValueKind::TryPin:
1691-
return getTryPinOperation(Context, Id);
1692-
16931681
case BuiltinValueKind::Retain:
16941682
case BuiltinValueKind::Release:
16951683
case BuiltinValueKind::Autorelease:
1696-
case BuiltinValueKind::Unpin:
16971684
if (!Types.empty()) return nullptr;
16981685
return getRefCountingOperation(Context, Id);
16991686

@@ -1729,9 +1716,7 @@ ValueDecl *swift::getBuiltinValueDecl(ASTContext &Context, Identifier Id) {
17291716
return getTransferArrayOperation(Context, Id);
17301717

17311718
case BuiltinValueKind::IsUnique:
1732-
case BuiltinValueKind::IsUniqueOrPinned:
17331719
case BuiltinValueKind::IsUnique_native:
1734-
case BuiltinValueKind::IsUniqueOrPinned_native:
17351720
if (!Types.empty()) return nullptr;
17361721
return getIsUniqueOperation(Context, Id);
17371722

lib/SIL/ValueOwnershipKindClassifier.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ CONSTANT_OWNERSHIP_INST(Owned, CopyBlockWithoutEscaping)
5656
CONSTANT_OWNERSHIP_INST(Owned, CopyValue)
5757
CONSTANT_OWNERSHIP_INST(Owned, KeyPath)
5858
CONSTANT_OWNERSHIP_INST(Owned, PartialApply)
59-
CONSTANT_OWNERSHIP_INST(Owned, StrongPin)
6059
CONSTANT_OWNERSHIP_INST(Owned, InitExistentialValue)
6160
CONSTANT_OWNERSHIP_INST(Owned, GlobalValue) // TODO: is this correct?
6261

@@ -89,7 +88,6 @@ CONSTANT_OWNERSHIP_INST(Trivial, InitExistentialAddr)
8988
CONSTANT_OWNERSHIP_INST(Trivial, InitExistentialMetatype)
9089
CONSTANT_OWNERSHIP_INST(Trivial, IntegerLiteral)
9190
CONSTANT_OWNERSHIP_INST(Trivial, IsUnique)
92-
CONSTANT_OWNERSHIP_INST(Trivial, IsUniqueOrPinned)
9391
CONSTANT_OWNERSHIP_INST(Trivial, IsEscapingClosure)
9492
CONSTANT_OWNERSHIP_INST(Trivial, MarkUninitializedBehavior)
9593
CONSTANT_OWNERSHIP_INST(Trivial, Metatype)

lib/SILGen/SILGenBuiltin.cpp

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -101,57 +101,6 @@ static ManagedValue emitBuiltinAutorelease(SILGenFunction &SGF,
101101
return ManagedValue::forUnmanaged(SGF.emitEmptyTuple(loc));
102102
}
103103

104-
static bool requireIsOptionalNativeObject(SILGenFunction &SGF,
105-
SILLocation loc,
106-
Type type) {
107-
if (auto valueType = type->getOptionalObjectType())
108-
if (valueType->is<BuiltinNativeObjectType>())
109-
return true;
110-
111-
SGF.SGM.diagnose(loc, diag::invalid_sil_builtin,
112-
"type of pin handle must be Optional<Builtin.NativeObject>");
113-
return false;
114-
}
115-
116-
static ManagedValue emitBuiltinTryPin(SILGenFunction &SGF,
117-
SILLocation loc,
118-
SubstitutionMap subs,
119-
ArrayRef<ManagedValue> args,
120-
SGFContext C) {
121-
assert(args.size() == 1);
122-
123-
auto argTy = subs.getReplacementTypes()[0];
124-
if (!requireIsOptionalNativeObject(SGF, loc, argTy)) {
125-
return SGF.emitUndef(loc, argTy);
126-
}
127-
128-
// The value was produced at +1, but pinning is only a conditional
129-
// retain, so we have to leave the cleanup in place. TODO: try to
130-
// emit the argument at +0.
131-
SILValue result =
132-
SGF.B.createStrongPin(loc, args[0].getValue(), SGF.B.getDefaultAtomicity());
133-
134-
// The handle, if non-null, is effectively +1.
135-
return SGF.emitManagedRValueWithCleanup(result);
136-
}
137-
138-
static ManagedValue emitBuiltinUnpin(SILGenFunction &SGF,
139-
SILLocation loc,
140-
SubstitutionMap subs,
141-
ArrayRef<ManagedValue> args,
142-
SGFContext C) {
143-
assert(args.size() == 1);
144-
145-
auto argTy = subs.getReplacementTypes()[0];
146-
if (requireIsOptionalNativeObject(SGF, loc, argTy)) {
147-
// Unpinning takes responsibility for the +1 handle.
148-
SGF.B.createStrongUnpin(loc, args[0].ensurePlusOne(SGF, loc).forward(SGF),
149-
SGF.B.getDefaultAtomicity());
150-
}
151-
152-
return ManagedValue::forUnmanaged(SGF.emitEmptyTuple(loc));
153-
}
154-
155104
/// Specialized emitter for Builtin.load and Builtin.take.
156105
static ManagedValue emitBuiltinLoadOrTake(SILGenFunction &SGF,
157106
SILLocation loc,
@@ -929,22 +878,6 @@ static ManagedValue emitBuiltinIsUnique(SILGenFunction &SGF,
929878
SGF.B.createIsUnique(loc, args[0].getValue()));
930879
}
931880

932-
static ManagedValue
933-
emitBuiltinIsUniqueOrPinned(SILGenFunction &SGF,
934-
SILLocation loc,
935-
SubstitutionMap subs,
936-
ArrayRef<ManagedValue> args,
937-
SGFContext C) {
938-
assert(subs.getReplacementTypes().size() == 1 &&
939-
"isUnique should have a single substitution");
940-
assert(args.size() == 1 && "isUnique should have a single argument");
941-
assert((args[0].getType().isAddress() && !args[0].hasCleanup()) &&
942-
"Builtin.isUnique takes an address.");
943-
944-
return ManagedValue::forUnmanaged(
945-
SGF.B.createIsUniqueOrPinned(loc, args[0].getValue()));
946-
}
947-
948881
// This force-casts the incoming address to NativeObject assuming the caller has
949882
// performed all necessary checks. For example, this may directly cast a
950883
// single-payload enum to a NativeObject reference.
@@ -966,24 +899,6 @@ emitBuiltinIsUnique_native(SILGenFunction &SGF,
966899
return ManagedValue::forUnmanaged(result);
967900
}
968901

969-
static ManagedValue
970-
emitBuiltinIsUniqueOrPinned_native(SILGenFunction &SGF,
971-
SILLocation loc,
972-
SubstitutionMap subs,
973-
ArrayRef<ManagedValue> args,
974-
SGFContext C) {
975-
976-
assert(subs.getReplacementTypes().size() == 1 &&
977-
"isUniqueOrPinned_native should have one sub.");
978-
assert(args.size() == 1 && "isUniqueOrPinned_native should have one arg.");
979-
980-
auto ToType =
981-
SILType::getNativeObjectType(SGF.getASTContext()).getAddressType();
982-
auto toAddr = SGF.B.createUncheckedAddrCast(loc, args[0].getValue(), ToType);
983-
SILValue result = SGF.B.createIsUniqueOrPinned(loc, toAddr);
984-
return ManagedValue::forUnmanaged(result);
985-
}
986-
987902
static ManagedValue emitBuiltinBindMemory(SILGenFunction &SGF,
988903
SILLocation loc,
989904
SubstitutionMap subs,

stdlib/public/core/BridgeStorage.swift

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,6 @@ struct _BridgeStorage<
7878
return _isUnique(&rawValue)
7979
}
8080

81-
@inlinable // FIXME(sil-serialize-all)
82-
@inline(__always)
83-
public // @testable
84-
mutating func isUniquelyReferencedOrPinnedNative() -> Bool {
85-
return _isUniqueOrPinned(&rawValue)
86-
}
87-
8881
@inlinable // FIXME(sil-serialize-all)
8982
public // @testable
9083
var isNative: Bool {
@@ -139,14 +132,6 @@ struct _BridgeStorage<
139132
return _isUnique_native(&rawValue)
140133
}
141134

142-
@inlinable // FIXME(sil-serialize-all)
143-
@inline(__always)
144-
public // @testable
145-
mutating func isUniquelyReferencedOrPinned_native_noSpareBits() -> Bool {
146-
_sanityCheck(isNative)
147-
return _isUniqueOrPinned_native(&rawValue)
148-
}
149-
150135
@inlinable // FIXME(sil-serialize-all)
151136
public // @testable
152137
var objCInstance: ObjC {

stdlib/public/core/Builtin.swift

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ func _getSuperclass(_ t: Any.Type) -> AnyClass? {
638638
// value... thus bumping the reference count and disturbing the
639639
// result we are trying to observe, Dr. Heisenberg!
640640
//
641-
// _isUnique and _isUniquePinned cannot be made public or the compiler
641+
// _isUnique cannot be made public or the compiler
642642
// will attempt to generate generic code for the transparent function
643643
// and type checking will fail.
644644

@@ -648,12 +648,6 @@ internal func _isUnique<T>(_ object: inout T) -> Bool {
648648
return Bool(Builtin.isUnique(&object))
649649
}
650650

651-
/// Returns `true` if `object` is uniquely referenced or pinned.
652-
@usableFromInline @_transparent
653-
internal func _isUniqueOrPinned<T>(_ object: inout T) -> Bool {
654-
return Bool(Builtin.isUniqueOrPinned(&object))
655-
}
656-
657651
/// Returns `true` if `object` is uniquely referenced.
658652
/// This provides sanity checks on top of the Builtin.
659653
@_transparent
@@ -670,21 +664,6 @@ func _isUnique_native<T>(_ object: inout T) -> Bool {
670664
return Bool(Builtin.isUnique_native(&object))
671665
}
672666

673-
/// Returns `true` if `object` is uniquely referenced or pinned.
674-
/// This provides sanity checks on top of the Builtin.
675-
@_transparent
676-
public // @testable
677-
func _isUniqueOrPinned_native<T>(_ object: inout T) -> Bool {
678-
// This could be a bridge object, single payload enum, or plain old
679-
// reference. Any case it's non pointer bits must be zero.
680-
_sanityCheck(
681-
(_bitPattern(Builtin.reinterpretCast(object)) & _objectPointerSpareBits)
682-
== 0)
683-
_sanityCheck(_usesNativeSwiftReferenceCounting(
684-
type(of: Builtin.reinterpretCast(object) as AnyObject)))
685-
return Bool(Builtin.isUniqueOrPinned_native(&object))
686-
}
687-
688667
/// Returns `true` if type is a POD type. A POD type is a type that does not
689668
/// require any special handling on copying or destruction.
690669
@_transparent

stdlib/public/core/ManagedBuffer.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -544,11 +544,6 @@ public func isKnownUniquelyReferenced<T : AnyObject>(_ object: inout T) -> Bool
544544
return _isUnique(&object)
545545
}
546546

547-
@inlinable
548-
internal func _isKnownUniquelyReferencedOrPinned<T : AnyObject>(_ object: inout T) -> Bool {
549-
return _isUniqueOrPinned(&object)
550-
}
551-
552547
/// Returns a Boolean value indicating whether the given object is known to
553548
/// have a single strong reference.
554549
///

test/IRGen/builtins.swift

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -615,27 +615,6 @@ func isUnique(_ ref: inout Builtin.NativeObject) -> Bool {
615615
return Builtin.isUnique(&ref)
616616
}
617617

618-
// native pinned
619-
// CHECK-LABEL: define hidden {{.*}}i1 @"$S8builtins16isUniqueOrPinnedyBi1_BoSgzF"({{%.*}}* nocapture dereferenceable({{.*}})) {{.*}} {
620-
// CHECK-NEXT: entry:
621-
// CHECK-NEXT: bitcast [[BUILTIN_NATIVE_OBJECT_TY]]* %0 to %swift.refcounted**
622-
// CHECK-NEXT: load %swift.refcounted*, %swift.refcounted** %1
623-
// CHECK-NEXT: call i1 @swift_isUniquelyReferencedOrPinned_native(%swift.refcounted* %2)
624-
// CHECK-NEXT: ret i1 %3
625-
func isUniqueOrPinned(_ ref: inout Builtin.NativeObject?) -> Bool {
626-
return Builtin.isUniqueOrPinned(&ref)
627-
}
628-
629-
// native pinned nonNull
630-
// CHECK-LABEL: define hidden {{.*}}i1 @"$S8builtins16isUniqueOrPinnedyBi1_BozF"(%swift.refcounted** nocapture dereferenceable({{.*}})) {{.*}} {
631-
// CHECK-NEXT: entry:
632-
// CHECK-NEXT: load %swift.refcounted*, %swift.refcounted** %0
633-
// CHECK-NEXT: call i1 @swift_isUniquelyReferencedOrPinned_nonNull_native(%swift.refcounted* %1)
634-
// CHECK-NEXT: ret i1 %2
635-
func isUniqueOrPinned(_ ref: inout Builtin.NativeObject) -> Bool {
636-
return Builtin.isUniqueOrPinned(&ref)
637-
}
638-
639618
// CHECK: define hidden {{.*}}void @"$S8builtins27acceptsBuiltinUnknownObjectyyBOSgzF"([[BUILTIN_UNKNOWN_OBJECT_TY:%.*]]* nocapture dereferenceable({{.*}})) {{.*}} {
640619
func acceptsBuiltinUnknownObject(_ ref: inout Builtin.UnknownObject?) {}
641620

@@ -663,18 +642,6 @@ func isUnique(_ ref: inout Builtin.UnknownObject) -> Bool {
663642
return Builtin.isUnique(&ref)
664643
}
665644

666-
// ObjC pinned nonNull
667-
// CHECK-LABEL: define hidden {{.*}}i1 @"$S8builtins16isUniqueOrPinnedyBi1_BOzF"
668-
// CHECK-SAME: ([[UNKNOWN_OBJECT]]** nocapture dereferenceable({{.*}})) {{.*}} {
669-
// CHECK-NEXT: entry:
670-
// CHECK-NEXT: load [[UNKNOWN_OBJECT]]*, [[UNKNOWN_OBJECT]]** %0
671-
// CHECK-native-NEXT: call i1 @swift_isUniquelyReferencedOrPinned_nonNull_native([[UNKNOWN_OBJECT]]* %1)
672-
// CHECK-objc-NEXT: call i1 @swift_isUniquelyReferencedOrPinnedNonObjC_nonNull([[UNKNOWN_OBJECT]]* %1)
673-
// CHECK-NEXT: ret i1 %2
674-
func isUniqueOrPinned(_ ref: inout Builtin.UnknownObject) -> Bool {
675-
return Builtin.isUniqueOrPinned(&ref)
676-
}
677-
678645
// BridgeObject nonNull
679646
// CHECK-LABEL: define hidden {{.*}}i1 @"$S8builtins8isUniqueyBi1_BbzF"(%swift.bridge** nocapture dereferenceable({{.*}})) {{.*}} {
680647
// CHECK-NEXT: entry:
@@ -685,16 +652,6 @@ func isUnique(_ ref: inout Builtin.BridgeObject) -> Bool {
685652
return Builtin.isUnique(&ref)
686653
}
687654

688-
// Bridge pinned nonNull
689-
// CHECK-LABEL: define hidden {{.*}}i1 @"$S8builtins16isUniqueOrPinnedyBi1_BbzF"(%swift.bridge** nocapture dereferenceable({{.*}})) {{.*}} {
690-
// CHECK-NEXT: entry:
691-
// CHECK-NEXT: load %swift.bridge*, %swift.bridge** %0
692-
// CHECK-NEXT: call i1 @swift_isUniquelyReferencedOrPinnedNonObjC_nonNull_bridgeObject(%swift.bridge* %1)
693-
// CHECK-NEXT: ret i1 %2
694-
func isUniqueOrPinned(_ ref: inout Builtin.BridgeObject) -> Bool {
695-
return Builtin.isUniqueOrPinned(&ref)
696-
}
697-
698655
// BridgeObject nonNull
699656
// CHECK-LABEL: define hidden {{.*}}i1 @"$S8builtins15isUnique_nativeyBi1_BbzF"(%swift.bridge** nocapture dereferenceable({{.*}})) {{.*}} {
700657
// CHECK-NEXT: entry:
@@ -706,17 +663,6 @@ func isUnique_native(_ ref: inout Builtin.BridgeObject) -> Bool {
706663
return Builtin.isUnique_native(&ref)
707664
}
708665

709-
// Bridge pinned nonNull
710-
// CHECK-LABEL: define hidden {{.*}}i1 @"$S8builtins23isUniqueOrPinned_nativeyBi1_BbzF"(%swift.bridge** nocapture dereferenceable({{.*}})) {{.*}} {
711-
// CHECK-NEXT: entry:
712-
// CHECK-NEXT: bitcast %swift.bridge** %0 to %swift.refcounted**
713-
// CHECK-NEXT: load %swift.refcounted*, %swift.refcounted** %1
714-
// CHECK-NEXT: call i1 @swift_isUniquelyReferencedOrPinned_nonNull_native(%swift.refcounted* %2)
715-
// CHECK-NEXT: ret i1 %3
716-
func isUniqueOrPinned_native(_ ref: inout Builtin.BridgeObject) -> Bool {
717-
return Builtin.isUniqueOrPinned_native(&ref)
718-
}
719-
720666
// ImplicitlyUnwrappedOptional argument to isUnique.
721667
// CHECK-LABEL: define hidden {{.*}}i1 @"$S8builtins11isUniqueIUOyBi1_BoSgzF"(%{{.*}}* nocapture dereferenceable({{.*}})) {{.*}} {
722668
// CHECK-NEXT: entry:

0 commit comments

Comments
 (0)