[llvm-branch-commits] [clang] [ExposeObjCDirect] Optimizations (PR #170619)
Oliver Hunt via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Feb 4 20:08:45 PST 2026
================
@@ -415,11 +417,87 @@ bool CGObjCRuntime::canMessageReceiverBeNull(
bool CGObjCRuntime::canClassObjectBeUnrealized(
const ObjCInterfaceDecl *CalleeClassDecl, CodeGenFunction &CGF) const {
- // TODO
+ if (!CalleeClassDecl || isWeakLinkedClass(CalleeClassDecl))
+ return true;
+
+ // Heuristic 1: +load method on this class or any subclass
+ // If the class or any of its subclasses has a +load method, it's realized
+ // when the binary is loaded. We cache this information to avoid repeatedly
+ // scanning the translation unit.
+ if (getOrPopulateRealizedClasses().contains(CalleeClassDecl))
+ return false;
----------------
ojhunt wrote:
this can be simplified to whatever the query function is called, which removes the need for a detailed comment - the function name explains the check, the rationale for what goes into the cache lives in the construction of that cache, and is much clearer because you're looking at the implementation.
https://github.com/llvm/llvm-project/pull/170619
More information about the llvm-branch-commits
mailing list