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