[LLVMdev] Call graph node for function: 'main' Calls external node
Duncan Sands
baldrick at free.fr
Tue May 4 12:11:59 PDT 2010
Hi Gener,
> For the main function, the output of the above command is:
>
> Call graph node for function: 'main'
> Calls external node
this means that callgraph saw that main calls something, but it doesn't
know what it is. It might be any function, internal (eg: f2) or external.
The reason for this poor quality information is that the use of the forward
declaration "void f2();", which should be "void f2(void);", results in some
unpleasantness in the bitcode. If you run the optimizers it will be cleaned
up. Take a look at this: without optimization and with mild optimization:
$ llvm-gcc -c -o - cg.c -emit-llvm -O0 | opt -print-callgraph -disable-output
2>&1 | grep "function: 'main'" -A 2
Call graph node for function: 'main'<<0x2f80c30>> #uses=1
CS<0x2f837b8> calls external node
$ llvm-gcc -c -o - cg.c -emit-llvm -O1 | opt -print-callgraph -disable-output
2>&1 | grep "function: 'main'" -A 2
Call graph node for function: 'main'<<0x20536c0>> #uses=1
CS<0x2057468> calls function 'f2'
The callgraph code doesn't try to be clever. It assumes that the optimizers
have been run.
Ciao,
Duncan.
More information about the llvm-dev
mailing list