How is first function called?

47 views
Skip to first unread message

Arpit Aggarwal

unread,
May 21, 2017, 2:53:27 PM5/21/17
to llgo-dev

Hi Andrew,
Can you please tell me how the first function called in LLVM IR.
I just printed the control flow graph for the following go program using its LLVM IR produced through llgo

package main
func add(x int, y int) int {
    return x + y
}
func main(){
  x:=5
  y:=10
  y=add(x,y)
}

Can you please explain me a little about this external variable and how is the first function being called?
How is main.main called?
I have also attached the LLVM IR file (readable).

Thanks a lot in advance.

Regards
Arpit
most_basic.ll

Andrew Wilkins

unread,
May 21, 2017, 10:54:40 PM5/21/17
to llgo...@googlegroups.com
On Mon, 22 May 2017 at 02:53 Arpit Aggarwal <arpit9...@gmail.com> wrote:

Hi Andrew,
Can you please tell me how the first function called in LLVM IR.
I just printed the control flow graph for the following go program using its LLVM IR produced through llgo

package main
func add(x int, y int) int {
    return x + y
}
func main(){
  x:=5
  y:=10
  y=add(x,y)
}

Can you please explain me a little about this external variable and how is the first function being called?
How is main.main called?

llgo uses the libgo runtime from gofrontend/gccgo, which takes care of the process startup: it defines the entry point that (indirectly) calls through to the "main" function, defined in the libgo runtime:

That calls runtime_main, which does some initialisation and then calls main.main:

Cheers,
Andrew

I have also attached the LLVM IR file (readable).

Thanks a lot in advance.

Regards
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 22, 2017, 12:31:15 AM5/22/17
to llgo-dev
Thanks a lot Andrew.

Regards
Arpit
Reply all
Reply to author
Forward
0 new messages