[PATCH] Propagation of profile samples through the CFG.

Diego Novillo dnovillo at google.com
Fri Jan 10 13:10:37 PST 2014


On Fri, Jan 10, 2014 at 3:15 PM, Chandler Carruth <chandlerc at gmail.com> wrote:

> I'm hoping to avoid needing post-dominance information as we currently don't
> compute it in the standard optimization pipeline. But again, this is (IMO)
> really for a subsequent patch.

Ah. Yeah, I'll play with the other ideas I had, and we can compare later on.

> Sorry, I meant just the SmallVector so that we clear rather than reallocate.

Done.

>> > ================
>> > Comment at: lib/Transforms/Scalar/SampleProfile.cpp:624-625
>> > @@ +623,4 @@
>> > +
>> > +    // Repeat the same logic for all the blocks post-dominated by BB1.
>> > +    // We are looking for every basic block BB2 such that:
>> > +    //
>> > ----------------
>> > Why do we need to do this?
>> >
>> > If we visit every block as BB1, and then visit every block BB1 dominates
>> > as BB2, we will have considered all pairs of blocks where A dominates B, and
>> > tested for B post-dominating A. We don't need to consider pairs of blocks
>> > where B post-dominates A because we will reject the ones where A does not
>> > dominate B.
>>
>> Note that we do not necessarily visit every block as BB1. We only
>> visit the blocks for which we have equivalence class information. This
>> means that initially, only those blocks with samples in them have been
>> assigned into an equivalence class.
>>
>> So, if in a if-then-else diamond, you only have samples inside the
>> 'then' basic block, you need to look up from the 'then' to be able to
>> propagate into the 'if'. Using just dominance properties for 'then'
>> will not allow you to propagate its weight.
>
>
> If you have an if-then-else diamond, you cannot propagate up into the if
> block because the then block doesn't post-dominate the if block?

The other way around. I cannot propagate any values because the if()
block has no weights. But since we do have weights on the 'then',
using post-dominance we can propagate that weight into the 'if' and
the edge if->then. On a subsequent round, we decide that the if->else
edge must weight 0, which we then assign to the 'else' block.


Diego.



More information about the llvm-commits mailing list