[LLVMdev] Clang's approach to anonymous struct pointer parameters

Rick Mann rmann at latencyzero.com
Sun Jan 20 01:57:37 PST 2013


For the following code:

    struct XBeePacket;
    
    typedef void (*CompletionProc)(XBeePacket* inPacket, void* inParam2);
    
    struct
    XBeePacket
    {
        bool            mField1;
        CompletionProc  mCompletionProc;
    };

Why does clang emit this IR?

    %struct.XBeePacket = type { i8, {}* }
    
    define void
    @MyCompletionProc(%struct.XBeePacket* %inPacket, i8* %inParam2)
        nounwind uwtable ssp
    {
    entry:
      ...
    }

It makes the struct field for the completion proc an an anonymous aggregate pointer. Is that better than making the first parameter to MyCompletionProc void* or something similar?

I guess there's no way in LLVM IR to forward-declare in a way that solves this, huh?

-- 
Rick







More information about the llvm-dev mailing list