This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Add hot/cold attributes for labels


On Fri, Jul 27, 2012 at 10:57 AM, Richard Guenther
<richard.guenther@gmail.com> wrote:
> On Thu, Jul 26, 2012 at 11:58 PM, Richard Henderson <rth@redhat.com> wrote:
>> On 07/26/2012 02:41 PM, Richard Henderson wrote:
>>> This is a patch...
>>
>> ... that I should have attached.  Bah.
>
> Do we need to mark the labels so we preserve them?  Consider
>
>  goto foo;
>
> foo:
> bar __attribute__((cold)):
>   ...
>
> so bar will be unused?  What about BB merging if we end up with
>
>   <BB 3>:
>       ..
>   fallthru
>   bar __attribute__((cold)):
>      ...
>
> should BB 3 inherit the coldness?  I think we no longer disable
> BB merging if the destination has user labels.

Right. I don't like the use of this attribute on labels at all, for
the reasons you list here. I think it would be much cleaner to add a
branch hint on the label in the asm goto, to contain this extension
and to also to make it clear that it's not the label that is cold but
the jump that is unlikely to be executed (i.e. cause and effect: the
jump is unlikely and therefore the basic block is cold).

Something like this:

   asm-goto-operands:
     asm-got-branch-hint identifier
     asm-goto-operands , asm-got-branch-hint identifier

   asm-got-branch-hint: <empty | + | ->
      where + means branch-likely and - means branch-unlikely

->

  asm goto (""::::+l1);
  asm goto (""::::+l1);
  asm goto (""::::-l1);

Ciao!
Steven


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]