[Bug middle-end/44053] "benchmark" function attribute.

svfuerst at gmail dot com gcc-bugzilla@gcc.gnu.org
Mon May 10 06:36:00 GMT 2010



------- Comment #1 from svfuerst at gmail dot com  2010-05-10 06:36 -------
A common technique is to benchmark a function by calling it many times i.e.

void foo(void)
{
  /* foo's implementation */
}

int main(void)
{
   int i;

   for (i = 0; i < LARGE_NUM; i++) foo();

   return 0;
}

The problem with this technique is that although the programmer would like to
optimize foo, the compiler will "over optimize".

In short, it would be nice if there was a flag to enforce the ABI in usage of
foo to get meaningful results.

i.e.

1) Prevent inlining of foo.  (The current 'noinline' attribute.)
2) Prevent cloning of foo for specific argument cases.
3) Prevent deletion of calls to foo.  In the example case, the calls to foo may
be removed as no external side effects may be visible.  However, the most
important side effect, the total time taken, is then altered.
4) Enforce the existence of foo, so its disassembly may be examined.  (The
current 'used' attribute.)

At the moment an increasing number of work-arounds need to be done to avoid
these problems.  It would be nice if a single function attribute would tell the
compiler to avoid optimizations that cross the foo function-call interface
boundary, but maintain optimizations within foo itself.



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44053



More information about the Gcc-bugs mailing list