(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
aarch64/
bti-1.c
       1  /* { dg-do compile } */
       2  /* -Os to create jump table.  */
       3  /* { dg-options "-Os" } */
       4  /* { dg-require-effective-target lp64 } */
       5  /* If configured with --enable-standard-branch-protection, don't use
       6     command line option.  */
       7  /* { dg-additional-options "-mbranch-protection=standard" { target { ! default_branch_protection } } } */
       8  
       9  extern int f1 (void);
      10  extern int f2 (void);
      11  extern int f3 (void);
      12  extern int f4 (void);
      13  extern int f5 (void);
      14  extern int f6 (void);
      15  extern int f7 (void);
      16  extern int f8 (void);
      17  extern int f9 (void);
      18  extern int f10 (void);
      19  
      20  int (*ptr) (void);
      21  
      22  int
      23  f_jump_table (int y, int n)
      24  {
      25    int i;
      26    for (i = 0; i < n ;i ++)
      27    {
      28      switch (y)
      29        {
      30        case 0 : ptr = f1; break;
      31        case 1 : ptr = f2; break;
      32        case 2 : ptr = f3; break;
      33        case 3 : ptr = f4; break;
      34        case 4 : ptr = f5; break;
      35        case 5 : ptr = f6; break;
      36        case 6 : ptr = f7; break;
      37        case 7 : ptr = f8; break;
      38        case 8 : ptr = f9; break;
      39        case 9 : ptr = f10; break;
      40        default: break;
      41        }
      42      y += ptr ();
      43    }
      44    return (y == 0)? y+1:4;
      45  }
      46  /* f_jump_table should have PACIASP and AUTIASP.  */
      47  /* { dg-final { scan-assembler-times "hint\t25" 1 } } */
      48  /* { dg-final { scan-assembler-times "hint\t29" 1 } } */
      49  
      50  int
      51  f_label_address ()
      52  {
      53    static void * addr = &&lab1;
      54    goto *addr;
      55  lab1:
      56    addr = &&lab2;
      57    return 1;
      58  lab2:
      59    addr = &&lab1;
      60    return 2;
      61  }
      62  /* { dg-final { scan-assembler-times "hint\t34" 1 } } */
      63  /* { dg-final { scan-assembler-times "hint\t36" 12 } } */
      64  /* { dg-final { scan-assembler ".note.gnu.property" { target *-*-linux* } } } */