Unbreak high resolution profiling a little: use dummy asms to prevent

timing loops being optimized away.

Once apon a time, gcc promised not to optimize away timing loops, but
gcc started optimizing away the call to a null function in the timing
loop here some time between gcc-3.3.3 and gcc-3.4.6, and it started
optimizing away the timing loop itself some time between gcc-3.4.6
and gcc-4.2.
This commit is contained in:
bde 2007-06-13 06:17:48 +00:00
parent 0630c4e3a4
commit 43613ee4ed

View File

@ -268,18 +268,23 @@ mexitcount(selfpc)
}
}
#ifndef __GNUCLIKE_ASM
#error "This file uses null asms to prevent timing loops being optimized away."
#endif
void
empty_loop()
{
int i;
for (i = 0; i < CALIB_SCALE; i++)
;
__asm __volatile("");
}
void
nullfunc()
{
__asm __volatile("");
}
void