[LLVMdev] How to get LoopInfo within Pass subclass?

Chris Lattner sabre at nondot.org
Mon Aug 9 19:54:13 PDT 2004


On Mon, 9 Aug 2004, Michael McCracken wrote:
> Sounds like good advice. I've been advised to hold off working on this
> problem as long as it isn't on my critical path. However, some free
> time spent on it can't hurt. Maybe if I talk about it enough I'll
> inspire someone else to work on it. :)

:)

> > Writing the clone() method for FunctionPass objects is an annoying
> > thing to have to do, but is purely mechanical.
>
> Would you have to write clone() for every FunctionPass subclass?
> It's not clear to me why cloning would have to be different from
> just creating a new Pass with the default constructor...

Yes, we would need them.  Most passes are created with a default ctor (in
fact, all those that are "required" are, which might be enough to get
around this, but...), but there are some that are created with ctor
arguments when added to the pass manager.  In particular, it's perfectly
legal to do stuff like this:

PM.add(new FunkyPass(1, 2, 3, 4));

> > I think that a lot of this can be moved to runtime.  In particular,
> > when
> > the PM is constructed, we only need to (and only can) create one
> > instance
> > of each pass.  At runtime, they need to be cloned and destroyed as
> > appropriate.
> >
>
> Do we really need to instantiate the passes when the PM is constructed?
> If we have to do some pass creation and scheduling at runtime anyway, it
> seems conceptually simpler to just do it all then - have add() be really
> simple, then do all the work in run().

Yup, we do that.  In particular, the passes explicitly added to the pass
manager are.  The passes implicitly required could potentially be deferred
to run-time, but I'm not sure what the gain would be.  In particular, if B
requires A, you could have:

PM.add(B);

or you could have:

PM.add(A);
PM.add(B);

which should run exactly the same stuff (A should not be run twice).

> I'm not aware of all the issues surrounding why it is the way it is now,
> but it doesn't seem like there's an efficiency issue with doing it at a
> different step, and it might be simpler to implement by doing all the
> instantiation of Passes in one place. Also, it might help avoid a
> distinction between creation and cloning.

I don't think it would be an efficiency issue, but we have to handle cases
like the above anyway, so I don't think it would save us anything...

-Chris

-- 
http://llvm.cs.uiuc.edu/
http://nondot.org/sabre/




More information about the llvm-dev mailing list