Skip to content

Commit 3e5c432

Browse files
committed
[semantic-arc] Remove all uses of SILBuilder::*AndFold in SILGen and TypeLowering.
I am removing these usages of this API since it conflicts with SILGen's want to hold onto copy_value return values for ownership propagation purposes. If any of the copy_value are folded, the reference that SILGen holds onto will be invalid. rdar://28685236
1 parent ed0955a commit 3e5c432

File tree

7 files changed

+18
-18
lines changed

7 files changed

+18
-18
lines changed

lib/SIL/TypeLowering.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ namespace {
718718
void emitDestroyValue(SILBuilder &B, SILLocation loc,
719719
SILValue aggValue) const override {
720720
if (B.getFunction().hasQualifiedOwnership()) {
721-
B.emitDestroyValueAndFold(loc, aggValue);
721+
B.createDestroyValue(loc, aggValue);
722722
return;
723723
}
724724

@@ -838,7 +838,7 @@ namespace {
838838
void emitDestroyValue(SILBuilder &B, SILLocation loc,
839839
SILValue value) const override {
840840
if (B.getFunction().hasQualifiedOwnership()) {
841-
B.emitDestroyValueAndFold(loc, value);
841+
B.createDestroyValue(loc, value);
842842
return;
843843
}
844844
B.emitReleaseValueAndFold(loc, value);
@@ -850,7 +850,7 @@ namespace {
850850
"This method should never be called when performing a shallow "
851851
"destroy value.");
852852
if (B.getFunction().hasQualifiedOwnership()) {
853-
B.emitDestroyValueAndFold(loc, value);
853+
B.createDestroyValue(loc, value);
854854
return;
855855
}
856856
B.emitReleaseValueAndFold(loc, value);
@@ -896,7 +896,7 @@ namespace {
896896
void emitDestroyValue(SILBuilder &B, SILLocation loc,
897897
SILValue value) const override {
898898
if (B.getFunction().hasQualifiedOwnership()) {
899-
B.emitDestroyValueAndFold(loc, value);
899+
B.createDestroyValue(loc, value);
900900
return;
901901
}
902902
B.emitStrongReleaseAndFold(loc, value);

lib/SILGen/SILGenBuiltin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ static ManagedValue emitBuiltinDestroy(SILGenFunction &gen,
236236

237237
// Destroy the value indirectly. Canonicalization will promote to loads
238238
// and releases if appropriate.
239-
gen.B.emitDestroyAddrAndFold(loc, addr);
239+
gen.B.createDestroyAddr(loc, addr);
240240

241241
return ManagedValue::forUnmanaged(gen.emitEmptyTuple(loc));
242242
}

lib/SILGen/SILGenDecl.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ namespace {
116116
public:
117117
CleanupClosureConstant(SILValue closure) : closure(closure) {}
118118
void emit(SILGenFunction &gen, CleanupLocation l) override {
119-
gen.B.emitDestroyValueAndFold(l, closure);
119+
gen.B.emitDestroyValueOperation(l, closure);
120120
}
121121
};
122122
}
@@ -208,7 +208,7 @@ class ReleaseValueCleanup : public Cleanup {
208208

209209
void emit(SILGenFunction &gen, CleanupLocation l) override {
210210
if (v->getType().isAddress())
211-
gen.B.emitDestroyAddrAndFold(l, v);
211+
gen.B.createDestroyAddr(l, v);
212212
else
213213
gen.B.emitDestroyValueOperation(l, v);
214214
}
@@ -1304,7 +1304,7 @@ void SILGenFunction::destroyLocalVariable(SILLocation silLoc, VarDecl *vd) {
13041304
// For a heap variable, the box is responsible for the value. We just need
13051305
// to give up our retain count on it.
13061306
if (loc.box) {
1307-
B.emitDestroyValueAndFold(silLoc, loc.box);
1307+
B.emitDestroyValueOperation(silLoc, loc.box);
13081308
return;
13091309
}
13101310

@@ -1314,7 +1314,7 @@ void SILGenFunction::destroyLocalVariable(SILLocation silLoc, VarDecl *vd) {
13141314
if (!Val->getType().isAddress())
13151315
B.emitDestroyValueOperation(silLoc, Val);
13161316
else
1317-
B.emitDestroyAddrAndFold(silLoc, Val);
1317+
B.createDestroyAddr(silLoc, Val);
13181318
}
13191319

13201320
void SILGenFunction::deallocateUninitializedLocalVariable(SILLocation silLoc,

lib/SILGen/SILGenDestructor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ void SILGenFunction::emitClassMemberDestruction(SILValue selfValue,
134134
if (!ti.isTrivial()) {
135135
SILValue addr = B.createRefElementAddr(cleanupLoc, selfValue, vd,
136136
ti.getLoweredType().getAddressType());
137-
B.emitDestroyAddrAndFold(cleanupLoc, addr);
137+
B.createDestroyAddr(cleanupLoc, addr);
138138
}
139139
}
140140
}

lib/SILGen/SILGenExpr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ emitRValueWithAccessor(SILGenFunction &SGF, SILLocation loc,
546546
case AddressorKind::Owning:
547547
case AddressorKind::NativeOwning:
548548
// Emit the release immediately.
549-
SGF.B.emitDestroyValueAndFold(loc, addressorResult.second.forward(SGF));
549+
SGF.B.emitDestroyValueOperation(loc, addressorResult.second.forward(SGF));
550550
break;
551551
case AddressorKind::NativePinning:
552552
// Emit the unpin immediately.

lib/SILGen/SILGenLValue.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2242,7 +2242,7 @@ static void emitStoreOfSemanticRValue(SILGenFunction &gen,
22422242
gen.B.createStoreWeak(loc, value, dest, isInit);
22432243

22442244
// store_weak doesn't take ownership of the input, so cancel it out.
2245-
gen.B.emitDestroyValueAndFold(loc, value);
2245+
gen.B.emitDestroyValueOperation(loc, value);
22462246
return;
22472247
}
22482248

@@ -2254,15 +2254,15 @@ static void emitStoreOfSemanticRValue(SILGenFunction &gen,
22542254
gen.B.createStoreUnowned(loc, value, dest, isInit);
22552255

22562256
// store_unowned doesn't take ownership of the input, so cancel it out.
2257-
gen.B.emitDestroyValueAndFold(loc, value);
2257+
gen.B.emitDestroyValueOperation(loc, value);
22582258
return;
22592259
}
22602260

22612261
auto unownedValue =
22622262
gen.B.createRefToUnowned(loc, value, storageType.getObjectType());
22632263
gen.B.createUnownedRetain(loc, unownedValue, Atomicity::Atomic);
22642264
emitUnloweredStoreOfCopy(gen.B, loc, unownedValue, dest, isInit);
2265-
gen.B.emitDestroyValueAndFold(loc, value);
2265+
gen.B.emitDestroyValueOperation(loc, value);
22662266
return;
22672267
}
22682268

@@ -2272,7 +2272,7 @@ static void emitStoreOfSemanticRValue(SILGenFunction &gen,
22722272
auto unmanagedValue =
22732273
gen.B.createRefToUnmanaged(loc, value, storageType.getObjectType());
22742274
emitUnloweredStoreOfCopy(gen.B, loc, unmanagedValue, dest, isInit);
2275-
gen.B.emitDestroyValueAndFold(loc, value);
2275+
gen.B.emitDestroyValueOperation(loc, value);
22762276
return;
22772277
}
22782278

@@ -2362,15 +2362,15 @@ SILValue SILGenFunction::emitConversionFromSemanticValue(SILLocation loc,
23622362

23632363
SILValue unowned = B.createRefToUnowned(loc, semanticValue, storageType);
23642364
B.createUnownedRetain(loc, unowned, Atomicity::Atomic);
2365-
B.emitDestroyValueAndFold(loc, semanticValue);
2365+
B.emitDestroyValueOperation(loc, semanticValue);
23662366
return unowned;
23672367
}
23682368

23692369
// For @unmanaged types, place into an unmanaged box.
23702370
if (storageType.is<UnmanagedStorageType>()) {
23712371
SILValue unmanaged =
23722372
B.createRefToUnmanaged(loc, semanticValue, storageType);
2373-
B.emitDestroyValueAndFold(loc, semanticValue);
2373+
B.emitDestroyValueOperation(loc, semanticValue);
23742374
return unmanaged;
23752375
}
23762376

lib/SILGen/SILGenProlog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class StrongReleaseCleanup : public Cleanup {
6161
public:
6262
StrongReleaseCleanup(SILValue box) : box(box) {}
6363
void emit(SILGenFunction &gen, CleanupLocation l) override {
64-
gen.B.emitDestroyValueAndFold(l, box);
64+
gen.B.emitDestroyValueOperation(l, box);
6565
}
6666
};
6767
} // end anonymous namespace

0 commit comments

Comments
 (0)