Debian Codegraph @

gcc/testsuite/gcc.target/arm/bti-2.c

raw
1 /* { dg-do compile } */
2 /* -Os to create jump table. */
3 /* { dg-options "-Os" } */
4 /* { dg-require-effective-target arm_arch_v8_1m_main_ok } */
5 /* { dg-add-options arm_arch_v8_1m_main } */
6 /* { dg-additional-options "-mfloat-abi=softfp -mbranch-protection=bti --save-temps" } */
7
8 extern int f1 (void);
9 extern int f2 (void);
10 extern int f3 (void);
11 extern int f4 (void);
12 extern int f5 (void);
13 extern int f6 (void);
14 extern int f7 (void);
15 extern int f8 (void);
16 extern int f9 (void);
17 extern int f10 (void);
18
19 int (*ptr) (void);
20
21 int
22 f_jump_table (int y, int n)
23 {
24 int i;
25 for (i = 0; i < n ;i ++)
26 {
27 switch (y)
28 {
29 case 0 : ptr = f1; break;
30 case 1 : ptr = f2; break;
31 case 2 : ptr = f3; break;
32 case 3 : ptr = f4; break;
33 case 4 : ptr = f5; break;
34 case 5 : ptr = f6; break;
35 case 6 : ptr = f7; break;
36 case 7 : ptr = f8; break;
37 case 8 : ptr = f9; break;
38 case 9 : ptr = f10; break;
39 default: break;
40 }
41 y += ptr ();
42 }
43 return (y == 0)? y+1:4;
44 }
45
46 int
47 f_label_address ()
48 {
49 static void * addr = &&lab1;
50 goto *addr;
51 lab1:
52 addr = &&lab2;
53 return 1;
54 lab2:
55 addr = &&lab1;
56 return 2;
57 }
58
59 /* { dg-final { scan-assembler-times "\tbti" 14 } } */