1 /* { dg-require-effective-target label_values } */
2
3 /* Test profile-directed block ordering with computed gotos.
4 *
5 This is the same as test gcc.c-torture/execute/980526-1.c and
6 gcc.misc-tests/gcov-3.c */
7
8 extern void abort (void);
9 extern void exit (int);
10
11 int expect_do1 = 1, expect_do2 = 2;
12
13 static int doit(int x){
14 __label__ lbl1;
15 __label__ lbl2;
16 static int jtab_init = 0;
17 static void *jtab[2];
18
19 if(!jtab_init) {
20 jtab[0] = &&lbl1;
21 jtab[1] = &&lbl2;
22 jtab_init = 1;
23 }
24 goto *jtab[x];
25 lbl1:
26 return 1;
27 lbl2:
28 return 2;
29 }
30
31 static void do1(void) {
32 if (doit(0) != expect_do1)
33 abort ();
34 }
35
36 static void do2(void){
37 if (doit(1) != expect_do2)
38 abort ();
39 }
40
41 int main(void){
42 do1();
43 do2();
44 exit(0);
45 }