Skip to content

Commit 18c6b61

Browse files
authored
Merge pull request swiftlang#20062 from gottesmm/pr-8d1e1d25d9d909af8231dfb8cfe502e0fef3043d
2 parents 69f6ae5 + 23378cc commit 18c6b61

26 files changed

+128
-127
lines changed

include/swift/SIL/SILBuilder.h

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -145,19 +145,19 @@ class SILBuilder {
145145
public:
146146
explicit SILBuilder(SILFunction &F, bool isParsing = false)
147147
: TempContext(F.getModule()), C(TempContext), F(&F),
148-
hasOwnership(F.hasQualifiedOwnership()), BB(0) {
148+
hasOwnership(F.hasOwnership()), BB(0) {
149149
C.isParsing = isParsing;
150150
}
151151

152152
SILBuilder(SILFunction &F, SmallVectorImpl<SILInstruction *> *InsertedInstrs)
153153
: TempContext(F.getModule(), InsertedInstrs), C(TempContext), F(&F),
154-
hasOwnership(F.hasQualifiedOwnership()), BB(0) {}
154+
hasOwnership(F.hasOwnership()), BB(0) {}
155155

156156
explicit SILBuilder(SILInstruction *I,
157157
SmallVectorImpl<SILInstruction *> *InsertedInstrs = 0)
158158
: TempContext(I->getFunction()->getModule(), InsertedInstrs),
159159
C(TempContext), F(I->getFunction()),
160-
hasOwnership(F->hasQualifiedOwnership()) {
160+
hasOwnership(F->hasOwnership()) {
161161
setInsertionPoint(I);
162162
}
163163

@@ -169,7 +169,7 @@ class SILBuilder {
169169
SmallVectorImpl<SILInstruction *> *InsertedInstrs = 0)
170170
: TempContext(BB->getParent()->getModule(), InsertedInstrs),
171171
C(TempContext), F(BB->getParent()),
172-
hasOwnership(F->hasQualifiedOwnership()) {
172+
hasOwnership(F->hasOwnership()) {
173173
setInsertionPoint(BB);
174174
}
175175

@@ -180,7 +180,7 @@ class SILBuilder {
180180
SmallVectorImpl<SILInstruction *> *InsertedInstrs = 0)
181181
: TempContext(BB->getParent()->getModule(), InsertedInstrs),
182182
C(TempContext), F(BB->getParent()),
183-
hasOwnership(F->hasQualifiedOwnership()) {
183+
hasOwnership(F->hasOwnership()) {
184184
setInsertionPoint(BB, InsertPt);
185185
}
186186

@@ -190,7 +190,7 @@ class SILBuilder {
190190
/// SILBuilderContext must outlive this SILBuilder instance.
191191
SILBuilder(SILInstruction *I, const SILDebugScope *DS, SILBuilderContext &C)
192192
: TempContext(C.getModule()), C(C), F(I->getFunction()),
193-
hasOwnership(F->hasQualifiedOwnership()) {
193+
hasOwnership(F->hasOwnership()) {
194194
assert(DS && "instruction has no debug scope");
195195
setCurrentDebugScope(DS);
196196
setInsertionPoint(I);
@@ -202,7 +202,7 @@ class SILBuilder {
202202
/// SILBuilderContext must outlive this SILBuilder instance.
203203
SILBuilder(SILBasicBlock *BB, const SILDebugScope *DS, SILBuilderContext &C)
204204
: TempContext(C.getModule()), C(C), F(BB->getParent()),
205-
hasOwnership(F->hasQualifiedOwnership()) {
205+
hasOwnership(F->hasOwnership()) {
206206
assert(DS && "block has no debug scope");
207207
setCurrentDebugScope(DS);
208208
setInsertionPoint(BB);
@@ -683,7 +683,7 @@ class SILBuilder {
683683
LoadInst *createTrivialLoadOr(SILLocation Loc, SILValue LV,
684684
LoadOwnershipQualifier Qualifier,
685685
bool SupportUnqualifiedSIL = false) {
686-
if (SupportUnqualifiedSIL && !getFunction().hasQualifiedOwnership()) {
686+
if (SupportUnqualifiedSIL && !getFunction().hasOwnership()) {
687687
assert(
688688
Qualifier != LoadOwnershipQualifier::Copy &&
689689
"In unqualified SIL, a copy must be done separately form the load");
@@ -699,10 +699,10 @@ class SILBuilder {
699699
LoadInst *createLoad(SILLocation Loc, SILValue LV,
700700
LoadOwnershipQualifier Qualifier) {
701701
assert((Qualifier != LoadOwnershipQualifier::Unqualified) ||
702-
!getFunction().hasQualifiedOwnership() &&
702+
!getFunction().hasOwnership() &&
703703
"Unqualified inst in qualified function");
704704
assert((Qualifier == LoadOwnershipQualifier::Unqualified) ||
705-
getFunction().hasQualifiedOwnership() &&
705+
getFunction().hasOwnership() &&
706706
"Qualified inst in unqualified function");
707707
assert(LV->getType().isLoadableOrOpaque(getModule()));
708708
return insert(new (getModule())
@@ -757,7 +757,7 @@ class SILBuilder {
757757
SILValue DestAddr,
758758
StoreOwnershipQualifier Qualifier,
759759
bool SupportUnqualifiedSIL = false) {
760-
if (SupportUnqualifiedSIL && !getFunction().hasQualifiedOwnership()) {
760+
if (SupportUnqualifiedSIL && !getFunction().hasOwnership()) {
761761
assert(
762762
Qualifier != StoreOwnershipQualifier::Assign &&
763763
"In unqualified SIL, assigns must be represented via 2 instructions");
@@ -773,10 +773,10 @@ class SILBuilder {
773773
StoreInst *createStore(SILLocation Loc, SILValue Src, SILValue DestAddr,
774774
StoreOwnershipQualifier Qualifier) {
775775
assert((Qualifier != StoreOwnershipQualifier::Unqualified) ||
776-
!getFunction().hasQualifiedOwnership() &&
776+
!getFunction().hasOwnership() &&
777777
"Unqualified inst in qualified function");
778778
assert((Qualifier == StoreOwnershipQualifier::Unqualified) ||
779-
getFunction().hasQualifiedOwnership() &&
779+
getFunction().hasOwnership() &&
780780
"Qualified inst in unqualified function");
781781
return insert(new (getModule()) StoreInst(getSILDebugLocation(Loc), Src,
782782
DestAddr, Qualifier));
@@ -1128,22 +1128,22 @@ class SILBuilder {
11281128

11291129
RetainValueInst *createRetainValue(SILLocation Loc, SILValue operand,
11301130
Atomicity atomicity) {
1131-
assert(C.isParsing || !getFunction().hasQualifiedOwnership());
1131+
assert(C.isParsing || !getFunction().hasOwnership());
11321132
assert(operand->getType().isLoadableOrOpaque(getModule()));
11331133
return insert(new (getModule()) RetainValueInst(getSILDebugLocation(Loc),
11341134
operand, atomicity));
11351135
}
11361136

11371137
RetainValueAddrInst *createRetainValueAddr(SILLocation Loc, SILValue operand,
11381138
Atomicity atomicity) {
1139-
assert(C.isParsing || !getFunction().hasQualifiedOwnership());
1139+
assert(C.isParsing || !getFunction().hasOwnership());
11401140
return insert(new (getModule()) RetainValueAddrInst(
11411141
getSILDebugLocation(Loc), operand, atomicity));
11421142
}
11431143

11441144
ReleaseValueInst *createReleaseValue(SILLocation Loc, SILValue operand,
11451145
Atomicity atomicity) {
1146-
assert(C.isParsing || !getFunction().hasQualifiedOwnership());
1146+
assert(C.isParsing || !getFunction().hasOwnership());
11471147
assert(operand->getType().isLoadableOrOpaque(getModule()));
11481148
return insert(new (getModule()) ReleaseValueInst(getSILDebugLocation(Loc),
11491149
operand, atomicity));
@@ -1152,15 +1152,15 @@ class SILBuilder {
11521152
ReleaseValueAddrInst *createReleaseValueAddr(SILLocation Loc,
11531153
SILValue operand,
11541154
Atomicity atomicity) {
1155-
assert(C.isParsing || !getFunction().hasQualifiedOwnership());
1155+
assert(C.isParsing || !getFunction().hasOwnership());
11561156
return insert(new (getModule()) ReleaseValueAddrInst(
11571157
getSILDebugLocation(Loc), operand, atomicity));
11581158
}
11591159

11601160
UnmanagedRetainValueInst *createUnmanagedRetainValue(SILLocation Loc,
11611161
SILValue operand,
11621162
Atomicity atomicity) {
1163-
assert(getFunction().hasQualifiedOwnership());
1163+
assert(getFunction().hasOwnership());
11641164
assert(operand->getType().isLoadableOrOpaque(getModule()));
11651165
return insert(new (getModule()) UnmanagedRetainValueInst(
11661166
getSILDebugLocation(Loc), operand, atomicity));
@@ -1169,7 +1169,7 @@ class SILBuilder {
11691169
UnmanagedReleaseValueInst *createUnmanagedReleaseValue(SILLocation Loc,
11701170
SILValue operand,
11711171
Atomicity atomicity) {
1172-
assert(getFunction().hasQualifiedOwnership());
1172+
assert(getFunction().hasOwnership());
11731173
assert(operand->getType().isLoadableOrOpaque(getModule()));
11741174
return insert(new (getModule()) UnmanagedReleaseValueInst(
11751175
getSILDebugLocation(Loc), operand, atomicity));
@@ -1637,13 +1637,13 @@ class SILBuilder {
16371637

16381638
StrongRetainInst *createStrongRetain(SILLocation Loc, SILValue Operand,
16391639
Atomicity atomicity) {
1640-
assert(C.isParsing || !getFunction().hasQualifiedOwnership());
1640+
assert(C.isParsing || !getFunction().hasOwnership());
16411641
return insert(new (getModule()) StrongRetainInst(getSILDebugLocation(Loc),
16421642
Operand, atomicity));
16431643
}
16441644
StrongReleaseInst *createStrongRelease(SILLocation Loc, SILValue Operand,
16451645
Atomicity atomicity) {
1646-
assert(C.isParsing || !getFunction().hasQualifiedOwnership());
1646+
assert(C.isParsing || !getFunction().hasOwnership());
16471647
return insert(new (getModule()) StrongReleaseInst(
16481648
getSILDebugLocation(Loc), Operand, atomicity));
16491649
}
@@ -2080,7 +2080,7 @@ class SILBuilder {
20802080
/// lowering for the non-address value.
20812081
void emitDestroyValueOperation(SILLocation Loc, SILValue v) {
20822082
assert(!v->getType().isAddress());
2083-
if (F->hasQualifiedOwnership() &&
2083+
if (F->hasOwnership() &&
20842084
v.getOwnershipKind() == ValueOwnershipKind::Any)
20852085
return;
20862086
auto &lowering = getTypeLowering(v->getType());

include/swift/SIL/SILFunction.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -232,12 +232,13 @@ class SILFunction
232232
/// *) It is a function referenced by the specialization information.
233233
bool Zombie = false;
234234

235-
/// True if SILOwnership is enabled for this function.
235+
/// True if this function is in Ownership SSA form and thus must pass
236+
/// ownership verification.
236237
///
237238
/// This enables the verifier to easily prove that before the Ownership Model
238239
/// Eliminator runs on a function, we only see a non-semantic-arc world and
239240
/// after the pass runs, we only see a semantic-arc world.
240-
bool HasQualifiedOwnership = true;
241+
bool HasOwnership = true;
241242

242243
/// Set if the function body was deserialized from canonical SIL. This implies
243244
/// that the function's home module performed SIL diagnostics prior to
@@ -423,12 +424,12 @@ class SILFunction
423424
bool isZombie() const { return Zombie; }
424425

425426
/// Returns true if this function has qualified ownership instructions in it.
426-
bool hasQualifiedOwnership() const { return HasQualifiedOwnership; }
427+
bool hasOwnership() const { return HasOwnership; }
427428

428-
/// Sets the HasQualifiedOwnership flag to false. This signals to SIL that no
429+
/// Sets the HasOwnership flag to false. This signals to SIL that no
429430
/// ownership instructions should be in this function any more.
430-
void setUnqualifiedOwnership() {
431-
HasQualifiedOwnership = false;
431+
void setOwnershipEliminated() {
432+
HasOwnership = false;
432433
}
433434

434435
/// Returns true if this function was deserialized from canonical

lib/IRGen/LoadableByAddress.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,7 @@ static AllocStackInst *allocate(StructLoweringState &pass,
10371037

10381038
static StoreOwnershipQualifier
10391039
getStoreInitOwnership(StructLoweringState &pass, SILType type) {
1040-
if (!pass.F->hasQualifiedOwnership()) {
1040+
if (!pass.F->hasOwnership()) {
10411041
return StoreOwnershipQualifier::Unqualified;
10421042
} else if (type.isTrivial(pass.F->getModule())) {
10431043
return StoreOwnershipQualifier::Trivial;
@@ -1517,7 +1517,7 @@ void LoadableStorageAllocation::allocateForArg(SILValue value) {
15171517
++II;
15181518
loadBuilder.setInsertionPoint(II);
15191519
}
1520-
if (!pass.F->hasQualifiedOwnership()) {
1520+
if (!pass.F->hasOwnership()) {
15211521
load = loadBuilder.createLoad(applyInst->getLoc(), value,
15221522
LoadOwnershipQualifier::Unqualified);
15231523
} else {
@@ -1552,7 +1552,7 @@ void LoadableStorageAllocation::allocateForArg(SILValue value) {
15521552
auto *applyOutlinedCopy =
15531553
createOutlinedCopyCall(allocBuilder, value, allocInstr, pass);
15541554

1555-
if (!pass.F->hasQualifiedOwnership()) {
1555+
if (!pass.F->hasOwnership()) {
15561556
loadCopy = allocBuilder.createLoad(applyOutlinedCopy->getLoc(), allocInstr,
15571557
LoadOwnershipQualifier::Unqualified);
15581558
} else {
@@ -1858,7 +1858,7 @@ static void createResultTyInstrAndLoad(LoadableStorageAllocation &allocator,
18581858
currStructExtractInst->getType().getAddressType());
18591859
// Load the struct element then see if we can get rid of the load:
18601860
LoadInst *loadArg = nullptr;
1861-
if (!pass.F->hasQualifiedOwnership()) {
1861+
if (!pass.F->hasOwnership()) {
18621862
loadArg = builder.createLoad(newInstr->getLoc(), newInstr,
18631863
LoadOwnershipQualifier::Unqualified);
18641864
} else {
@@ -1914,7 +1914,7 @@ static void rewriteFunction(StructLoweringState &pass,
19141914

19151915
// Load the enum addr then see if we can get rid of the load:
19161916
LoadInst *loadArg = nullptr;
1917-
if (!pass.F->hasQualifiedOwnership()) {
1917+
if (!pass.F->hasOwnership()) {
19181918
loadArg = argBuilder.createLoad(
19191919
newArg->getLoc(), newArg, LoadOwnershipQualifier::Unqualified);
19201920
} else {
@@ -2458,7 +2458,7 @@ void LoadableByAddress::recreateSingleApply(SILInstruction *applyInst) {
24582458
if (oldValue->getType() != newValue->getType() &&
24592459
!oldValue->getType().isAddress()) {
24602460
LoadOwnershipQualifier ownership;
2461-
if (!F->hasQualifiedOwnership()) {
2461+
if (!F->hasOwnership()) {
24622462
ownership = LoadOwnershipQualifier::Unqualified;
24632463
} else if (newValue->getType().isTrivial(*getModule())) {
24642464
ownership = LoadOwnershipQualifier::Trivial;

lib/ParseSIL/ParseSIL.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5182,10 +5182,10 @@ bool SILParser::parseSILBasicBlock(SILBuilder &B) {
51825182
bool AssumeUnqualifiedOwnershipWhenParsing =
51835183
F->getModule().getOptions().AssumeUnqualifiedOwnershipWhenParsing;
51845184
if (AssumeUnqualifiedOwnershipWhenParsing) {
5185-
F->setUnqualifiedOwnership();
5185+
F->setOwnershipEliminated();
51865186
}
51875187
B.setInsertionPoint(BB);
5188-
B.setHasOwnership(F->hasQualifiedOwnership());
5188+
B.setHasOwnership(F->hasOwnership());
51895189
do {
51905190
if (parseSILInstruction(B))
51915191
return true;

lib/SIL/InstructionUtils.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ bool FunctionOwnershipEvaluator::evaluate(SILInstruction *I) {
539539
case OwnershipQualifiedKind::Unqualified: {
540540
// If we already know that the function has unqualified ownership, just
541541
// return early.
542-
if (!F.get()->hasQualifiedOwnership())
542+
if (!F.get()->hasOwnership())
543543
return true;
544544

545545
// Ok, so we know at this point that we have qualified ownership. If we have
@@ -551,15 +551,15 @@ bool FunctionOwnershipEvaluator::evaluate(SILInstruction *I) {
551551
// Otherwise, set the function to have unqualified ownership. This will
552552
// ensure that no more Qualified instructions can be added to the given
553553
// function.
554-
F.get()->setUnqualifiedOwnership();
554+
F.get()->setOwnershipEliminated();
555555
return true;
556556
}
557557
case OwnershipQualifiedKind::Qualified: {
558558
// First check if our function has unqualified ownership. If we already do
559559
// have unqualified ownership, then we know that we have already seen an
560560
// unqualified ownership instruction. This means the function has both
561561
// qualified and unqualified instructions. =><=.
562-
if (!F.get()->hasQualifiedOwnership())
562+
if (!F.get()->hasOwnership())
563563
return false;
564564

565565
// Ok, at this point we know that we are still qualified. Since functions

lib/SIL/SILBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ void SILBuilder::emitShallowDestructureValueOperation(
514514
}
515515

516516
// Otherwise, we want to destructure add the destructure and return.
517-
if (getFunction().hasQualifiedOwnership()) {
517+
if (getFunction().hasOwnership()) {
518518
auto *DI = emitDestructureValueOperation(Loc, V);
519519
copy(DI->getResults(), std::back_inserter(Results));
520520
return;

lib/SIL/SILOwnershipVerifier.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ void SILInstruction::verifyOperandOwnership() const {
637637

638638
// If the given function has unqualified ownership or we have been asked by
639639
// the user not to verify this function, there is nothing to verify.
640-
if (!getFunction()->hasQualifiedOwnership() ||
640+
if (!getFunction()->hasOwnership() ||
641641
!getFunction()->shouldVerifyOwnership())
642642
return;
643643

@@ -701,7 +701,7 @@ void SILValue::verifyOwnership(SILModule &mod,
701701

702702
// If the given function has unqualified ownership or we have been asked by
703703
// the user not to verify this function, there is nothing to verify.
704-
if (!f->hasQualifiedOwnership() || !f->shouldVerifyOwnership())
704+
if (!f->hasOwnership() || !f->shouldVerifyOwnership())
705705
return;
706706

707707
ErrorBehaviorKind errorBehavior;
@@ -737,7 +737,7 @@ bool OwnershipChecker::checkValue(SILValue value) {
737737

738738
// If the given function has unqualified ownership, there is nothing further
739739
// to verify.
740-
if (!f->hasQualifiedOwnership())
740+
if (!f->hasOwnership())
741741
return false;
742742

743743
ErrorBehaviorKind errorBehavior(ErrorBehaviorKind::ReturnFalse);

lib/SIL/SILPrinter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
561561

562562
// If SIL ownership is enabled and the given function has not had ownership
563563
// stripped out, print out ownership of SILArguments.
564-
if (BB->getParent()->hasQualifiedOwnership()) {
564+
if (BB->getParent()->hasOwnership()) {
565565
*this << getIDAndTypeAndOwnership(Args[0]);
566566
for (SILArgument *Arg : Args.drop_front()) {
567567
*this << ", " << getIDAndTypeAndOwnership(Arg);

0 commit comments

Comments
 (0)