Consider C code
void foo();
int main(void) {
foo();
return 0;
}
void foo(void) {
int a =10;
}
Bitcode generated by clang with –O0 is :
define i32 @main() nounwind {
entry:
%retval = alloca i32 ; <i32*> [#uses=3]
store i32 0, i32* %retval
call void (…)* bitcast (void ()* @foo to void (…)*)()
store i32 0, i32* %retval
%0 = load i32* %retval ; [#uses=1]
ret i32 %0
}
define void @foo() nounwind {
entry:
%a = alloca i32, align 4 ; <i32*> [#uses=1]
store i32 10, i32* %a
ret void
}
Bitcode generated by llvm-ld with –disable-opt and –basiccg options is:
define i32 @main() nounwind {
entry:
%retval = alloca i32 ; <i32*> [#uses=3]
store i32 0, i32* %retval
call void (…)* bitcast (void ()* @foo to void (…)*)()
store i32 0, i32* %retval
%0 = load i32* %retval ; [#uses=1]
ret i32 %0
}
define void @foo() nounwind {
entry:
%a = alloca i32, align 4 ; <i32*> [#uses=1]
store i32 10, i32* %a
ret void
}
My point is why is the call to foo not resolved correctly in llvm-ld. Here if I try to make use of the call graph pass to get the call graph, I do not get the complete call graph.
Thanks
Vasudev