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

Rafael Ávila de Espíndola rafael.espindola at gmail.com
Sat Jul 30 19:27:13 PDT 2011


> Your patch is for an "indirect branch duplication" pass, but your
> comments above suggest that you're planning to expand it to do much
> more general IL-level tail duplication.  Which is it?  And why?  I
> don't think it makes sense to have 3 separate taildup passes that are
> all doing essentially the same thing at different points in the
> compilation process.

I agree that we should not have all of them. I do intend to remove the
MI one if this one works.

>> 
>> BTW, what is your plan for duplicating into a conditional branch?
>> I would be interested in implementing that too…
> 
> The problem I'm working on is specifically for indirect branches.  We
> need to essentially undo the front-end's transformation to use a
> single indirect branch per function.  (I'm actually including
> branches through jump tables here.  Those don't get the same
> treatment by the front-end, but the same motivation applies for
> duplicating them in some cases.)  The current taildup approach is
> very naive.  It cannot handle important cases like duplicating past
> conditional branches, and in other cases, it duplicates far more than
> necessary, which bloats code size and can hurt i-cache locality, etc.
> The approach I'm taking it is to use dominance information to analyze
> the CFG and find regions of code to duplicate in selected locations.
> You would not want to do this for anything except indirect branches.

Sorry, the question was more on the "how to duplicate", not "where to
duplicate". If previous optimizations gives us

zed:
...
br i1 %foo, %indirectgoto, %bar

and you decide that the indirect goto should be duplicated to zed, how
do you do it?

> I agree that a target-specific peephole is not the most elegant
> solution, and I'm sure your new pass nicely solves the specific
> problem you're looking at.  I just don't think we want to have 4
> separate taildup/indirect-branch-dup passes (the 2 existing taildup
> passes, plus yours, plus mine).

As I mentioned, my intention is to replace the existing early MI level one.

Cheers,
Rafael



More information about the llvm-commits mailing list