[LLVMdev] How do you determine whether a function is definedexternally to a module ?

Chris Lattner sabre at nondot.org
Tue Jul 5 10:07:24 PDT 2005


On Sun, 3 Jul 2005, Aaron Gray wrote:
>> Something like this should work:
>> 
>> for (Module::iterator F = M->begin(), E = M->end(); F != E; ++F)
>>   if (F->isExternal())
>>     ... Function* F is external! ...
>
> This is not working. For some reason there is a BasicBlock present on 
> undefined functions !

Which functions in particular are you not seeing?

> I am compiling the examples from llvm/test/feature, about 28 out of 34 
> assemble fine. Just cannot seem to get the externals listed, been trying for 
> several hours :(

There are two types of external functions that the code generator deals 
with: external functions that are present in the LLVM program, and 
external functions used by the code generator.  I suspect that you are 
hitting cases where the later are not getting printed.

If you look at the PowerPCAsmPrinter.cpp it has to do very similar things 
to what you are doing.  Note that it uses a "FnStubs" set to collect 
references to external functions as they are emitted.  Once it builds this 
set, it emits a stub for each external function at the bottom of the file. 
I think you should do something similar to this.

-Chris

-- 
http://nondot.org/sabre/
http://llvm.cs.uiuc.edu/




More information about the llvm-dev mailing list