[llvm-dev] How to create a call to a function which returns a struct

Manuel Jacob via llvm-dev
Wed, 23 May 2018 09:06:16 -0000

On 2018-05-23 05:12, SANGEETA CHOWDHARY via llvm-dev
wrote:
> I am trying to create a call to a function which returns a struct in
> llvm pass. I also want to read struct fields returned from this
> function call. Can somebody help me with this?

You call the function like every other function.  You can then extract
the fields with the 'extractvalue' instruction
(http://llvm.org/docs/LangRef.html#extractvalue-instruction).  In a
pass, usually these instructions are created with a IRBuilder.  If you
don't already know about it, you'll find many examples in the LLVM code
base (for example under lib/Transforms/).