This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


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

Re: New attribute "infrequent"?


Jan Hubicka <jh@suse.cz> writes:

> Does this make sense?  It would imply a lot of work on glibc side to tag all
> functions...
> 
> An extension can be allowing infrequent on variables too (such as stderr) and
> predicting any block containing reference to such variable as infrequently
> executing.

If you go there (and it doesn't sound bad at all) please go one step
further.  Some compilers allow changing optimization levels and other
code generation controlling variables in the source file.  Something
like

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int
foo (int a)
{
  return a;
}

_Pragma ("-Os")
int
bar (int a)
{
  return a;
}
_Pragma ("-Oprevious")

int
baz (int a)
{
  return a;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Using __builtin_expect we can control the block ordering (though this
should be improved on as well) but as you say, aggressive
optimizations shouldn't be carried out on code which isn't critical
for the runtime.

The _Pragma stuff above will in any case be needed for the C99-style
control of floating-point handling.

-- 
---------------.                          ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Red Hat          `--' drepper at redhat.com   `------------------------


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