[LLVMdev] Docs question: legality of inspecting other functions in a function pass
swlin at post.harvard.edu
Thu Jul 4 11:21:38 PDT 2013
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.
More information about the llvm-dev