Hi All, I’ve got a question about Module::getOrInsertFunction(). I got an impression that it is not deterministic where exactly in the bit code module the new function will be inserted. Is there a way to make it deterministic by explicitly specifying some offset at which the function should be inserted? Please correct me if I’m wrong. Thank you very much in advance for help, Best regards, Tomek -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140529/f2feb55a/attachment.html>
Hi Tomek,> I’ve got a question about Module::getOrInsertFunction(). > I got an impression that it is not deterministic where exactly in the bit > code module the new function will be inserted.Looking at the code (not exhaustively), it seems a new function will always be added to the end of a module. Documenting that probably wouldn't be a terrible idea, but it shouldn't affect anything except the human-readability of LLVM IR. Are you trying to do something where it is actually causing problems? Cheers. Tim.
Hi Tim, Thank you very much for quick response. What happens in my case is that mixing calls to getOrInsertFunction with linking another bit code module to the current module seems to be sometimes producing different outputs. Difference might be with the ordering of functions in the file (I¹m looking at LLVM IR representation), with numbers used for constant variables, numbers used in the ³dbg² metadata. Since sometimes the diff is not trivial to analyse I just wasn¹t sure if I only get these sort of differences and not differences like actual instructions being reordered. Do you know what might be the cause of these differences? Thank you, Tomek On 29/05/2014 19:06, "Tim Northover" <t.p.northover at gmail.com> wrote:>Hi Tomek, > >> I¹ve got a question about Module::getOrInsertFunction(). >> I got an impression that it is not deterministic where exactly in the >>bit >> code module the new function will be inserted. > >Looking at the code (not exhaustively), it seems a new function will >always be added to the end of a module. > >Documenting that probably wouldn't be a terrible idea, but it >shouldn't affect anything except the human-readability of LLVM IR. Are >you trying to do something where it is actually causing problems? > >Cheers. > >Tim.
On 05/29/2014 11:06 AM, Tim Northover wrote:> Hi Tomek, > >> I’ve got a question about Module::getOrInsertFunction(). >> I got an impression that it is not deterministic where exactly in the bit >> code module the new function will be inserted. > Looking at the code (not exhaustively), it seems a new function will > always be added to the end of a module. > > Documenting that probably wouldn't be a terrible idea, but it > shouldn't affect anything except the human-readability of LLVM IR. Are > you trying to do something where it is actually causing problems? > > Cheers. > > Tim.I would argue in favor of leaving this explicitly undocumented. I don't see the use case in knowing where in a module it got added, and it restricts future implementations in ways we can't predict. Documenting that it must be deterministic is fine. Documenting where it decides to place it is not. Tomek, could you spell out why you need the position? Maybe there's another option here. Philip
Possibly Parallel Threads
- [LLVMdev] Module::getOrInsertFunction determinism
- [LLVMdev] Module::getOrInsertFunction determinism
- [LLVMdev] Module::getOrInsertFunction determinism
- [LLVMdev] Module::getOrInsertFunction determinism
- [LLVMdev] Inserting a varargs function declaration with getOrInsertFunction()?