Skip to content

Commit 58ff39b

Browse files
authored
Merge pull request #35046 from gottesmm/pr-2511f2f686454ddb2d288c821d750999c44bbbd6
[sil-combine] Use high level ARC APIs instead of low level ARC APIs in a few cases to make code work in ossa and non-ossa.
2 parents fa966ce + 9f6688e commit 58ff39b

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

lib/SILOptimizer/SILCombiner/SILCombinerApplyVisitors.cpp

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -945,8 +945,8 @@ struct ConcreteArgumentCopy {
945945
}
946946

947947
static Optional<ConcreteArgumentCopy>
948-
generate(const ConcreteExistentialInfo &CEI, ApplySite apply, unsigned argIdx,
949-
SILBuilderContext &BuilderCtx) {
948+
generate(const ConcreteExistentialInfo &existentialInfo, ApplySite apply,
949+
unsigned argIdx, SILBuilderContext &builderCtx) {
950950
SILParameterInfo paramInfo =
951951
apply.getOrigCalleeConv().getParamInfoForSILArg(argIdx);
952952
// Mutation should have been checked before we get this far.
@@ -976,21 +976,23 @@ struct ConcreteArgumentCopy {
976976
if (!paramInfo.isFormalIndirect())
977977
return None;
978978

979-
SILBuilderWithScope B(apply.getInstruction(), BuilderCtx);
979+
SILBuilderWithScope builder(apply.getInstruction(), builderCtx);
980980
auto loc = apply.getLoc();
981-
auto *ASI = B.createAllocStack(loc, CEI.ConcreteValue->getType());
981+
auto *asi =
982+
builder.createAllocStack(loc, existentialInfo.ConcreteValue->getType());
982983
// If the type is an address, simple copy it.
983-
if (CEI.ConcreteValue->getType().isAddress()) {
984-
B.createCopyAddr(loc, CEI.ConcreteValue, ASI, IsNotTake,
985-
IsInitialization_t::IsInitialization);
984+
if (existentialInfo.ConcreteValue->getType().isAddress()) {
985+
builder.createCopyAddr(loc, existentialInfo.ConcreteValue, asi, IsNotTake,
986+
IsInitialization_t::IsInitialization);
986987
} else {
987988
// Otherwise, we probably got the value from the source of a store
988989
// instruction so, create a store into the temporary argument.
989-
B.createStrongRetain(loc, CEI.ConcreteValue, B.getDefaultAtomicity());
990-
B.createStore(loc, CEI.ConcreteValue, ASI,
991-
StoreOwnershipQualifier::Unqualified);
990+
auto copy =
991+
builder.emitCopyValueOperation(loc, existentialInfo.ConcreteValue);
992+
builder.emitStoreValueOperation(loc, copy, asi,
993+
StoreOwnershipQualifier::Init);
992994
}
993-
return ConcreteArgumentCopy(origArg, ASI);
995+
return ConcreteArgumentCopy(origArg, asi);
994996
}
995997
};
996998

@@ -1416,7 +1418,7 @@ static void emitMatchingRCAdjustmentsForCall(ApplyInst *Call, SILValue OnX) {
14161418

14171419
// Emit a retain for the @owned return.
14181420
SILBuilderWithScope Builder(Call);
1419-
Builder.createRetainValue(Call->getLoc(), OnX, Builder.getDefaultAtomicity());
1421+
OnX = Builder.emitCopyValueOperation(Call->getLoc(), OnX);
14201422

14211423
// Emit a release for the @owned parameter, or none for a @guaranteed
14221424
// parameter.
@@ -1428,7 +1430,7 @@ static void emitMatchingRCAdjustmentsForCall(ApplyInst *Call, SILValue OnX) {
14281430
ParamInfo == ParameterConvention::Direct_Guaranteed);
14291431

14301432
if (ParamInfo == ParameterConvention::Direct_Owned)
1431-
Builder.createReleaseValue(Call->getLoc(), OnX, Builder.getDefaultAtomicity());
1433+
Builder.emitDestroyValueOperation(Call->getLoc(), OnX);
14321434
}
14331435

14341436
/// Replace an application of a cast composition f_inverse(f(x)) by x.

lib/SILOptimizer/SILCombiner/SILCombinerMiscVisitors.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ SILCombiner::visitAllocExistentialBoxInst(AllocExistentialBoxInst *AEBI) {
8585
// retain_value %value // must insert the release after this retain
8686
// strong_release %box
8787
Builder.setInsertionPoint(singleRelease);
88-
Builder.createReleaseValue(AEBI->getLoc(), boxedValue,
89-
singleRelease->getAtomicity());
88+
Builder.emitDestroyValueOperation(AEBI->getLoc(), boxedValue);
9089

9190
eraseInstIncludingUsers(AEBI);
9291
return nullptr;

0 commit comments

Comments
 (0)