| 1 |
/* { dg-skip-if "gdb hang" { hppa*-*-linux* } } */ |
| 2 |
/* { dg-options "-g" } */ |
| 3 |
/* { dg-do run { xfail { ! aarch64*-*-* } } } */ |
| 4 |
/* { dg-xfail-run-if "" aarch64*-*-* "*" { "-O[01g]" } } */ |
| 5 |
|
| 6 |
#define GUALITY_DONT_FORCE_LIVE_AFTER -1 |
| 7 |
|
| 8 |
#ifndef STATIC_INLINE |
| 9 |
#define STATIC_INLINE /*static*/ |
| 10 |
#endif |
| 11 |
|
| 12 |
#include "guality.h" |
| 13 |
|
| 14 |
#include <assert.h> |
| 15 |
|
| 16 |
/* Test the debug info for the functions used in the VTA |
| 17 |
presentation at the GCC Summit 2008. */ |
| 18 |
|
| 19 |
typedef struct list { |
| 20 |
struct list *n; |
| 21 |
int v; |
| 22 |
} elt, *node; |
| 23 |
|
| 24 |
STATIC_INLINE node |
| 25 |
find_val (node c, int v, node e) |
| 26 |
{ |
| 27 |
while (c < e) |
| 28 |
{ |
| 29 |
GUALCHK (c); |
| 30 |
GUALCHK (v); |
| 31 |
GUALCHK (e); |
| 32 |
if (c->v == v) |
| 33 |
return c; |
| 34 |
GUALCHK (c); |
| 35 |
GUALCHK (v); |
| 36 |
GUALCHK (e); |
| 37 |
c++; |
| 38 |
} |
| 39 |
return NULL; |
| 40 |
} |
| 41 |
|
| 42 |
STATIC_INLINE node |
| 43 |
find_prev (node c, node w) |
| 44 |
{ |
| 45 |
while (c) |
| 46 |
{ |
| 47 |
node o = c; |
| 48 |
c = c->n; |
| 49 |
GUALCHK (c); |
| 50 |
GUALCHK (o); |
| 51 |
GUALCHK (w); |
| 52 |
if (c == w) |
| 53 |
return o; |
| 54 |
GUALCHK (c); |
| 55 |
GUALCHK (o); |
| 56 |
GUALCHK (w); |
| 57 |
} |
| 58 |
return NULL; |
| 59 |
} |
| 60 |
|
| 61 |
STATIC_INLINE node |
| 62 |
check_arr (node c, node e) |
| 63 |
{ |
| 64 |
if (c == e) |
| 65 |
return NULL; |
| 66 |
e--; |
| 67 |
while (c < e) |
| 68 |
{ |
| 69 |
GUALCHK (c); |
| 70 |
GUALCHK (e); |
| 71 |
if (c->v > (c+1)->v) |
| 72 |
return c; |
| 73 |
GUALCHK (c); |
| 74 |
GUALCHK (e); |
| 75 |
c++; |
| 76 |
} |
| 77 |
return NULL; |
| 78 |
} |
| 79 |
|
| 80 |
STATIC_INLINE node |
| 81 |
check_list (node c, node t) |
| 82 |
{ |
| 83 |
while (c != t) |
| 84 |
{ |
| 85 |
node n = c->n; |
| 86 |
GUALCHK (c); |
| 87 |
GUALCHK (n); |
| 88 |
GUALCHK (t); |
| 89 |
if (c->v > n->v) |
| 90 |
return c; |
| 91 |
GUALCHK (c); |
| 92 |
GUALCHK (n); |
| 93 |
GUALCHK (t); |
| 94 |
c = n; |
| 95 |
} |
| 96 |
return NULL; |
| 97 |
} |
| 98 |
|
| 99 |
struct list testme[] = { |
| 100 |
{ &testme[1], 2 }, |
| 101 |
{ &testme[2], 3 }, |
| 102 |
{ &testme[3], 5 }, |
| 103 |
{ &testme[4], 7 }, |
| 104 |
{ &testme[5], 11 }, |
| 105 |
{ NULL, 13 }, |
| 106 |
}; |
| 107 |
|
| 108 |
int |
| 109 |
main (int argc, char *argv[]) |
| 110 |
{ |
| 111 |
int n = sizeof (testme) / sizeof (*testme); |
| 112 |
node first, last, begin, end, ret; |
| 113 |
|
| 114 |
GUALCHKXPR (n); |
| 115 |
|
| 116 |
begin = first = &testme[0]; |
| 117 |
last = &testme[n-1]; |
| 118 |
end = &testme[n]; |
| 119 |
|
| 120 |
GUALCHKXPR (first); |
| 121 |
GUALCHKXPR (last); |
| 122 |
GUALCHKXPR (begin); |
| 123 |
GUALCHKXPR (end); |
| 124 |
|
| 125 |
ret = find_val (begin, 13, end); |
| 126 |
GUALCHK (ret); |
| 127 |
assert (ret == last); |
| 128 |
|
| 129 |
ret = find_prev (first, last); |
| 130 |
GUALCHK (ret); |
| 131 |
assert (ret == &testme[n-2]); |
| 132 |
|
| 133 |
ret = check_arr (begin, end); |
| 134 |
GUALCHK (ret); |
| 135 |
assert (!ret); |
| 136 |
|
| 137 |
ret = check_list (first, last); |
| 138 |
GUALCHK (ret); |
| 139 |
assert (!ret); |
| 140 |
} |