Skip to content

Commit f0f9351

Browse files
committed
[NFC] IRGen: Extracted callOutlinedRelease.
In preparation to sometimes use a metadata collector.
1 parent 93595e4 commit f0f9351

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

lib/IRGen/IRGenSIL.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5098,15 +5098,9 @@ void IRGenSILFunction::visitReleaseValueAddrInst(
50985098
if (tryEmitDestroyUsingDeinit(*this, addr, addrTy)) {
50995099
return;
51005100
}
5101-
llvm::Type *llvmType = addr.getAddress()->getType();
51025101
const TypeInfo &addrTI = getTypeInfo(addrTy);
51035102
auto atomicity = i->isAtomic() ? Atomicity::Atomic : Atomicity::NonAtomic;
5104-
auto *outlinedF = cast<llvm::Function>(
5105-
IGM.getOrCreateReleaseFunction(addrTI, objectT, llvmType, atomicity));
5106-
llvm::Value *args[] = {addr.getAddress()};
5107-
llvm::CallInst *call =
5108-
Builder.CreateCall(outlinedF->getFunctionType(), outlinedF, args);
5109-
call->setCallingConv(IGM.DefaultCC);
5103+
addrTI.callOutlinedRelease(*this, addr, objectT, atomicity);
51105104
}
51115105

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

lib/IRGen/Outlining.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,17 @@ llvm::Constant *IRGenModule::getOrCreateRetainFunction(const TypeInfo &ti,
443443
true /*setIsNoInline*/);
444444
}
445445

446+
void TypeInfo::callOutlinedRelease(IRGenFunction &IGF, Address addr, SILType T,
447+
Atomicity atomicity) const {
448+
llvm::Type *llvmType = addr.getAddress()->getType();
449+
auto *outlinedF = cast<llvm::Function>(
450+
IGF.IGM.getOrCreateReleaseFunction(*this, T, llvmType, atomicity));
451+
llvm::Value *args[] = {addr.getAddress()};
452+
llvm::CallInst *call =
453+
IGF.Builder.CreateCall(outlinedF->getFunctionType(), outlinedF, args);
454+
call->setCallingConv(IGF.IGM.DefaultCC);
455+
}
456+
446457
llvm::Constant *
447458
IRGenModule::getOrCreateReleaseFunction(const TypeInfo &ti,
448459
SILType t,

lib/IRGen/TypeInfo.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,9 @@ class TypeInfo {
583583
IsTake_t isTake) const;
584584

585585
void callOutlinedDestroy(IRGenFunction &IGF, Address addr, SILType T) const;
586+
587+
void callOutlinedRelease(IRGenFunction &IGF, Address addr, SILType T,
588+
Atomicity atomicity) const;
586589
};
587590

588591
} // end namespace irgen

0 commit comments

Comments
 (0)