Skip to content

Commit 28a9d08

Browse files
authored
Merge pull request swiftlang#27878 from gottesmm/pr-5a70f15fcf866b4c0f26919d4c7ca9747f7a352e
[sil] Rename {,Strong}Copy{Unowned,Unmanaged}.
2 parents 6f3c744 + 7ee5ad7 commit 28a9d08

Some content is hidden

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

43 files changed

+250
-243
lines changed

docs/SIL.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2807,13 +2807,13 @@ It is expected that the strong reference count of the object is one.
28072807
Furthermore, no other thread may increment the strong reference count during
28082808
execution of this instruction.
28092809

2810-
copy_unowned_value
2811-
``````````````````
2810+
strong_copy_unowned_value
2811+
`````````````````````````
28122812
::
28132813

2814-
sil-instruction ::= 'copy_unowned_value' sil-operand
2814+
sil-instruction ::= 'strong_copy_unowned_value' sil-operand
28152815

2816-
%1 = copy_unowned_value %0 : $@unowned T
2816+
%1 = strong_copy_unowned_value %0 : $@unowned T
28172817
// %1 will be a strong @owned value of type $T.
28182818
// $T must be a reference type
28192819

@@ -3732,14 +3732,14 @@ This instruction has the same local semantics as ``retain_value`` but:
37323732
The intention is that this instruction is used to implement unmanaged
37333733
constructs.
37343734

3735-
copy_unmanaged_value
3736-
``````````````````````
3735+
strong_copy_unmanaged_value
3736+
```````````````````````````
37373737

37383738
::
37393739

3740-
sil-instruction ::= 'copy_unmanaged_value' sil-value
3740+
sil-instruction ::= 'strong_copy_unmanaged_value' sil-value
37413741

3742-
%1 = copy_unmanaged_value %0 : $@sil_unmanaged A
3742+
%1 = strong_copy_unmanaged_value %0 : $@sil_unmanaged A
37433743
// %1 will be a strong @owned $A.
37443744

37453745
This instruction has the same semantics as ``copy_value`` except that its input

include/swift/AST/ReferenceStorage.def

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@
5555
/// UNCHECKED_REF_STORAGE
5656
/// Name##RetainValueInst
5757
/// Name##ReleaseValueInst
58-
/// Copy##Name##ValueInst
58+
/// StrongCopy##Name##ValueInst
5959
/// LOADABLE_REF_STORAGE
6060
/// Ref*ToNameInst
6161
/// Name*ToRefInst
6262
/// NEVER_OR_SOMETIMES_LOADABLE_CHECKED_REF_STORAGE
6363
/// Load##Name##Inst
6464
/// Store##Name##Inst
6565
/// ALWAYS_OR_SOMETIMES_LOADABLE_CHECKED_REF_STORAGE
66-
/// Copy##Name##ValueInst
66+
/// StrongCopy##Name##ValueInst
6767
/// StrongRetain##Name##Inst
6868
/// Name##RetainInst
6969
/// Name##ReleaseInst
@@ -78,7 +78,7 @@
7878
/// ALWAYS_LOADABLE_CHECKED_REF_STORAGE
7979
/// Ref*ToNameInst
8080
/// Name*ToRefInst
81-
/// Copy##Name##ValueInst
81+
/// StrongCopy##Name##ValueInst
8282
/// StrongRetain##Name##Inst
8383
/// Name##RetainInst
8484
/// Name##ReleaseInst
@@ -87,7 +87,7 @@
8787
/// Name*ToRefInst
8888
/// Load##Name##Inst
8989
/// Store##Name##Inst
90-
/// Copy##Name##ValueInst
90+
/// StrongCopy##Name##ValueInst
9191
/// StrongRetain##Name##Inst
9292
/// Name##RetainInst
9393
/// Name##ReleaseInst

