Iulia Stirb via llvm-dev
2019-Sep-10 15:56 UTC
[llvm-dev] Question about using multiple functions in a Function pass
Hi all, I would want to know if from the runOnFunction method of a Function pass, other functions in IR, except for the one received as parameter, can be obtained as well, from a call instruction, as follows: Function F = dyn_cast<Function>(callInst); Or do I need a Module pass to work in IR with multiple functions from input source code? If so, it is accepted to have O(n^3) complexity in a module pass when iterating through each instruction of each basic block of each function in the module. Unrelated to the topic, I would also like to ask if a module object contains the IR for the entire application if the application contains multiple source files? Kind regards, Iulia ȘTIRB -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190910/251e6a6b/attachment.html>
Iulia Stirb via llvm-dev
2019-Sep-10 16:12 UTC
[llvm-dev] Question about using multiple functions in a Function pass
Forgot one question to the mail and a correction below: When calling runOnFunction for a function in IR is it guaranteed that all other functions in the module are already parsed by the compiler? Thank you,Iulia On Tuesday, September 10, 2019, 6:56:39 PM GMT+3, Iulia Stirb <iulia_s24 at yahoo.com> wrote: Hi all, I would want to know if from the runOnFunction method of a Function pass, other functions in IR, except for the one received as parameter, can be obtained as well, from a call instruction, as follows: Function * F = dyn_cast<Function>(callInst); Or do I need a Module pass to work in IR with multiple functions from input source code? If so, it is accepted to have O(n^3) complexity in a module pass when iterating through each instruction of each basic block of each function in the module. Unrelated to the topic, I would also like to ask if a module object contains the IR for the entire application if the application contains multiple source files? Kind regards, Iulia ȘTIRB -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190910/7070274a/attachment.html>
Alexey Zhikhartsev via llvm-dev
2019-Sep-10 18:45 UTC
[llvm-dev] Question about using multiple functions in a Function pass
Hi Iulia, Function passes are not allowed to process functions other than the current one. Please see http://llvm.org/docs/WritingAnLLVMPass.html#the-functionpass-class Alex On Tue., Sep. 10, 2019, 11:56 a.m. Iulia Stirb via llvm-dev, < llvm-dev at lists.llvm.org> wrote:> Hi all, > > I would want to know if from the runOnFunction method of a Function pass, > other functions in IR, except for the one received as parameter, can be > obtained as well, from a call instruction, as follows: > > Function F = dyn_cast<Function>(callInst); > > Or do I need a Module pass to work in IR with multiple functions from > input source code? If so, it is accepted to have O(n^3) complexity in a > module pass when iterating through each instruction of each basic block of > each function in the module. > > Unrelated to the topic, I would also like to ask if a module object > contains the IR for the entire application if the application contains > multiple source files? > > Kind regards, > Iulia ȘTIRB > > > > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190910/8a7860a8/attachment.html>
Hiroshi Yamauchi via llvm-dev
2019-Sep-11 15:48 UTC
[llvm-dev] Question about using multiple functions in a Function pass
My understanding is that a pass type is supposed not to operate outside its scope (module, function, loop, etc.) because the pass manager might choose to 'batch' multiple passes of the same type (for performance) or could run concurrently. It sounds like it's best to use a module pass if the other functions in the same module need to be read. On Tue, Sep 10, 2019 at 11:46 AM Alexey Zhikhartsev via llvm-dev <llvm-dev at lists.llvm.org> wrote:> > Hi Iulia, > > Function passes are not allowed to process functions other than the current one. Please see http://llvm.org/docs/WritingAnLLVMPass.html#the-functionpass-class > > Alex > > On Tue., Sep. 10, 2019, 11:56 a.m. Iulia Stirb via llvm-dev, <llvm-dev at lists.llvm.org> wrote: >> >> Hi all, >> >> I would want to know if from the runOnFunction method of a Function pass, other functions in IR, except for the one received as parameter, can be obtained as well, from a call instruction, as follows: >> >> Function F = dyn_cast<Function>(callInst); >> >> Or do I need a Module pass to work in IR with multiple functions from input source code? If so, it is accepted to have O(n^3) complexity in a module pass when iterating through each instruction of each basic block of each function in the module. >> >> Unrelated to the topic, I would also like to ask if a module object contains the IR for the entire application if the application contains multiple source files? >> >> Kind regards, >> Iulia ȘTIRB >> >> >> >> >> >> _______________________________________________ >> LLVM Developers mailing list >> llvm-dev at lists.llvm.org >> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev