Aaron Gray
2005-Jul-03 22:40 UTC
[LLVMdev] How do you determine whether a function is definedexternally to a module ?
> 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 ! 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 :(> If you take a look at the PowerPC asm printer, it has to do some special > things for external functions as well, it might give you some ideas.I will have a look at this then. Aaron
Aaron Gray
2005-Jul-03 22:53 UTC
[LLVMdev] How do you determine whether a function isdefinedexternally to a module ?
>> If you take a look at the PowerPC asm printer, it has to do some special >> things for external functions as well, it might give you some ideas. > > I will have a look at this then.AFAICS there is nothing special here (PowerPCAsmPrinter.cpp). Aaron
Aaron Gray
2005-Jul-03 23:15 UTC
[LLVMdev] How do you determine whether a functionisdefinedexternally to a module ?
I have tried the following :- if (!M.empty()) for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) if ( !I->getIntrinsicID() && I->getEntryBlock().empty()) O << "EXTERN " << Mang->getValueName(I) << " : NEAR" << "\n"; Based upon :- virtual bool Function::isExternal() const { return BasicBlocks.empty(); } But it does not work either. Which means there must be a BasicBlock occuring on undefined/external functions. Anyway no hurry I am off to do other tasks for a day or so. Aaron -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20050704/0d66579c/attachment.html>
Chris Lattner
2005-Jul-05 17:07 UTC
[LLVMdev] How do you determine whether a function is definedexternally to a module ?
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/
Aaron Gray
2005-Jul-05 17:43 UTC
[LLVMdev] How do you determine whether a function isdefinedexternally to a module ?
> Which functions in particular are you not seeing?_alloc and _free>> 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.I was getting confused by the feature test cases. So am now writting my own. Sorry It was late and I have just not been looking at things quite properly and so have been getting confused. if (!M.empty()) for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F) if ( !F->getIntrinsicID() && F->isExternal()) O << "EXTERN " << Mang->getValueName(F) << " : NEAR" << "\n"; The above works fine with normal external functions. Regarding _alloc and _free they do not seem to be added to the external functions when they are used in the test case "feature/testmemory.ll", so should I include such cases in an include file or add them to the head of the generated file or something like that. Doing quite well now. I have just got to deal with STRUC's as the MASM assembler requires some level of typing. And then produce some conclusive purpose written test cases. I should take a rest and then perservere a bit more before panicing and asking for help ! Cheers, Aaron -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20050705/17233e37/attachment.html>
Reasonably Related Threads
- [LLVMdev] How do you determine whether a function is definedexternally to a module ?
- [LLVMdev] How do you determine whether a functionisdefinedexternally to a module ?
- [LLVMdev] How do you determine whether a function is definedexternally to a module ?
- [LLVMdev] How do you determine whether a function is defined externally to a module ?
- [LLVMdev] How do you determine whether a function is defined externally to a module ?