include/swift/SIL/SILBuilder.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -911,11 +911,11 @@ class SILBuilder {
911911
return insert(new (getModule()) \
912912
RefTo##Name##Inst(getSILDebugLocation(Loc), op, ty)); \
913913
} \
914-
Copy##Name##ValueInst *createCopy##Name##Value(SILLocation Loc, \
915-
SILValue operand) { \
914+
StrongCopy##Name##ValueInst *createStrongCopy##Name##Value( \
915+
SILLocation Loc, SILValue operand) { \
916916
auto type = getFunction().getLoweredType( \
917917
operand->getType().getASTType().getReferenceStorageReferent()); \
918-
return insert(new (getModule()) Copy##Name##ValueInst( \
918+
return insert(new (getModule()) StrongCopy##Name##ValueInst( \
919919
getSILDebugLocation(Loc), operand, type)); \
920920
}
921921

include/swift/SIL/SILCloner.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,10 +1325,10 @@ SILCloner<ImplClass>::visitDebugValueAddrInst(DebugValueAddrInst *Inst) {
13251325
getOpType(Inst->getType()))); \
13261326
} \
13271327
template <typename ImplClass> \
1328-
void SILCloner<ImplClass>::visitCopy##Name##ValueInst( \
1329-
Copy##Name##ValueInst *Inst) { \
1328+
void SILCloner<ImplClass>::visitStrongCopy##Name##ValueInst( \
1329+
StrongCopy##Name##ValueInst *Inst) { \
13301330
getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope())); \
1331-
recordClonedInstruction(Inst, getBuilder().createCopy##Name##Value( \
1331+
recordClonedInstruction(Inst, getBuilder().createStrongCopy##Name##Value( \
13321332
getOpLocation(Inst->getLoc()), \
13331333
getOpValue(Inst->getOperand()))); \
13341334
}

include/swift/SIL/SILInstruction.h

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6480,22 +6480,24 @@ class CopyValueInst
64806480
};
64816481

64826482
#define UNCHECKED_REF_STORAGE(Name, ...) \
6483-
class Copy##Name##ValueInst \
6484-
: public UnaryInstructionBase<SILInstructionKind::Copy##Name##ValueInst, \
6485-
SingleValueInstruction> { \
6483+
class StrongCopy##Name##ValueInst \
6484+
: public UnaryInstructionBase< \
6485+
SILInstructionKind::StrongCopy##Name##ValueInst, \
6486+
SingleValueInstruction> { \
64866487
friend class SILBuilder; \
6487-
Copy##Name##ValueInst(SILDebugLocation DebugLoc, SILValue operand, \
6488-
SILType type) \
6488+
StrongCopy##Name##ValueInst(SILDebugLocation DebugLoc, SILValue operand, \
6489+
SILType type) \
64896490
: UnaryInstructionBase(DebugLoc, operand, type) {} \
64906491
};
64916492

64926493
#define ALWAYS_OR_SOMETIMES_LOADABLE_CHECKED_REF_STORAGE(Name, ...) \
6493-
class Copy##Name##ValueInst \
6494-
: public UnaryInstructionBase<SILInstructionKind::Copy##Name##ValueInst, \
6495-
SingleValueInstruction> { \
6494+
class StrongCopy##Name##ValueInst \
6495+
: public UnaryInstructionBase< \
6496+
SILInstructionKind::StrongCopy##Name##ValueInst, \
6497+
SingleValueInstruction> { \
64966498
friend class SILBuilder; \
6497-
Copy##Name##ValueInst(SILDebugLocation DebugLoc, SILValue operand, \
6498-
SILType type) \
6499+
StrongCopy##Name##ValueInst(SILDebugLocation DebugLoc, SILValue operand, \
6500+
SILType type) \
64996501
: UnaryInstructionBase(DebugLoc, operand, type) {} \
65006502
};
65016503
#include "swift/AST/ReferenceStorage.def"

