aschwaighofer marked an inline comment as done.
aschwaighofer added inline comments.


================
Comment at: clang/include/clang/CodeGen/CodeGenABITypes.h:148
+                 llvm::function_ref<llvm::Constant *(const ObjCProtocolDecl *)>
+                     createProtocolReference);
 }  // end namespace CodeGen
----------------
rjmccall wrote:
> aschwaighofer wrote:
> > rjmccall wrote:
> > > I would call this `emitObjCProtocolObject` or something, and maybe say in 
> > > the comment:
> > > 
> > > > Get a pointer to a protocol object for the given declaration, emitting 
> > > > it if it hasn't already been emitted in this translation unit.  Note 
> > > > that the ABI for emitting a protocol reference in code (e.g. for a 
> > > > `@protocol` expression) in most runtimes is not as simple as just 
> > > > materializing a pointer to this object.
> > > 
> > > Can you explain the need for the callback?   Are you expecting to use 
> > > this for Swift-declared protocols by synthesizing an ObjC protocol 
> > > declaration for them?  I can see why you'd need a callback in that case.
> > > Can you explain the need for the callback? Are you expecting to use this 
> > > for Swift-declared protocols by synthesizing an ObjC protocol declaration 
> > > for them? I can see why you'd need a callback in that case.
> > 
> > The objective C protocol references other protocols in its inherited list. 
> > Swift has an internal list that keeps track of those protocols references 
> > and makes sure to initialized them for the debugger and also makes sure 
> > that the underlying protocol structure is emitted. The call back is to keep 
> > this list in sync.
> The problem is that this is really, really intertwined with the ABI logic.  
> This callback basically has to know exactly how the caller is calling it and 
> and what it's expected to build in response.
> 
> Swift code can use arbitrary inline Objective-C functions and therefore emit 
> arbitrary Objective-C code.  Is there an approach that handles that while 
> also being less invasive for Clang IRGen?  Can we, e.g., inspect the built 
> llvm::Module to figure out retroactively what protocol refs we need to update 
> dynamically instead of trying to track them during the build?
Yes. I think you are right. Swift can inspect the generated IR and update it.

https://github.com/aschwaighofer/swift/commit/d29daf41ec3a51405df31591dad6fea97dbc58e0

I have removed the callback.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77077/new/

https://reviews.llvm.org/D77077



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to