[PATCH] D86049: RFC: Implement optional exportable wrapper function generation for objc_direct methods.

Puyan Lotfi via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 17 00:40:06 PDT 2020


plotfi created this revision.
plotfi added reviewers: rjmccall, manmanren, MadCoder.
Herald added subscribers: cfe-commits, dang.
Herald added a project: clang.
plotfi requested review of this revision.

Hi @rjmccall @MadCoder

I'd like to preface this diff: I mostly want to discuss the prospects of exporting generated wrappers that call objc_direct methods, or alternately exporting the objc_direct methods themselves when an optional CodeGenOpts command-line flag is specified. This diff implements generating wrappers when a CodeGenOpts command-line flag is provided since C wrappers were mentioned in the original objc_direct diff. However I do think it might be possible to export the methods directly provided the implicit '_' underbar prefix is prepended to satisfy C naming on Darwin, and if thats the case I can post a diff that does that instead.  Anyways, thats all I wanted to preface with. Thanks.

Motivated by the potential benefit of using the objc_direct attribute, this diff aims to expand support to cross dylib objc_direct method calls by automatically generating exportable wrapper functions that call objc_direct methods internal to a dylib.

In the original patch landed in https://reviews.llvm.org/D69991 it mentions:

"The symbol for the method has enforced hidden visibility and such direct
calls are hence unreachable cross image. An explicit C function must be
made if so desired to wrap them."

This change provides a codegen options flag to clang `-fobjc-export-direct-method-wrappers` to generate the wrapper functions that begin with the prefix __objc_direct_wrapper and are marked as __attribute__((alwaysinline)). This way within a link unit the wrapper functions should be inlined away at their call sites, but across a dylib boundary the wrapper call is used.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86049

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/CGObjCMac.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86049.285923.patch
Type: text/x-patch
Size: 6854 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200817/ff5de2a4/attachment.bin>


More information about the cfe-commits mailing list