diff options
Diffstat (limited to 'clang/include')
-rw-r--r-- | clang/include/clang/Basic/ObjCRuntime.h | 37 | ||||
-rw-r--r-- | clang/include/clang/Driver/Options.td | 4 | ||||
-rw-r--r-- | clang/include/clang/Frontend/CodeGenOptions.def | 2 |
3 files changed, 43 insertions, 0 deletions
diff --git a/clang/include/clang/Basic/ObjCRuntime.h b/clang/include/clang/Basic/ObjCRuntime.h index c307c964339..f8b4826d3dd 100644 --- a/clang/include/clang/Basic/ObjCRuntime.h +++ b/clang/include/clang/Basic/ObjCRuntime.h @@ -173,6 +173,43 @@ public: llvm_unreachable("bad kind"); } + /// Does this runtime provide entrypoints that are likely to be faster + /// than an ordinary message send of the "alloc" selector? + /// + /// The "alloc" entrypoint is guaranteed to be equivalent to just sending the + /// corresponding message. If the entrypoint is implemented naively as just a + /// message send, using it is a trade-off: it sacrifices a few cycles of + /// overhead to save a small amount of code. However, it's possible for + /// runtimes to detect and special-case classes that use "standard" + /// alloc behavior; if that's dynamically a large proportion of all + /// objects, using the entrypoint will also be faster than using a message + /// send. + /// + /// When this method returns true, Clang will turn non-super message sends of + /// certain selectors into calls to the corresponding entrypoint: + /// alloc => objc_alloc + /// allocWithZone:nil => objc_allocWithZone + bool shouldUseRuntimeFunctionsForAlloc() const { + switch (getKind()) { + case FragileMacOSX: + return false; + case MacOSX: + return getVersion() >= VersionTuple(10, 10); + case iOS: + return getVersion() >= VersionTuple(8); + case WatchOS: + return true; + + case GCC: + return false; + case GNUstep: + return false; + case ObjFW: + return false; + } + llvm_unreachable("bad kind"); + } + /// Does this runtime supports optimized setter entrypoints? bool hasOptimizedSetter() const { switch (getKind()) { diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index cde7d805077..0a96820734d 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -1473,6 +1473,10 @@ def fno_zero_initialized_in_bss : Flag<["-"], "fno-zero-initialized-in-bss">, Gr def fobjc_arc : Flag<["-"], "fobjc-arc">, Group<f_Group>, Flags<[CC1Option]>, HelpText<"Synthesize retain and release calls for Objective-C pointers">; def fno_objc_arc : Flag<["-"], "fno-objc-arc">, Group<f_Group>; +def fobjc_convert_messages_to_runtime_calls : + Flag<["-"], "fobjc-convert-messages-to-runtime-calls">, Group<f_Group>; +def fno_objc_convert_messages_to_runtime_calls : + Flag<["-"], "fno-objc-convert-messages-to-runtime-calls">, Group<f_Group>, Flags<[CC1Option]>; def fobjc_arc_exceptions : Flag<["-"], "fobjc-arc-exceptions">, Group<f_Group>, Flags<[CC1Option]>, HelpText<"Use EH-safe code when synthesizing retains and releases in -fobjc-arc">; def fno_objc_arc_exceptions : Flag<["-"], "fno-objc-arc-exceptions">, Group<f_Group>; diff --git a/clang/include/clang/Frontend/CodeGenOptions.def b/clang/include/clang/Frontend/CodeGenOptions.def index e531bb80ff5..952aa588b60 100644 --- a/clang/include/clang/Frontend/CodeGenOptions.def +++ b/clang/include/clang/Frontend/CodeGenOptions.def @@ -149,6 +149,8 @@ CODEGENOPT(UniformWGSize , 1, 0) ///< -cl-uniform-work-group-size CODEGENOPT(NoZeroInitializedInBSS , 1, 0) ///< -fno-zero-initialized-in-bss. /// Method of Objective-C dispatch to use. ENUM_CODEGENOPT(ObjCDispatchMethod, ObjCDispatchMethodKind, 2, Legacy) +/// Replace certain message sends with calls to ObjC runtime entrypoints +CODEGENOPT(ObjCConvertMessagesToRuntimeCalls , 1, 1) CODEGENOPT(OmitLeafFramePointer , 1, 0) ///< Set when -momit-leaf-frame-pointer is ///< enabled. |