[llvm-commits] [patch] Add a pass for duplicating indirectbr at the IL level

Rafael Ávila de Espíndola rafael.espindola at gmail.com
Tue Aug 2 08:35:59 PDT 2011


>> A similar problem exists with the early tail dup at the IL level too.
>
> Right, and we haven't used that pass for at least the last few years.
> I'm not sure if that was the reason why it was deprecated like that, but
> it is a fundamental issue with IR-level tail-dup, not a criticism of
> your particular implementation.

The original one demotes values to memory, so it has to run a lot earlier.

> I'm just trying to head off what looks like a collision between two
> projects. Ideally we can figure out a plan for how to move forward that
> doesn't involve either of us wasting effort. If we could agree on an
> overall plan ahead of time, we can both adjust our efforts to fit into
> that plan.

I must say I am unconvinced on the direction you are proposing. 
Indirectbr doesn't look that special to have its own pass and while
the idea of using the dominated ares it jumps to for selecting where
to duplicate looks clever, it doesn't seem to be the main problem with
webkit or firefox and in something that can be retrofited as an refined
heuristic to shouldDuplicate.

Doing it at the MI level also means you would have to duplicating the 
folding logic in a second pass. With my proposal we get one extra pass 
in the pipeline (zero if merged with codegen prepare).

> The alternative is that we both go our own ways, end up with 3 or 4 tail
> dup passes, and then have to throw one or more of them away. That would
> be a shame, I think.

It is more of a shame to block work based on future expectations. While 
we have different opinions on which path is best, the only way to be 
sure is benchmark it. If I finish implementing my pass, get 1% in 
sunspider, I would be more than happy to replace it with yours (even if 
it needs an extra folding pass) if it got 2%.

> I would be willing to implement the indirect branch dup pass that I'm
> working on at the IR level, except that I don't know how to solve the
> two problems I mentioned earlier. If you have ideas for how to solve
> those, I might be able to build my pass on top of what you're doing now.

Note that other than having simpler api's a pass that only care about 
SSA form MI is not that different from a IL one. Also, if it is an IL 
pass it has to be very late, if it is a MI pass it has to be really 
early (before loop opts).

> "that point" would be "zed". I really don't think I'm understanding your
> question correctly. Sorry.

Can you write what code your pass would produce for:

bbx:
  ....
    br label %zed

zed:
  ...
   br i1 %foo, label %indirectgoto, label %bar ; duplicate the 
indirectgoto bb in here.

indirectgoto:
  ....
  %l = phi ...
  indirectbr i8* %l ....


Cheers,
Rafael



More information about the llvm-commits mailing list