rjmccall added a comment. By "in CGObjC", I mean you should be able to do it in CodeGenFunction::EmitObjCMessageExpr. Maybe put it in a separate function like
static llvm::Value *tryGenerateSpecializedMessageSend(...) and then do something like } else if (llvm::Value *SpecializedResult = tryGenerateSpecializedMessageSend(...)) { result = RValue::get(SpecializedResult); } else { right before the call to GenerateMessageSend. ================ Comment at: include/clang/Basic/ObjCRuntime.h:176 @@ +175,3 @@ + /// than an ordinary message send of the appropriate selector? + + /// The ARC entrypoints are guaranteed to be equivalent to just sending the ---------------- The vertical whitespace is good, but please continue the doc comments across it. ================ Comment at: include/clang/Basic/ObjCRuntime.h:207 @@ +206,3 @@ + /// Does this runtime provide entrypoints that are likely to be faster + /// than an ordinary message send of the appropriate selector? + ---------------- You can just say "alloc" here. :) ================ Comment at: include/clang/Driver/Options.td:896 @@ -895,1 +895,3 @@ +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]>, ---------------- It's fine to have both the "yes" and "no" options; I just meant that only the "no" option needs to be a cc1 option. ================ Comment at: lib/CodeGen/CGObjCMac.cpp:1874 @@ +1873,3 @@ + auto &Runtime = CGM.getLangOpts().ObjCRuntime; + if (Method->getMethodFamily() == OMF_alloc && + Runtime.shouldUseRuntimeFunctionsForAlloc()) { ---------------- I'd just write this as a switch over the method family. The runtime check isn't unreasonable to duplicate into each of the cases; also, in the dominant case it will be true, so we're not really saving any work in practice by doing it early. It's the method family check that will usually avoid the rest of the work. We don't really care if we have a method declaration; if there's no method, you can just ask the selector for its method family. That won't be cached, though, and it's implemented with string comparisons, so please be sure to avoid calling it multiple times. Please loosen the type restrictions here. You shouldn't need to restrict the receiver type, and any ObjC pointer type should be fine for the return type. Of course, you'll need to add bitcasts to/from i8*, but that's easy enough. ================ Comment at: lib/CodeGen/CGObjCMac.cpp:1883 @@ +1882,3 @@ + return RValue::get(CGF.EmitObjCAlloc(Arg0)); + } else if (Runtime.shouldUseARCFunctionsForRetainRelease()) { + switch (Method->getMethodFamily()) { ---------------- Oh. Additional check: don't do this if GC != NonGC. ================ Comment at: lib/CodeGen/CGObjCMac.cpp:1897 @@ +1896,3 @@ + if (ResultType->isVoidType() && Arg0Ty->isObjCIdType()) { + CGF.EmitARCRelease(Arg0, ARCImpreciseLifetime); + return RValue::get(nullptr); ---------------- This has precise lifetime, actually. Not that it really matters, since the ARC optimizer should be disabled, but it's best to be correct. http://reviews.llvm.org/D14737 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits