From 43613ee4edc241e9a29308f32f760f4342026e13 Mon Sep 17 00:00:00 2001 From: bde Date: Wed, 13 Jun 2007 06:17:48 +0000 Subject: 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. --- sys/libkern/mcount.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'sys/libkern/mcount.c') diff --git a/sys/libkern/mcount.c b/sys/libkern/mcount.c index d967fe8..e26f6fa 100644 --- a/sys/libkern/mcount.c +++ b/sys/libkern/mcount.c @@ -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 -- cgit v1.1