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:
Bruce Evans 2007-06-13 06:17:48 +00:00
parent d076fbea58
commit 7df7fc34a3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=170659

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