(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
s390/
return-addr2.c
       1  /* builtin_return_address(n) with n>0 has always been troublesome.  */
       2  
       3  /* { dg-do run } */
       4  /* { dg-options "-O3 -fno-optimize-sibling-calls -mbackchain" } */
       5  
       6  void *addr1;
       7  
       8  extern void abort (void);
       9  
      10  void * __attribute__((noinline))
      11  foo1 ()
      12  {
      13    addr1 = __builtin_return_address (2);
      14  }
      15  
      16  void * __attribute__((noinline))
      17  foo2 ()
      18  {
      19    foo1 ();
      20  }
      21  
      22  void * __attribute__((noinline))
      23  foo3 ()
      24  {
      25    foo2 ();
      26  }
      27  
      28  void __attribute__((noinline))
      29  bar ()
      30  {
      31    void *addr2;
      32  
      33    foo3 ();
      34    asm volatile ("basr  %0,0\n\t" : "=d" (addr2));
      35    /* basr is two bytes in length.  */
      36    if (addr2 - addr1 != 2)
      37      abort ();
      38  }
      39  
      40  int
      41  main ()
      42  {
      43    bar();
      44    return 0;
      45  }