Skip to content

Commit 46bfebc

Browse files
authored
Merge pull request #18922 from eeckstein/remove-pinning
Remove the Array pinning addressor and all the pinning instructions in SIL
2 parents 5dfeb4c + 99a9ed5 commit 46bfebc

File tree

73 files changed

+23
-1765
lines changed

Some content is hidden

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

73 files changed

+23
-1765
lines changed

docs/ABI/Mangling.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ Entities
232232
ADDRESSOR-KIND ::= 'u' // unsafe addressor (no owner)
233233
ADDRESSOR-KIND ::= 'O' // owning addressor (non-native owner)
234234
ADDRESSOR-KIND ::= 'o' // owning addressor (native owner)
235-
ADDRESSOR-KIND ::= 'p' // pinning addressor (native owner)
235+
ADDRESSOR-KIND ::= 'p' // pinning addressor (native owner), not used anymore
236236

237237
decl-name ::= identifier
238238
decl-name ::= identifier 'L' INDEX // locally-discriminated declaration

docs/ARCOptimization.rst

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ Reference Counting Instructions
3838
- fix_lifetime
3939
- mark_dependence
4040
- is_unique
41-
- is_unique_or_pinned
4241
- copy_block
4342

4443
Memory Behavior of ARC Operations
@@ -348,15 +347,10 @@ static argument type is optional, then a null check is also performed.
348347
Thus, is_unique only returns true for non-null, native Swift object
349348
references with a strong reference count of one.
350349

351-
is_unique_or_pinned has the same semantics as is_unique except that it
352-
also returns true if the object is marked pinned (by strong_pin)
353-
regardless of the reference count. This allows for simultaneous
354-
non-structural modification of multiple subobjects.
355-
356350
Builtin.isUnique
357351
----------------
358352

359-
Builtin.isUnique and Builtin.isUniqueOrPinned give the standard
353+
Builtin.isUnique gives the standard
360354
library access to optimization safe uniqueness checking. Because the
361355
type of reference check is derived from the builtin argument's static
362356
type, the most efficient check is automatically generated. However, in
@@ -367,7 +361,6 @@ additional pointer bit mask and dynamic class lookup to be bypassed in
367361
these cases:
368362

369363
- isUnique_native : <T> (inout T[?]) -> Int1
370-
- isUniqueOrPinned_native : <T> (inout T[?]) -> Int1
371364

372365
These builtins perform an implicit cast to NativeObject before
373366
checking uniqueness. There's no way at SIL level to cast the address

docs/SIL.rst

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2881,16 +2881,6 @@ The second operand may have either object or address type. In the
28812881
latter case, the dependency is on the current value stored in the
28822882
address.
28832883

2884-
strong_pin
2885-
``````````
2886-
2887-
TODO: Fill me in!
2888-
2889-
strong_unpin
2890-
````````````
2891-
2892-
TODO: Fill me in!
2893-
28942884
is_unique
28952885
`````````
28962886

@@ -2909,22 +2899,6 @@ strong reference count is greater than 1.
29092899
A discussion of the semantics can be found here:
29102900
:ref:`arcopts.is_unique`.
29112901

2912-
is_unique_or_pinned
2913-
```````````````````
2914-
2915-
::
2916-
2917-
sil-instruction ::= 'is_unique_or_pinned' sil-operand
2918-
2919-
%1 = is_unique_or_pinned %0 : $*T
2920-
// $T must be a reference-counted type
2921-
// %1 will be of type Builtin.Int1
2922-
2923-
Checks whether %0 is the address of either a unique reference to a
2924-
memory object or a reference to a pinned object. Returns 1 if the
2925-
strong reference count is 1 or the object has been marked pinned by
2926-
strong_pin.
2927-
29282902
is_escaping_closure
29292903
```````````````````
29302904

include/swift/AST/AccessorKinds.def

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ ACCESSOR(Address)
187187
IMMUTABLE_ADDRESSOR(Unsafe, unsafeAddress)
188188
IMMUTABLE_ADDRESSOR(Owning, addressWithOwner)
189189
IMMUTABLE_ADDRESSOR(NativeOwning, addressWithNativeOwner)
190-
IMMUTABLE_ADDRESSOR(NativePinning, addressWithPinnedNativeOwner)
191190

192191
/// This is a mutableAddress-family accessor: a function that is
193192
/// called when the storage is assigned to (like a setter) or
@@ -203,7 +202,6 @@ ACCESSOR(MutableAddress)
203202
MUTABLE_ADDRESSOR(Unsafe, unsafeMutableAddress)
204203
MUTABLE_ADDRESSOR(Owning, mutableAddressWithOwner)
205204
MUTABLE_ADDRESSOR(NativeOwning, mutableAddressWithNativeOwner)
206-
MUTABLE_ADDRESSOR(NativePinning, mutableAddressWithPinnedNativeOwner)
207205

208206
#ifdef LAST_ACCESSOR
209207
LAST_ACCESSOR(MutableAddress)

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)

include/swift/AST/StorageImpl.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ enum class AddressorKind : uint8_t {
5454
/// \brief This is an owning addressor; it returns a Builtin.NativeObject
5555
/// which should be released when the caller is done with the object.
5656
NativeOwning,
57-
/// \brief This is a pinning addressor; it returns a Builtin.NativeObject?
58-
/// which should be unpinned when the caller is done with the object.
59-
NativePinning,
6057
};
6158

6259
/// Whether an access to storage is for reading, writing, or both.

include/swift/SIL/SILBuilder.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,16 +1588,6 @@ class SILBuilder {
15881588
return insert(new (getModule()) StrongReleaseInst(
15891589
getSILDebugLocation(Loc), Operand, atomicity));
15901590
}
1591-
StrongPinInst *createStrongPin(SILLocation Loc, SILValue Operand,
1592-
Atomicity atomicity) {
1593-
return insert(new (getModule()) StrongPinInst(getSILDebugLocation(Loc),
1594-
Operand, atomicity));
1595-
}
1596-
StrongUnpinInst *createStrongUnpin(SILLocation Loc, SILValue Operand,
1597-
Atomicity atomicity) {
1598-
return insert(new (getModule()) StrongUnpinInst(getSILDebugLocation(Loc),
1599-
Operand, atomicity));
1600-
}
16011591

16021592
EndLifetimeInst *createEndLifetime(SILLocation Loc, SILValue Operand) {
16031593
return insert(new (getModule())
@@ -1632,12 +1622,6 @@ class SILBuilder {
16321622
return insert(new (getModule()) IsUniqueInst(getSILDebugLocation(Loc),
16331623
operand, Int1Ty));
16341624
}
1635-
IsUniqueOrPinnedInst *createIsUniqueOrPinned(SILLocation Loc,
1636-
SILValue value) {
1637-
auto Int1Ty = SILType::getBuiltinIntegerType(1, getASTContext());
1638-
return insert(new (getModule()) IsUniqueOrPinnedInst(
1639-
getSILDebugLocation(Loc), value, Int1Ty));
1640-
}
16411625
IsEscapingClosureInst *createIsEscapingClosure(SILLocation Loc,
16421626
SILValue operand,
16431627
unsigned VerificationType) {

include/swift/SIL/SILCloner.h

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1940,26 +1940,6 @@ void SILCloner<ImplClass>::visitMarkDependenceInst(MarkDependenceInst *Inst) {
19401940
getOpValue(Inst->getBase())));
19411941
}
19421942

1943-
template<typename ImplClass>
1944-
void
1945-
SILCloner<ImplClass>::visitStrongPinInst(StrongPinInst *Inst) {
1946-
getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope()));
1947-
doPostProcess(Inst,
1948-
getBuilder().createStrongPin(getOpLocation(Inst->getLoc()),
1949-
getOpValue(Inst->getOperand()),
1950-
Inst->getAtomicity()));
1951-
}
1952-
1953-
template<typename ImplClass>
1954-
void
1955-
SILCloner<ImplClass>::visitStrongUnpinInst(StrongUnpinInst *Inst) {
1956-
getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope()));
1957-
doPostProcess(Inst,
1958-
getBuilder().createStrongUnpin(getOpLocation(Inst->getLoc()),
1959-
getOpValue(Inst->getOperand()),
1960-
Inst->getAtomicity()));
1961-
}
1962-
19631943
template<typename ImplClass>
19641944
void
19651945
SILCloner<ImplClass>::visitStrongReleaseInst(StrongReleaseInst *Inst) {
@@ -1977,15 +1957,6 @@ void SILCloner<ImplClass>::visitIsUniqueInst(IsUniqueInst *Inst) {
19771957
getBuilder().createIsUnique(getOpLocation(Inst->getLoc()),
19781958
getOpValue(Inst->getOperand())));
19791959
}
1980-
template<typename ImplClass>
1981-
void
1982-
SILCloner<ImplClass>::
1983-
visitIsUniqueOrPinnedInst(IsUniqueOrPinnedInst *Inst) {
1984-
getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope()));
1985-
doPostProcess(Inst,
1986-
getBuilder().createIsUniqueOrPinned(getOpLocation(Inst->getLoc()),
1987-
getOpValue(Inst->getOperand())));
1988-
}
19891960
template <typename ImplClass>
19901961
void SILCloner<ImplClass>::visitIsEscapingClosureInst(
19911962
IsEscapingClosureInst *Inst) {

include/swift/SIL/SILInstruction.h

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -4777,60 +4777,6 @@ class SetDeallocatingInst
47774777
}
47784778
};
47794779

4780-
/// StrongPinInst - Ensure that the operand is retained and pinned, if
4781-
/// not by this operation then by some enclosing pin.
4782-
///
4783-
/// Transformations must not do anything which reorders pin and unpin
4784-
/// operations. (This should generally be straightforward, as pin and
4785-
/// unpin may be conservatively assumed to have arbitrary
4786-
/// side-effects.)
4787-
///
4788-
/// This can't be a RefCountingInst because it returns a value.
4789-
class StrongPinInst
4790-
: public UnaryInstructionBase<SILInstructionKind::StrongPinInst,
4791-
SingleValueInstruction>
4792-
{
4793-
public:
4794-
using Atomicity = RefCountingInst::Atomicity;
4795-
4796-
private:
4797-
friend SILBuilder;
4798-
4799-
StrongPinInst(SILDebugLocation DebugLoc, SILValue operand,
4800-
Atomicity atomicity);
4801-
4802-
public:
4803-
void setAtomicity(Atomicity flag) {
4804-
SILInstruction::Bits.StrongPinInst.atomicity = bool(flag);
4805-
}
4806-
void setNonAtomic() {
4807-
SILInstruction::Bits.StrongPinInst.atomicity = bool(Atomicity::NonAtomic);
4808-
}
4809-
void setAtomic() {
4810-
SILInstruction::Bits.StrongPinInst.atomicity = bool(Atomicity::Atomic);
4811-
}
4812-
Atomicity getAtomicity() const {
4813-
return Atomicity(SILInstruction::Bits.StrongPinInst.atomicity);
4814-
}
4815-
bool isNonAtomic() const { return getAtomicity() == Atomicity::NonAtomic; }
4816-
bool isAtomic() const { return getAtomicity() == Atomicity::Atomic; }
4817-
};
4818-
4819-
/// StrongUnpinInst - Given that the operand is the result of a
4820-
/// strong_pin instruction, unpin it.
4821-
class StrongUnpinInst
4822-
: public UnaryInstructionBase<SILInstructionKind::StrongUnpinInst,
4823-
RefCountingInst>
4824-
{
4825-
friend SILBuilder;
4826-
4827-
StrongUnpinInst(SILDebugLocation DebugLoc, SILValue operand,
4828-
Atomicity atomicity)
4829-
: UnaryInstructionBase(DebugLoc, operand) {
4830-
setAtomicity(atomicity);
4831-
}
4832-
};
4833-
48344780
/// ObjectInst - Represents a object value type.
48354781
///
48364782
/// This instruction can only appear at the end of a gobal variable's
@@ -6261,19 +6207,6 @@ class IsUniqueInst
62616207
: UnaryInstructionBase(DebugLoc, Operand, BoolTy) {}
62626208
};
62636209

6264-
/// Given an object reference, return true iff it is non-nil and either refers
6265-
/// to a native swift object with strong reference count of 1 or refers to a
6266-
/// pinned object (for simultaneous access to multiple subobjects).
6267-
class IsUniqueOrPinnedInst
6268-
: public UnaryInstructionBase<SILInstructionKind::IsUniqueOrPinnedInst,
6269-
SingleValueInstruction> {
6270-
friend SILBuilder;
6271-
6272-
IsUniqueOrPinnedInst(SILDebugLocation DebugLoc, SILValue Operand,
6273-
SILType BoolTy)
6274-
: UnaryInstructionBase(DebugLoc, Operand, BoolTy) {}
6275-
};
6276-
62776210
/// Given an escaping closure return true iff it has a non-nil context and the
62786211
/// context has a strong reference count greater than 1.
62796212
class IsEscapingClosureInst

include/swift/SIL/SILNodes.def

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -369,17 +369,13 @@ ABSTRACT_VALUE_AND_INST(SingleValueInstruction, ValueBase, SILInstruction)
369369
#include "swift/AST/ReferenceStorage.def"
370370
SINGLE_VALUE_INST(UncheckedOwnershipConversionInst, unchecked_ownership_conversion,
371371
SingleValueInstruction, MayHaveSideEffects, MayRelease)
372-
SINGLE_VALUE_INST(StrongPinInst, strong_pin,
373-
SingleValueInstruction, MayHaveSideEffects, DoesNotRelease)
374372

375373
// IsUnique does not actually write to memory but should be modeled
376374
// as such. Its operand is a pointer to an object reference. The
377375
// optimizer should not assume that the same object is pointed to after
378376
// the isUnique instruction. It appears to write a new object reference.
379377
SINGLE_VALUE_INST(IsUniqueInst, is_unique,
380378
SingleValueInstruction, MayHaveSideEffects, DoesNotRelease)
381-
SINGLE_VALUE_INST(IsUniqueOrPinnedInst, is_unique_or_pinned,
382-
SingleValueInstruction, MayHaveSideEffects, DoesNotRelease)
383379

384380
SINGLE_VALUE_INST(IsEscapingClosureInst, is_escaping_closure,
385381
SingleValueInstruction, MayRead, DoesNotRelease)
@@ -558,8 +554,6 @@ ABSTRACT_INST(RefCountingInst, SILInstruction)
558554
RefCountingInst, MayHaveSideEffects, DoesNotRelease)
559555
NON_VALUE_INST(StrongReleaseInst, strong_release,
560556
RefCountingInst, MayHaveSideEffects, MayRelease)
561-
NON_VALUE_INST(StrongUnpinInst, strong_unpin,
562-
RefCountingInst, MayHaveSideEffects, DoesNotRelease)
563557
NON_VALUE_INST(UnmanagedRetainValueInst, unmanaged_retain_value,
564558
RefCountingInst, MayHaveSideEffects, DoesNotRelease)
565559
NON_VALUE_INST(UnmanagedReleaseValueInst, unmanaged_release_value,

include/swift/SILOptimizer/PassManager/Passes.def

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,6 @@ PASS(PerformanceSILLinker, "performance-linker",
240240
"Deserialize all referenced SIL functions")
241241
PASS(RawSILInstLowering, "raw-sil-inst-lowering",
242242
"Lower all raw SIL instructions to canonical equivalents.")
243-
PASS(RemovePins, "remove-pins",
244-
"Remove SIL pin/unpin pairs")
245243
PASS(TempRValueOpt, "temp-rvalue-opt",
246244
"Remove short-lived immutable temporary copies")
247245
PASS(SideEffectsDumper, "side-effects-dump",

include/swift/Serialization/ModuleFormat.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const uint16_t VERSION_MAJOR = 0;
5555
/// describe what change you made. The content of this comment isn't important;
5656
/// it just ensures a conflict if two people change the module format.
5757
/// Don't worry about adhering to the 80-column limit for this line.
58-
const uint16_t VERSION_MINOR = 436; // Last change: without_actually_escaping.
58+
const uint16_t VERSION_MINOR = 437; // Last change: remove pinning
5959

6060
using DeclIDField = BCFixed<31>;
6161

@@ -286,7 +286,7 @@ using MetatypeRepresentationField = BCFixed<2>;
286286
// These IDs must \em not be renumbered or reordered without incrementing
287287
// VERSION_MAJOR.
288288
enum class AddressorKind : uint8_t {
289-
NotAddressor, Unsafe, Owning, NativeOwning, NativePinning
289+
NotAddressor, Unsafe, Owning, NativeOwning
290290
};
291291
using AddressorKindField = BCFixed<3>;
292292

lib/AST/ASTMangler.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ static StringRef getCodeForAccessorKind(AccessorKind kind,
7171
return "lO";
7272
case AddressorKind::NativeOwning:
7373
return "lo";
74-
case AddressorKind::NativePinning:
75-
return "lp";
7674
}
7775
llvm_unreachable("bad addressor kind");
7876
case AccessorKind::MutableAddress:
@@ -85,8 +83,6 @@ static StringRef getCodeForAccessorKind(AccessorKind kind,
8583
return "aO";
8684
case AddressorKind::NativeOwning:
8785
return "ao";
88-
case AddressorKind::NativePinning:
89-
return "aP";
9086
}
9187
llvm_unreachable("bad addressor kind");
9288
case AccessorKind::MaterializeForSet:

0 commit comments

Comments
 (0)