Skip to content

Commit 79784a8

Browse files
committed
IRGen: Replace retail_value_addr implementation by destroy_addr's
We can't always use an outlined function, destroy_addr's implementation already handles cases where this is true (such as opened archetypes). rdar://143456806
1 parent c95c452 commit 79784a8

File tree

2 files changed

+11
-20
lines changed

2 files changed

+11
-20
lines changed

lib/IRGen/IRGenSIL.cpp

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5399,18 +5399,14 @@ void IRGenSILFunction::visitRetainValueInst(swift::RetainValueInst *i) {
53995399
void IRGenSILFunction::visitRetainValueAddrInst(swift::RetainValueAddrInst *i) {
54005400
SILValue operandValue = i->getOperand();
54015401
assert(!operandValue->getType().isMoveOnly());
5402-
Address addr = getLoweredAddress(operandValue);
5403-
SILType addrTy = operandValue->getType();
5404-
SILType objectT = addrTy.getObjectType();
5405-
llvm::Type *llvmType = addr.getAddress()->getType();
5406-
const TypeInfo &addrTI = getTypeInfo(addrTy);
5407-
auto atomicity = i->isAtomic() ? Atomicity::Atomic : Atomicity::NonAtomic;
5408-
auto *outlinedF = cast<llvm::Function>(
5409-
IGM.getOrCreateRetainFunction(addrTI, objectT, llvmType, atomicity));
5410-
llvm::Value *args[] = {addr.getAddress()};
5411-
llvm::CallInst *call =
5412-
Builder.CreateCall(outlinedF->getFunctionType(), outlinedF, args);
5413-
call->setCallingConv(IGM.DefaultCC);
5402+
5403+
auto objTy = operandValue->getType().getObjectType();
5404+
const TypeInfo &type = getTypeInfo(objTy);
5405+
auto stackAddr = type.allocateStack(*this, objTy, "retain.value.addr.tmp");
5406+
Address src = getLoweredAddress(operandValue);
5407+
type.initializeWithCopy(*this, stackAddr.getAddress(), src,
5408+
operandValue->getType(), false);
5409+
type.deallocateStack(*this, stackAddr, operandValue->getType());
54145410
}
54155411

54165412
void IRGenSILFunction::visitCopyValueInst(swift::CopyValueInst *i) {
@@ -5489,15 +5485,10 @@ void IRGenSILFunction::visitReleaseValueInst(swift::ReleaseValueInst *i) {
54895485
void IRGenSILFunction::visitReleaseValueAddrInst(
54905486
swift::ReleaseValueAddrInst *i) {
54915487
SILValue operandValue = i->getOperand();
5492-
Address addr = getLoweredAddress(operandValue);
54935488
SILType addrTy = operandValue->getType();
5494-
SILType objectT = addrTy.getObjectType();
5495-
if (tryEmitDestroyUsingDeinit(*this, addr, addrTy)) {
5496-
return;
5497-
}
54985489
const TypeInfo &addrTI = getTypeInfo(addrTy);
5499-
auto atomicity = i->isAtomic() ? Atomicity::Atomic : Atomicity::NonAtomic;
5500-
addrTI.callOutlinedRelease(*this, addr, objectT, atomicity);
5490+
Address base = getLoweredAddress(operandValue);
5491+
addrTI.destroy(*this, base, addrTy, false /*isOutlined*/);
55015492
}
55025493

55035494
void IRGenSILFunction::visitDestroyValueInst(swift::DestroyValueInst *i) {

test/IRGen/moveonly_deinit.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ entry(%b : $*MOEnum):
209209

210210
// CHECK-LABEL: define{{.*}}@destroy_combo_struct_value(
211211
// CHECK-NEXT: entry:
212-
// CHECK-NEXT: call {{.*}} @[[COMBO_STRUCT_OUTLINED_DESTROY:"\$.*13MOComboStructVWOs"]](
212+
// CHECK-NEXT: call {{.*}} @[[COMBO_STRUCT_OUTLINED_DESTROY:"\$.*13MOComboStructVWOh"]](
213213
// CHECK-NEXT: ret void
214214
sil @destroy_combo_struct_value : $@convention(thin) (@owned MOComboStruct) -> () {
215215
entry(%b : $MOComboStruct):

0 commit comments

Comments
 (0)