Skip to content

Commit 99a9ed5

Browse files
committed
SIL: remove the pinning instructions: strong_pin, strong_unpin, is_unique_or_pinned
They are not used anymore after removing the pinning addressors.
1 parent 7c06d4f commit 99a9ed5

36 files changed

+6
-349
lines changed

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/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/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/IRGen/GenHeap.cpp

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,30 +1289,6 @@ void IRGenFunction::emitErrorStrongRelease(llvm::Value *value) {
12891289
emitUnaryRefCountCall(*this, IGM.getErrorStrongReleaseFn(), value);
12901290
}
12911291

1292-
llvm::Value *IRGenFunction::emitNativeTryPin(llvm::Value *value,
1293-
Atomicity atomicity) {
1294-
llvm::CallInst *call =
1295-
(atomicity == Atomicity::Atomic)
1296-
? Builder.CreateCall(IGM.getNativeTryPinFn(), value)
1297-
: Builder.CreateCall(IGM.getNonAtomicNativeTryPinFn(), value);
1298-
call->setDoesNotThrow();
1299-
1300-
// Builtin.NativeObject? has representation i32/i64.
1301-
llvm::Value *handle = Builder.CreatePtrToInt(call, IGM.IntPtrTy);
1302-
return handle;
1303-
}
1304-
1305-
void IRGenFunction::emitNativeUnpin(llvm::Value *value, Atomicity atomicity) {
1306-
// Builtin.NativeObject? has representation i32/i64.
1307-
value = Builder.CreateIntToPtr(value, IGM.RefCountedPtrTy);
1308-
1309-
llvm::CallInst *call =
1310-
(atomicity == Atomicity::Atomic)
1311-
? Builder.CreateCall(IGM.getNativeUnpinFn(), value)
1312-
: Builder.CreateCall(IGM.getNonAtomicNativeUnpinFn(), value);
1313-
call->setDoesNotThrow();
1314-
}
1315-
13161292
llvm::Value *IRGenFunction::emitLoadRefcountedPtr(Address addr,
13171293
ReferenceCounting style) {
13181294
Address src =

lib/IRGen/IRGenFunction.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -406,10 +406,6 @@ class IRGenFunction {
406406
void emitNativeStrongRelease(llvm::Value *value, Atomicity atomicity);
407407
void emitNativeSetDeallocating(llvm::Value *value);
408408

409-
// - other operations
410-
llvm::Value *emitNativeTryPin(llvm::Value *object, Atomicity atomicity);
411-
void emitNativeUnpin(llvm::Value *handle, Atomicity atomicity);
412-
413409
// Routines for the ObjC reference-counting style.
414410
void emitObjCStrongRetain(llvm::Value *value);
415411
llvm::Value *emitObjCRetainCall(llvm::Value *value);

lib/IRGen/IRGenSIL.cpp

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,12 +1073,9 @@ class IRGenSILFunction :
10731073
void visitCopyBlockWithoutEscapingInst(CopyBlockWithoutEscapingInst *i) {
10741074
llvm_unreachable("not valid in canonical SIL");
10751075
}
1076-
void visitStrongPinInst(StrongPinInst *i);
1077-
void visitStrongUnpinInst(StrongUnpinInst *i);
10781076
void visitStrongRetainInst(StrongRetainInst *i);
10791077
void visitStrongReleaseInst(StrongReleaseInst *i);
10801078
void visitIsUniqueInst(IsUniqueInst *i);
1081-
void visitIsUniqueOrPinnedInst(IsUniqueOrPinnedInst *i);
10821079
void visitIsEscapingClosureInst(IsEscapingClosureInst *i);
10831080
void visitDeallocStackInst(DeallocStackInst *i);
10841081
void visitDeallocBoxInst(DeallocBoxInst *i);
@@ -3792,25 +3789,6 @@ void IRGenSILFunction::visitCopyBlockInst(CopyBlockInst *i) {
37923789
setLoweredExplosion(i, result);
37933790
}
37943791

3795-
void IRGenSILFunction::visitStrongPinInst(swift::StrongPinInst *i) {
3796-
Explosion lowered = getLoweredExplosion(i->getOperand());
3797-
llvm::Value *object = lowered.claimNext();
3798-
llvm::Value *pinHandle =
3799-
emitNativeTryPin(object, i->isAtomic() ? irgen::Atomicity::Atomic
3800-
: irgen::Atomicity::NonAtomic);
3801-
3802-
Explosion result;
3803-
result.add(pinHandle);
3804-
setLoweredExplosion(i, result);
3805-
}
3806-
3807-
void IRGenSILFunction::visitStrongUnpinInst(swift::StrongUnpinInst *i) {
3808-
Explosion lowered = getLoweredExplosion(i->getOperand());
3809-
llvm::Value *pinHandle = lowered.claimNext();
3810-
emitNativeUnpin(pinHandle, i->isAtomic() ? irgen::Atomicity::Atomic
3811-
: irgen::Atomicity::NonAtomic);
3812-
}
3813-
38143792
void IRGenSILFunction::visitStrongRetainInst(swift::StrongRetainInst *i) {
38153793
Explosion lowered = getLoweredExplosion(i->getOperand());
38163794
auto &ti = cast<ReferenceTypeInfo>(getTypeInfo(i->getOperand()->getType()));
@@ -3949,15 +3927,6 @@ void IRGenSILFunction::visitIsUniqueInst(swift::IsUniqueInst *i) {
39493927
setLoweredExplosion(i, out);
39503928
}
39513929

3952-
void IRGenSILFunction::
3953-
visitIsUniqueOrPinnedInst(swift::IsUniqueOrPinnedInst *i) {
3954-
llvm::Value *result = emitIsUnique(*this, i->getOperand(),
3955-
i->getLoc().getSourceLoc(), true);
3956-
Explosion out;
3957-
out.add(result);
3958-
setLoweredExplosion(i, out);
3959-
}
3960-
39613930
void IRGenSILFunction::visitIsEscapingClosureInst(
39623931
swift::IsEscapingClosureInst *i) {
39633932
// The closure operand is allowed to be an optional closure.

lib/ParseSIL/ParseSIL.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2669,7 +2669,6 @@ bool SILParser::parseSILInstruction(SILBuilder &B) {
26692669
UNARY_INSTRUCTION(EndLifetime)
26702670
UNARY_INSTRUCTION(CopyBlock)
26712671
UNARY_INSTRUCTION(IsUnique)
2672-
UNARY_INSTRUCTION(IsUniqueOrPinned)
26732672
UNARY_INSTRUCTION(DestroyAddr)
26742673
UNARY_INSTRUCTION(CopyValue)
26752674
UNARY_INSTRUCTION(DestroyValue)
@@ -2680,10 +2679,8 @@ bool SILParser::parseSILInstruction(SILBuilder &B) {
26802679
REFCOUNTING_INSTRUCTION(UnmanagedReleaseValue)
26812680
REFCOUNTING_INSTRUCTION(UnmanagedRetainValue)
26822681
REFCOUNTING_INSTRUCTION(UnmanagedAutoreleaseValue)
2683-
REFCOUNTING_INSTRUCTION(StrongPin)
26842682
REFCOUNTING_INSTRUCTION(StrongRetain)
26852683
REFCOUNTING_INSTRUCTION(StrongRelease)
2686-
REFCOUNTING_INSTRUCTION(StrongUnpin)
26872684
REFCOUNTING_INSTRUCTION(AutoreleaseValue)
26882685
REFCOUNTING_INSTRUCTION(SetDeallocating)
26892686
REFCOUNTING_INSTRUCTION(ReleaseValue)

0 commit comments

Comments
 (0)