Stephen Lin
2013-Jul-03 22:05 UTC
[LLVMdev] Docs question: legality of inspecting other functions in a function pass
Hi, I'm not planning on doing this, but I noticed that the documentation in WritingAnLLVMPass.rst doesn't seem to specify whether or not it's legal for a function pass to inspect (and thus depend upon the contents of) other functions and I'm curious if this is an oversight or by design: To be explicit, ``FunctionPass`` subclasses are not allowed to: #. Modify a ``Function`` other than the one currently being processed. ... Whereas for basic block passes there is an explicit prohibition: ``BasicBlockPass``\ es are just like :ref:`FunctionPass's <writing-an-llvm-pass-FunctionPass>` , except that they must limit their scope of inspection and modification to a single basic block at a time. As such, they are **not** allowed to do any of the following: #. Modify or inspect any basic blocks outside of the current one. ... Does anyone know if there's a defined policy about this, either way? If so, I think it ought to be noted in the docs, for consistency. Stephen
Sean Silva
2013-Jul-03 22:56 UTC
[LLVMdev] Docs question: legality of inspecting other functions in a function pass
On Wed, Jul 3, 2013 at 3:05 PM, Stephen Lin <swlin at post.harvard.edu> wrote:> > If so, I think it ought to be noted in the docs, for consistency. >Once you get your answer, definitely feel free to update the docs. -- Sean Silva -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130703/76965036/attachment.html>
David Chisnall
2013-Jul-04 08:45 UTC
[LLVMdev] Docs question: legality of inspecting other functions in a function pass
On 3 Jul 2013, at 23:05, Stephen Lin <swlin at post.harvard.edu> wrote:> Does anyone know if there's a defined policy about this, either way? > If so, I think it ought to be noted in the docs, for consistency.The prohibition exists, at least in part, because in theory it would be nice to be able to run passes in parallel. It's not a real limitation at the moment because updating instructions in a module is not thread safe (and making it so with the current APIs would probably be somewhat problematic in terms of performance) and so when we do eventually get the ability to run FunctionPasses in parallel they will most likely need new APIs. That said, it's a good idea structurally to view the Function / Block as synchronisation boundaries so that it will be easier to support concurrent execution in the future. David
Stephen Lin
2013-Jul-04 18:21 UTC
[LLVMdev] Docs question: legality of inspecting other functions in a function pass
On Thu, Jul 4, 2013 at 1:45 AM, David Chisnall <David.Chisnall at cl.cam.ac.uk> wrote:> On 3 Jul 2013, at 23:05, Stephen Lin <swlin at post.harvard.edu> wrote: > >> Does anyone know if there's a defined policy about this, either way? >> If so, I think it ought to be noted in the docs, for consistency. > > The prohibition exists, at least in part, because in theory it would be nice to be able to run passes in parallel. It's not a real limitation at the moment because updating instructions in a module is not thread safe (and making it so with the current APIs would probably be somewhat problematic in terms of performance) and so when we do eventually get the ability to run FunctionPasses in parallel they will most likely need new APIs. That said, it's a good idea structurally to view the Function / Block as synchronisation boundaries so that it will be easier to support concurrent execution in the future. >I understand the rationale but are you sure that the prohibition against *inspecting* other functions during a function pass does exist and is currently followed? If it does I think the docs ought to make that clear so I want to make sure if the omission is not deliberate. In theory you could still parallelize function pass execution if they inspected other functions if they used some kind of read/write locking and used transactional updates; I would think the main point is that we want the results to be deterministic and not dependent on the order in which functions are processed, which applies regardless of what kind of parallelization and/or synchronization is used. Stephen
Reasonably Related Threads
- [LLVMdev] Docs question: legality of inspecting other functions in a function pass
- [LLVMdev] Docs question: legality of inspecting other functions in a function pass
- [LLVMdev] Docs question: legality of inspecting other functions in a function pass
- [LLVMdev] Docs question: legality of inspecting other functions in a function pass
- [LLVMdev] Docs question: legality of inspecting other functions in a function pass