mirror of
https://github.com/tobast/libunwind-eh_elf.git
synced 2024-11-22 07:37:38 +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:
parent
2f63c6c54e
commit
02c9034eb2
1 changed files with 16 additions and 4 deletions
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue