[LLVMdev] Docs question: legality of inspecting other functions in a function pass

Stephen Lin swlin at post.harvard.edu
Wed Jul 3 15:05:15 PDT 2013


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



More information about the llvm-dev mailing list