include/swift/SIL/SILNodes.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,10 +563,10 @@ ABSTRACT_VALUE_AND_INST(SingleValueInstruction, ValueBase, SILInstruction)
563563
SINGLE_VALUE_INST(CopyValueInst, copy_value,
564564
SingleValueInstruction, MayHaveSideEffects, DoesNotRelease)
565565
#define UNCHECKED_REF_STORAGE(Name, name, ...) \
566-
SINGLE_VALUE_INST(Copy##Name##ValueInst, copy_##name##_value, \
566+
SINGLE_VALUE_INST(StrongCopy##Name##ValueInst, strong_copy_##name##_value, \
567567
SingleValueInstruction, MayHaveSideEffects, DoesNotRelease)
568568
#define ALWAYS_OR_SOMETIMES_LOADABLE_CHECKED_REF_STORAGE(Name, name, ...) \
569-
SINGLE_VALUE_INST(Copy##Name##ValueInst, copy_##name##_value, \
569+
SINGLE_VALUE_INST(StrongCopy##Name##ValueInst, strong_copy_##name##_value, \
570570
SingleValueInstruction, MayHaveSideEffects, DoesNotRelease)
571571
#include "swift/AST/ReferenceStorage.def"
572572
SINGLE_VALUE_INST(UncheckedOwnershipConversionInst, unchecked_ownership_conversion,

lib/IRGen/IRGenSIL.cpp

Lines changed: 47 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,7 +1125,7 @@ class IRGenSILFunction :
11251125
#define LOADABLE_REF_STORAGE_HELPER(Name) \
11261126
void visitRefTo##Name##Inst(RefTo##Name##Inst *i); \
11271127
void visit##Name##ToRefInst(Name##ToRefInst *i); \
1128-
void visitCopy##Name##ValueInst(Copy##Name##ValueInst *i);
1128+
void visitStrongCopy##Name##ValueInst(StrongCopy##Name##ValueInst *i);
11291129
#define NEVER_LOADABLE_CHECKED_REF_STORAGE(Name, ...) \
11301130
void visitLoad##Name##Inst(Load##Name##Inst *i); \
11311131
void visitStore##Name##Inst(Store##Name##Inst *i);
@@ -3829,57 +3829,58 @@ static const ReferenceTypeInfo &getReferentTypeInfo(IRGenFunction &IGF,
38293829
ti.name##Assign(*this, source, dest, isOptional); \
38303830
} \
38313831
}
3832-
#define ALWAYS_LOADABLE_CHECKED_REF_STORAGE(Name, name, ...) \
3833-
void IRGenSILFunction:: \
3834-
visitStrongRetain##Name##Inst(swift::StrongRetain##Name##Inst *i) { \
3835-
Explosion lowered = getLoweredExplosion(i->getOperand()); \
3836-
auto &ti = getReferentTypeInfo(*this, i->getOperand()->getType()); \
3837-
ti.strongRetain##Name(*this, lowered, \
3838-
i->isAtomic() ? irgen::Atomicity::Atomic \
3839-
: irgen::Atomicity::NonAtomic); \
3840-
} \
3832+
#define ALWAYS_LOADABLE_CHECKED_REF_STORAGE(Name, name, ...) \
3833+
void IRGenSILFunction::visitStrongRetain##Name##Inst( \
3834+
swift::StrongRetain##Name##Inst *i) { \
3835+
Explosion lowered = getLoweredExplosion(i->getOperand()); \
3836+
auto &ti = getReferentTypeInfo(*this, i->getOperand()->getType()); \
3837+
ti.strongRetain##Name(*this, lowered, \
3838+
i->isAtomic() ? irgen::Atomicity::Atomic \
3839+
: irgen::Atomicity::NonAtomic); \
3840+
} \
38413841
void IRGenSILFunction::visit##Name##RetainInst(swift::Name##RetainInst *i) { \
3842-
Explosion lowered = getLoweredExplosion(i->getOperand()); \
3843-
auto &ti = getReferentTypeInfo(*this, i->getOperand()->getType()); \
3844-
ti.name##Retain(*this, lowered, \
3845-
i->isAtomic() ? irgen::Atomicity::Atomic \
3846-
: irgen::Atomicity::NonAtomic); \
3847-
} \
3848-
void \
3849-
IRGenSILFunction::visit##Name##ReleaseInst(swift::Name##ReleaseInst *i) { \
3850-
Explosion lowered = getLoweredExplosion(i->getOperand()); \
3851-
auto &ti = getReferentTypeInfo(*this, i->getOperand()->getType()); \
3852-
ti.name##Release(*this, lowered, \
3853-
i->isAtomic() ? irgen::Atomicity::Atomic \
3854-
: irgen::Atomicity::NonAtomic); \
3855-
} \
3856-
void IRGenSILFunction::visitCopy##Name##ValueInst( \
3857-
swift::Copy##Name##ValueInst *i) { \
3858-
Explosion in = getLoweredExplosion(i->getOperand()); \
3859-
auto silTy = i->getOperand()->getType(); \
3860-
auto ty = cast<Name##StorageType>(silTy.getASTType()); \
3861-
auto isOptional = bool(ty.getReferentType()->getOptionalObjectType()); \
3862-
auto &ti = getReferentTypeInfo(*this, silTy); \
3863-
ti.strongRetain##Name(*this, in, irgen::Atomicity::Atomic); \
3864-
/* Semantically we are just passing through the input parameter but as a */\
3865-
/* strong reference... at LLVM IR level these type differences don't */ \
3866-
/* matter. So just set the lowered explosion appropriately. */ \
3867-
Explosion output = getLoweredExplosion(i->getOperand()); \
3868-
if (isOptional) { \
3869-
auto values = output.claimAll(); \
3870-
output.reset(); \
3871-
for (auto value : values) { \
3872-
output.add(Builder.CreatePtrToInt(value, IGM.IntPtrTy)); \
3873-
} \
3874-
} \
3875-
setLoweredExplosion(i, output); \
3842+
Explosion lowered = getLoweredExplosion(i->getOperand()); \
3843+
auto &ti = getReferentTypeInfo(*this, i->getOperand()->getType()); \
3844+
ti.name##Retain(*this, lowered, \
3845+
i->isAtomic() ? irgen::Atomicity::Atomic \
3846+
: irgen::Atomicity::NonAtomic); \
3847+
} \
3848+
void IRGenSILFunction::visit##Name##ReleaseInst( \
3849+
swift::Name##ReleaseInst *i) { \
3850+
Explosion lowered = getLoweredExplosion(i->getOperand()); \
3851+
auto &ti = getReferentTypeInfo(*this, i->getOperand()->getType()); \
3852+
ti.name##Release(*this, lowered, \
3853+
i->isAtomic() ? irgen::Atomicity::Atomic \
3854+
: irgen::Atomicity::NonAtomic); \
3855+
} \
3856+
void IRGenSILFunction::visitStrongCopy##Name##ValueInst( \
3857+
swift::StrongCopy##Name##ValueInst *i) { \
3858+
Explosion in = getLoweredExplosion(i->getOperand()); \
3859+
auto silTy = i->getOperand()->getType(); \
3860+
auto ty = cast<Name##StorageType>(silTy.getASTType()); \
3861+
auto isOptional = bool(ty.getReferentType()->getOptionalObjectType()); \
3862+
auto &ti = getReferentTypeInfo(*this, silTy); \
3863+
ti.strongRetain##Name(*this, in, irgen::Atomicity::Atomic); \
3864+
/* Semantically we are just passing through the input parameter but as a \
3865+
*/ \
3866+
/* strong reference... at LLVM IR level these type differences don't */ \
3867+
/* matter. So just set the lowered explosion appropriately. */ \
3868+
Explosion output = getLoweredExplosion(i->getOperand()); \
3869+
if (isOptional) { \
3870+
auto values = output.claimAll(); \
3871+
output.reset(); \
3872+
for (auto value : values) { \
3873+
output.add(Builder.CreatePtrToInt(value, IGM.IntPtrTy)); \
3874+
} \
3875+
} \
3876+
setLoweredExplosion(i, output); \
38763877
}
38773878
#define SOMETIMES_LOADABLE_CHECKED_REF_STORAGE(Name, name, ...) \
38783879
NEVER_LOADABLE_CHECKED_REF_STORAGE(Name, name, "...") \
38793880
ALWAYS_LOADABLE_CHECKED_REF_STORAGE(Name, name, "...")
38803881
#define UNCHECKED_REF_STORAGE(Name, name, ...) \
3881-
void IRGenSILFunction::visitCopy##Name##ValueInst( \
3882-
swift::Copy##Name##ValueInst *i) { \
3882+
void IRGenSILFunction::visitStrongCopy##Name##ValueInst( \
3883+
swift::StrongCopy##Name##ValueInst *i) { \
38833884
Explosion in = getLoweredExplosion(i->getOperand()); \
38843885
auto silTy = i->getOperand()->getType(); \
38853886
auto ty = cast<Name##StorageType>(silTy.getASTType()); \

