[LLVMdev] Anonymous Structures

Gordon Henriksen gordonhenriksen at me.com
Wed Apr 29 08:17:27 PDT 2009


On 2009-04-29, at 10:53, Nick Johnson wrote:

> I am writing a pass which must insert calls to an external library.  
> One of the parameters to functions in this library is a very large,  
> complex structure (let's call it Foo).  [...]  The internal  
> representation of Foo is important to this library, but the code my  
> pass generates will only deal with Foo-pointers.
>
> For these reasons, I do not want my pass to emit a definition for  
> struct Foo.  However, to add an external reference to the library  
> functions, I must supply function signatures that include this  
> structure type.  Casting to/from void pointers works, but ultimately  
> generates suboptimal code.

When your pass inserts calls, try declaring the function declarations  
to take i8* or %Foo* (where type %Foo = opaque). LLVM will unify the  
declaration's type when linking with the module that defines the symbol.

— Gordon



More information about the llvm-dev mailing list