LLVM IR extra parameter in every function

44 views
Skip to first unread message

Arpit Aggarwal

unread,
May 17, 2017, 6:38:05 AM5/17/17
to llgo-dev
Hi all,
Every function in LLVM-IR of any Go program has an additional parameter as i8* nest.
Can you please tell me what it is and the use of it?

Thanks in advance

Thanks
Arpit

Andrew Wilkins

unread,
May 17, 2017, 9:01:25 PM5/17/17
to llgo...@googlegroups.com
On Wed, 17 May 2017 at 18:38 Arpit Aggarwal <arpit9...@gmail.com> wrote:
Hi all,
Every function in LLVM-IR of any Go program has an additional parameter as i8* nest.
Can you please tell me what it is and the use of it?

The nest parameter is to support closures: the closure is passed in via that nest parameter. Because the caller can't always know whether its callee expects a closure or not, all functions are given a nest parameter.

A function value is represented as two pointers: the function itself, and a pointer to a struct containing closure variables. When making a dynamic function call, the closure struct pointer is passed in via the nest parameter. For a function that doesn't expect a closure, that will be ignored.

Cheers,
Andrew

Thanks in advance

Thanks
Arpit

--
You received this message because you are subscribed to the Google Groups "llgo-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to llgo-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Arpit Aggarwal

unread,
May 18, 2017, 3:14:55 AM5/18/17
to llgo-dev
Thanks a lot Andrew.

Regards,
Arpit
Reply all
Reply to author
Forward
0 new messages