[LLVMdev] the definitions of internal functions and external functions

Duncan Sands baldrick at free.fr
Tue Nov 30 01:55:48 PST 2010


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.



More information about the llvm-dev mailing list