Debian Codegraph @

gcc/testsuite/gcc.target/s390/nobp-function-pointer-z10.c

raw
1 /* { dg-do run } */
2 /* { dg-options "-O3 -march=z10 --save-temps -mindirect-branch-call=thunk -mindirect-branch-table" } */
3
4 int gl;
5
6 void __attribute__((noinline,noclone))
7 foo (int a)
8 {
9 gl = a + 40;
10 }
11
12 int __attribute__((noinline,noclone))
13 foo_value (int a)
14 {
15 return a + 40;
16 }
17
18 void* __attribute__((noinline,noclone))
19 get_fptr (int a)
20 {
21 switch (a)
22 {
23 case 0: return &foo; break;
24 case 1: return &foo_value; break;
25 default: __builtin_abort ();
26 }
27 }
28
29 void (*f) (int);
30 int (*g) (int);
31
32 int
33 main ()
34 {
35 int res;
36
37 f = get_fptr(0);
38 f (2);
39 if (gl != 42)
40 __builtin_abort ();
41
42 g = get_fptr(1);
43 if (g (2) != 42)
44 __builtin_abort ();
45
46 return 0;
47 }
48
49 /* 2 x main
50 /* { dg-final { scan-assembler-times "brasl\t%r\[0-9\]*,__s390_indirect_jump" 2 } } */
51 /* { dg-final { scan-assembler "exrl" } } */
52
53 /* { dg-final { scan-assembler-not "section\t.s390_indirect_jump" } } */
54 /* { dg-final { scan-assembler "section\t.s390_indirect_call" } } */
55 /* { dg-final { scan-assembler-not "section\t.s390_return_reg" } } */
56 /* { dg-final { scan-assembler-not "section\t.s390_return_mem" } } */