1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-12-22 19:43:42 +01:00

Tweak such that GCC v4 doesn't optimize it to the point where the

test fails (it managed to unravel the recursion in f1).

(Logical change 1.290)
This commit is contained in:
hp.com!davidm 2005-05-03 09:13:17 +00:00
parent 2f63c6c54e
commit 02c9034eb2

View file

@ -53,7 +53,7 @@ gettime (void)
return tv.tv_sec + 1e-6*tv.tv_usec;
}
static int
static int __attribute__((noinline))
measure_unwind (int maxlevel, double *step)
{
double stop, start;
@ -79,15 +79,17 @@ measure_unwind (int maxlevel, double *step)
stop = gettime ();
if (level <= maxlevel)
panic ("Unwound only %d levels, expected at least %d levels",
panic ("Unwound only %d levels, expected at least %d levels\n",
level, maxlevel);
*step = (stop - start) / (double) level;
return 0;
}
static int
f1 (int level, int maxlevel, double *step)
static int f1 (int, int, double *);
static int __attribute__((noinline))
g1 (int level, int maxlevel, double *step)
{
if (level == maxlevel)
return measure_unwind (maxlevel, step);
@ -96,6 +98,16 @@ f1 (int level, int maxlevel, double *step)
return f1 (level + 1, maxlevel, step) + level;
}
static int __attribute__((noinline))
f1 (int level, int maxlevel, double *step)
{
if (level == maxlevel)
return measure_unwind (maxlevel, step);
else
/* defeat last-call/sibcall optimization */
return g1 (level + 1, maxlevel, step) + level;
}
static void
doit (const char *label)
{