Skip to content

Commit 6b3e561

Browse files
authored
Merge pull request #86015 from mikeash/client-rr-cmake-default
[IRGen] Add a CMake option to configure direct retain/release enablement.
2 parents b3ee390 + 6629479 commit 6b3e561

File tree

6 files changed

+15
-9
lines changed

6 files changed

+15
-9
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,10 @@ option(SWIFT_ENABLE_EXPERIMENTAL_PARSER_VALIDATION
804804
"Enable experimental SwiftParser validation by default"
805805
FALSE)
806806

807+
option(SWIFT_ENABLE_DIRECT_RETAIN_RELEASE
808+
"Enable use of direct refcounting calls by default"
809+
FALSE)
810+
807811
cmake_dependent_option(SWIFT_BUILD_SOURCEKIT
808812
"Build SourceKit" TRUE
809813
"SWIFT_ENABLE_DISPATCH" FALSE)

include/swift/AST/IRGenOptions.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ class IRGenOptions {
560560
unsigned MergeableTraps : 1;
561561

562562
/// Enable the use of swift_retain/releaseDirect functions.
563-
unsigned EnableSwiftDirectRuntime : 1;
563+
unsigned EnableSwiftDirectRetainRelease : 1;
564564

565565
/// The number of threads for multi-threaded code generation.
566566
unsigned NumThreads = 0;
@@ -689,7 +689,7 @@ class IRGenOptions {
689689
EmitAsyncFramePushPopMetadata(true), EmitTypeMallocForCoroFrame(true),
690690
AsyncFramePointerAll(false), UseProfilingMarkerThunks(false),
691691
UseCoroCCX8664(false), UseCoroCCArm64(false), MergeableTraps(false),
692-
EnableSwiftDirectRuntime(false),
692+
EnableSwiftDirectRetainRelease(SWIFT_ENABLE_DIRECT_RETAIN_RELEASE),
693693
DebugInfoForProfiling(false), CmdArgs(),
694694
SanitizeCoverage(llvm::SanitizerCoverageOptions()),
695695
TypeInfoFilter(TypeInfoDumpFilter::All),

include/swift/Config.h.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@
1616

1717
#cmakedefine01 SWIFT_ENABLE_EXPERIMENTAL_PARSER_VALIDATION
1818

19+
#cmakedefine01 SWIFT_ENABLE_DIRECT_RETAIN_RELEASE
20+
1921
#endif // SWIFT_CONFIG_H

lib/Frontend/CompilerInvocation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4046,10 +4046,10 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
40464046

40474047
Opts.MergeableTraps = Args.hasArg(OPT_mergeable_traps);
40484048

4049-
Opts.EnableSwiftDirectRuntime =
4049+
Opts.EnableSwiftDirectRetainRelease =
40504050
Args.hasFlag(OPT_enable_direct_retain_release,
40514051
OPT_disable_direct_retain_release,
4052-
Opts.EnableSwiftDirectRuntime);
4052+
Opts.EnableSwiftDirectRetainRelease);
40534053

40544054
Opts.EnableObjectiveCProtocolSymbolicReferences =
40554055
Args.hasFlag(OPT_enable_objective_c_protocol_symbolic_references,

lib/IRGen/GenHeap.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ void IRGenFunction::emitNativeStrongRetain(llvm::Value *value,
10001000
FunctionPointer function;
10011001
if (atomicity == Atomicity::Atomic &&
10021002
IGM.TargetInfo.HasSwiftSwiftDirectRuntimeLibrary &&
1003-
getOptions().EnableSwiftDirectRuntime)
1003+
getOptions().EnableSwiftDirectRetainRelease)
10041004
function = IGM.getNativeStrongRetainDirectFunctionPointer();
10051005
else if (atomicity == Atomicity::Atomic)
10061006
function = IGM.getNativeStrongRetainFunctionPointer();
@@ -1265,7 +1265,7 @@ void IRGenFunction::emitNativeStrongRelease(llvm::Value *value,
12651265
llvm::Constant *function;
12661266
if (atomicity == Atomicity::Atomic &&
12671267
IGM.TargetInfo.HasSwiftSwiftDirectRuntimeLibrary &&
1268-
getOptions().EnableSwiftDirectRuntime)
1268+
getOptions().EnableSwiftDirectRetainRelease)
12691269
function = IGM.getNativeStrongReleaseDirectFn();
12701270
else if (atomicity == Atomicity::Atomic)
12711271
function = IGM.getNativeStrongReleaseFn();
@@ -1373,7 +1373,7 @@ void IRGenFunction::emitBridgeStrongRetain(llvm::Value *value,
13731373
llvm::Constant *function;
13741374
if (atomicity == Atomicity::Atomic &&
13751375
IGM.TargetInfo.HasSwiftSwiftDirectRuntimeLibrary &&
1376-
getOptions().EnableSwiftDirectRuntime)
1376+
getOptions().EnableSwiftDirectRetainRelease)
13771377
function = IGM.getBridgeObjectStrongRetainDirectFn();
13781378
else if (atomicity == Atomicity::Atomic)
13791379
function = IGM.getBridgeObjectStrongRetainFn();
@@ -1387,7 +1387,7 @@ void IRGenFunction::emitBridgeStrongRelease(llvm::Value *value,
13871387
llvm::Constant *function;
13881388
if (atomicity == Atomicity::Atomic &&
13891389
IGM.TargetInfo.HasSwiftSwiftDirectRuntimeLibrary &&
1390-
getOptions().EnableSwiftDirectRuntime)
1390+
getOptions().EnableSwiftDirectRetainRelease)
13911391
function = IGM.getBridgeObjectStrongReleaseDirectFn();
13921392
else if (atomicity == Atomicity::Atomic)
13931393
function = IGM.getBridgeObjectStrongReleaseFn();

lib/IRGen/IRGenModule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1743,7 +1743,7 @@ void IRGenModule::addLinkLibraries() {
17431743
LinkLibrary{"objc", LibraryKind::Library, /*static=*/false});
17441744

17451745
if (TargetInfo.HasSwiftSwiftDirectRuntimeLibrary &&
1746-
getOptions().EnableSwiftDirectRuntime)
1746+
getOptions().EnableSwiftDirectRetainRelease)
17471747
registerLinkLibrary(LinkLibrary{"swiftSwiftDirectRuntime",
17481748
LibraryKind::Library, /*static=*/true});
17491749

0 commit comments

Comments
 (0)