[LLVMdev] Anonymous Structures

Nick Johnson npjohnso at cs.princeton.edu
Wed Apr 29 07:53:37 PDT 2009


Hello,

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).  Foo has many fields, strange
target-dependent alignment requirements, and is likely to change many
times in the future.  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.

Is there any way to refer to this structure by name, instead of
specifying its contents?  Is this a place where I should use
OpaqueType?  Could anyone provide examples please?

Thank you,
-- 
Nick Johnson



More information about the llvm-dev mailing list