lib/ParseSIL/ParseSIL.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2963,12 +2963,13 @@ bool SILParser::parseSILInstruction(SILBuilder &B) {
29632963
REFCOUNTING_INSTRUCTION(RetainValue)
29642964
REFCOUNTING_INSTRUCTION(ReleaseValueAddr)
29652965
REFCOUNTING_INSTRUCTION(RetainValueAddr)
2966-
#define UNCHECKED_REF_STORAGE(Name, ...) UNARY_INSTRUCTION(Copy##Name##Value)
2967-
#define ALWAYS_OR_SOMETIMES_LOADABLE_CHECKED_REF_STORAGE(Name, ...) \
2968-
REFCOUNTING_INSTRUCTION(StrongRetain##Name) \
2969-
REFCOUNTING_INSTRUCTION(Name##Retain) \
2970-
REFCOUNTING_INSTRUCTION(Name##Release) \
2971-
UNARY_INSTRUCTION(Copy##Name##Value)
2966+
#define UNCHECKED_REF_STORAGE(Name, ...) \
2967+
UNARY_INSTRUCTION(StrongCopy##Name##Value)
2968+
#define ALWAYS_OR_SOMETIMES_LOADABLE_CHECKED_REF_STORAGE(Name, ...) \
2969+
REFCOUNTING_INSTRUCTION(StrongRetain##Name) \
2970+
REFCOUNTING_INSTRUCTION(Name##Retain) \
2971+
REFCOUNTING_INSTRUCTION(Name##Release) \
2972+
UNARY_INSTRUCTION(StrongCopy##Name##Value)
29722973
#include "swift/AST/ReferenceStorage.def"
29732974
#undef UNARY_INSTRUCTION
29742975
#undef REFCOUNTING_INSTRUCTION

lib/SIL/InstructionUtils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,12 +329,12 @@ bool swift::onlyAffectsRefCount(SILInstruction *user) {
329329
#define UNCHECKED_REF_STORAGE(Name, ...) \
330330
case SILInstructionKind::Name##RetainValueInst: \
331331
case SILInstructionKind::Name##ReleaseValueInst: \
332-
case SILInstructionKind::Copy##Name##ValueInst:
332+
case SILInstructionKind::StrongCopy##Name##ValueInst:
333333
#define ALWAYS_OR_SOMETIMES_LOADABLE_CHECKED_REF_STORAGE(Name, ...) \
334334
case SILInstructionKind::Name##RetainInst: \
335335
case SILInstructionKind::Name##ReleaseInst: \
336336
case SILInstructionKind::StrongRetain##Name##Inst: \
337-
case SILInstructionKind::Copy##Name##ValueInst:
337+
case SILInstructionKind::StrongCopy##Name##ValueInst:
338338
#include "swift/AST/ReferenceStorage.def"
339339
return true;
340340
}

lib/SIL/MemAccessUtils.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -596,9 +596,9 @@ void swift::visitAccessedAddress(SILInstruction *I,
596596
// Non-access cases: these are marked with memory side effects, but, by
597597
// themselves, do not access formal memory.
598598
#define UNCHECKED_REF_STORAGE(Name, ...) \
599-
case SILInstructionKind::Copy##Name##ValueInst:
600-
#define ALWAYS_OR_SOMETIMES_LOADABLE_CHECKED_REF_STORAGE(Name, ...) \
601-
case SILInstructionKind::Copy##Name##ValueInst:
599+
case SILInstructionKind::StrongCopy##Name##ValueInst:
600+
#define ALWAYS_OR_SOMETIMES_LOADABLE_CHECKED_REF_STORAGE(Name, ...) \
601+
case SILInstructionKind::StrongCopy##Name##ValueInst:
602602
#include "swift/AST/ReferenceStorage.def"
603603
case SILInstructionKind::AbortApplyInst:
604604
case SILInstructionKind::AllocBoxInst:

0 commit comments

Comments
 (0)