@@ -997,11 +997,16 @@ void IRGenFunction::emitNativeStrongRetain(llvm::Value *value,
997997 value = Builder.CreateBitCast (value, IGM.RefCountedPtrTy );
998998
999999 // Emit the call.
1000- llvm::CallInst *call = Builder.CreateCall (
1001- (atomicity == Atomicity::Atomic)
1002- ? IGM.getNativeStrongRetainFunctionPointer ()
1003- : IGM.getNativeNonAtomicStrongRetainFunctionPointer (),
1004- value);
1000+ FunctionPointer function;
1001+ if (atomicity == Atomicity::Atomic &&
1002+ IGM.TargetInfo .HasSwiftClientRRLibrary &&
1003+ getOptions ().EnableClientRetainRelease )
1004+ function = IGM.getNativeStrongRetainClientFunctionPointer ();
1005+ else if (atomicity == Atomicity::Atomic)
1006+ function = IGM.getNativeStrongRetainFunctionPointer ();
1007+ else
1008+ function = IGM.getNativeNonAtomicStrongRetainFunctionPointer ();
1009+ llvm::CallInst *call = Builder.CreateCall (function, value);
10051010 call->setDoesNotThrow ();
10061011 call->addParamAttr (0 , llvm::Attribute::Returned);
10071012}
@@ -1257,10 +1262,16 @@ void IRGenFunction::emitNativeStrongRelease(llvm::Value *value,
12571262 Atomicity atomicity) {
12581263 if (doesNotRequireRefCounting (value))
12591264 return ;
1260- emitUnaryRefCountCall (*this , (atomicity == Atomicity::Atomic)
1261- ? IGM.getNativeStrongReleaseFn ()
1262- : IGM.getNativeNonAtomicStrongReleaseFn (),
1263- value);
1265+ llvm::Constant *function;
1266+ if (atomicity == Atomicity::Atomic &&
1267+ IGM.TargetInfo .HasSwiftClientRRLibrary &&
1268+ getOptions ().EnableClientRetainRelease )
1269+ function = IGM.getNativeStrongReleaseClientFn ();
1270+ else if (atomicity == Atomicity::Atomic)
1271+ function = IGM.getNativeStrongReleaseFn ();
1272+ else
1273+ function = IGM.getNativeNonAtomicStrongReleaseFn ();
1274+ emitUnaryRefCountCall (*this , function, value);
12641275}
12651276
12661277void IRGenFunction::emitNativeSetDeallocating (llvm::Value *value) {
@@ -1353,20 +1364,30 @@ void IRGenFunction::emitUnknownStrongRelease(llvm::Value *value,
13531364
13541365void IRGenFunction::emitBridgeStrongRetain (llvm::Value *value,
13551366 Atomicity atomicity) {
1356- emitUnaryRefCountCall (*this ,
1357- (atomicity == Atomicity::Atomic)
1358- ? IGM.getBridgeObjectStrongRetainFn ()
1359- : IGM.getNonAtomicBridgeObjectStrongRetainFn (),
1360- value);
1367+ llvm::Constant *function;
1368+ if (atomicity == Atomicity::Atomic &&
1369+ IGM.TargetInfo .HasSwiftClientRRLibrary &&
1370+ getOptions ().EnableClientRetainRelease )
1371+ function = IGM.getBridgeObjectStrongRetainClientFn ();
1372+ else if (atomicity == Atomicity::Atomic)
1373+ function = IGM.getBridgeObjectStrongRetainFn ();
1374+ else
1375+ function = IGM.getNonAtomicBridgeObjectStrongRetainFn ();
1376+ emitUnaryRefCountCall (*this , function, value);
13611377}
13621378
13631379void IRGenFunction::emitBridgeStrongRelease (llvm::Value *value,
13641380 Atomicity atomicity) {
1365- emitUnaryRefCountCall (*this ,
1366- (atomicity == Atomicity::Atomic)
1367- ? IGM.getBridgeObjectStrongReleaseFn ()
1368- : IGM.getNonAtomicBridgeObjectStrongReleaseFn (),
1369- value);
1381+ llvm::Constant *function;
1382+ if (atomicity == Atomicity::Atomic &&
1383+ IGM.TargetInfo .HasSwiftClientRRLibrary &&
1384+ getOptions ().EnableClientRetainRelease )
1385+ function = IGM.getBridgeObjectStrongReleaseClientFn ();
1386+ else if (atomicity == Atomicity::Atomic)
1387+ function = IGM.getBridgeObjectStrongReleaseFn ();
1388+ else
1389+ function = IGM.getNonAtomicBridgeObjectStrongReleaseFn ();
1390+ emitUnaryRefCountCall (*this , function, value);
13701391}
13711392
13721393void IRGenFunction::emitErrorStrongRetain (llvm::Value *value) {
0 commit comments