[llvm-dev] Guidelines for pass initialization?
Philip Reames via llvm-dev
llvm-dev at lists.llvm.org
Fri Aug 21 15:26:43 PDT 2015
On 08/21/2015 11:13 AM, Owen Anderson wrote:
>> On Aug 21, 2015, at 10:40 AM, Philip Reames <listmail at philipreames.com> wrote:
>>> INITIALIZE_PASS is used for a pass that is a leaf in the dependency graph, whereas INITIALIZE_PASS_BEGIN is used for interior nodes.
>> Almost all transform passes - with the exception of LoopSimplify and the like - do not have passes which require them. As a result, most transform passes are leaves in the dependency graph and should use the INITIALIZE_PASS mechanism. All Analysis passes are expected to have consumers, so they are obvious not leaf and should use the INITIALIZE_PASS_BEGIN mechanism. Is that a reasonable summary?
> No, you have the edge directions backwards. A pass that depends on something else (a Transform that depends on an Analysis) needs to specify that dependency. The Analysis pass itself does not need to specify the reverse dependency.
I realized I had that backwards not long after sending it. :) So, to
rephrase one more time:
1) Analysis without dependencies are leaf and thus INITIALIZE_PASS
eligible. Most Analysis passes do not have dependencies.
2) Transforms without dependencies are leaf and thus INITIALIZE_PASS
eligible. Very few Transform passes have no dependencies!
3) Passes (Transform or Analysis) with dependencies are not leaf and
must use INITIALIZE_PASS_BEGIN.
4) An INITIALIZE_PASS_BEGIN without a dependency is equivalent to
It would seem this makes the RegisterPass template essentially useless.
It provides no way to register dependencies so any transform pass
register through it is essentially relying on all Analysis passes it
uses being previously registered. Yuck.
More information about the llvm-dev