[PATCH] D41373: [GISel][RFC]: GlobalISel Combiner prototype

Aditya Nandakumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 3 10:54:46 PST 2018


aditya_nandakumar added inline comments.


================
Comment at: include/llvm/CodeGen/GlobalISel/PreLegalizeCombiner.h:35
+
+class PreLegalizeCombiner : public MachineFunctionPass {
+public:
----------------
dsanders wrote:
> aditya_nandakumar wrote:
> > aditya_nandakumar wrote:
> > > aemerson wrote:
> > > > aditya_nandakumar wrote:
> > > > > qcolombet wrote:
> > > > > > The relationship between PreLegalizeCombiner and GICombiner looks strange to me.
> > > > > > In particular, before looking at the actual implementation of runOnMachineFunction, there is nothing showing that this pass uses GICombiner.
> > > > > > 
> > > > > > I would have expected something like GICombiner is a pass and PreLegalizeCombiner inherit from it and only set its custom PreLegalizeCombinerInfo thing.
> > > > > I went with the "has a" relationship with the GICombiner. Pretty much what the GICombiner does right now is the driving of the combines which felt like it belonged in a utility. Right now, there should be little/no difference to switch to each pass inheriting the GICombiner and I can do that if required.
> > > > I agree with Quentin that it seems having a generic GICombiner to inherit from seems clearer from a design point of view.
> > > Thanks. I will update that shortly.
> > The one downside I see to making it based on inheritance is that, things like MachineFunction is not available during creation of the CombinerInfo (pass construction). Passes would need to initialize the legalizerInfo during the runOnMachineFunction call instead if we go this route.
> You should be able to retrieve it from MI.getParent().getParent().getSubtarget().getLegalizerInfo() or something like that
The problem is, when do you initialize it? Do you check if it's initialized during each combine invocation? It seems wasteful to have to check every time (even if initialized).
The alternative is to have a setter that initializes the LegalizerInfo during runOnMachineFunction.


https://reviews.llvm.org/D41373





More information about the llvm-commits mailing list