[all-commits] [llvm/llvm-project] 077991: [ObjC] Emit class msgSend stub calls (#183923)
Akira Hatanaka via All-commits
all-commits at lists.llvm.org
Wed Mar 11 15:22:12 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 077991463253b9295f291d4e4d2078521e518717
https://github.com/llvm/llvm-project/commit/077991463253b9295f291d4e4d2078521e518717
Author: Akira Hatanaka <ahatanak at gmail.com>
Date: 2026-03-11 (Wed, 11 Mar 2026)
Changed paths:
M clang/include/clang/Basic/CodeGenOptions.def
M clang/include/clang/Options/Options.td
M clang/lib/CodeGen/CGObjCMac.cpp
M clang/lib/Driver/ToolChains/Clang.cpp
M clang/lib/Driver/ToolChains/Darwin.cpp
M clang/test/CodeGenObjC/method-selector-stub.m
M clang/test/Driver/darwin-objc-selector-stubs.m
Log Message:
-----------
[ObjC] Emit class msgSend stub calls (#183923)
Instead of translating class messages to `objc_msgSend` calls, clang now
emits calls to stub functions that are synthesized by the linker. Each
stub loads the class reference and the selector name and forwards them
to `objc_msgSend`.
The stub function is named using the following format:
`objc_msgSendClass$selName$_OBJC_CLASS_$_className`
Note that the optimization is disabled in the following cases:
- When the class name is unknown at compile time (e.g, `[id
classMethod]`).
- The selector name contains a `$`, which serves as the delimiter in
stub
function names.
- The class is annotated with either `objc_class_stub` or
`objc_runtime_visible`.
In such cases, clang reverts to the existing message send optimization,
where each stub loads only the selector name.
Also add class objects to llvm.used when class msgSend optimization is
enabled. This is needed as the linker currently cannot generate the
stub,
which references the class object, if LTO internalizes the global
variable
for the class object.
rdar://147604613
---------
Co-authored-by: Ahmed Bougacha <ahmed at bougacha.org>
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list