huwei8717
2010-Nov-30 04:42 UTC
[LLVMdev] the definitions of internal functions and external functions
Hi, I have a llvm pass in hand written by other people. There are following statements that I couldn't understand: -------------------------------program---------------------------------------------------- ... // Calls to internal functions. if (!F->isDeclaration()) { DOUT << " internal call" << opcode << ": " << name << "\n"; return ...; } // Calls to external functions ... ------------------------------------------------------------------------------------------- My question is: What's the definitions of internal functions and external functions? In c, internal functions is functions that it is only called in the file where it defines using keyword "static", external functions is functions that can be called by other files, defining using keyword "external". Are these definitions identical with the definitions in llvm? Thank you very much. Best Regards 2010-11-30 WeiHu -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20101130/84ca4d08/attachment.html>
Duncan Sands
2010-Nov-30 09:55 UTC
[LLVMdev] the definitions of internal functions and external functions
Hi WeiHu,> I have a llvm pass in hand written by other people. There are following > statements that I couldn't understand: > -------------------------------program---------------------------------------------------- > ... > // Calls to internal functions. > if (!F->isDeclaration()) { > DOUT << " internal call" << opcode << ": " << name << "\n"; > return ...; > } > // Calls to external functions > ... > ------------------------------------------------------------------------------------------- > My question is: > What's the definitions of internal functions and external functions? In c, > internal functions is functions that it is only called in the file where it > defines using keyword "static", external functions is functions that can be > called by other files, defining using keyword "external". Are these definitions > identical with the definitions in llvm?the comments in your pass are misleading. In LLVM, as in C, external functions are those not defined in the module. If "F->isDeclaration()" is true, then F is an external function. If F is not an external function, then it is defined in the module. It may or may not have internal linkage (internal linkage -> static in C). To be honest there are several linkage types that mean that the function is not externally visible, see the isLocalLinkage method in GlobalValue.h. Ciao, Duncan.