OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.dg/] [sibcall-3.c] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
/* Simple check that sibling calls are performed from a
2
   void non-leaf-function taking one int argument calling a function which
3
   is about the same as itself.
4
 
5
   Copyright (C) 2002 Free Software Foundation Inc.
6
   Contributed by Hans-Peter Nilsson  <hp@bitrange.com>  */
7
 
8
/* { dg-do run { xfail arc-*-* avr-*-* c4x-*-* cris-*-* h8300-*-* hppa*64*-*-* m32r-*-* m68hc1?-*-* m681?-*-* m680*-*-* m68k-*-* mcore-*-* mn10300-*-* xstormy16-*-* v850*-*-* vax-*-* xtensa-*-* } } */
9
/* { dg-options "-O2 -foptimize-sibling-calls" } */
10
 
11
/* The option -foptimize-sibling-calls is the default, but serves as
12
   marker.  This test is xfailed on targets without sibcall patterns
13
   (except targets where the test does not work due to the return address
14
   not saved on the regular stack).  */
15
 
16
extern void abort (void);
17
extern void exit (int);
18
 
19
static void recurser_void1 (int);
20
static void recurser_void2 (int);
21
extern void track (int);
22
 
23
int main ()
24
{
25
  recurser_void1 (0);
26
  exit (0);
27
}
28
 
29
/* The functions should get the same stack-frame, and best way to make it
30
   reasonably sure is to make them have the same contents (regarding the
31
   n tests).  */
32
 
33
static void __attribute__((noinline))
34
recurser_void1 (int n)
35
{
36
  if (n == 0 || n == 7 || n == 8)
37
    track (n);
38
 
39
  if (n == 10)
40
    return;
41
 
42
  recurser_void2 (n + 1);
43
}
44
 
45
static void __attribute__((noinline))
46
recurser_void2 (int n)
47
{
48
  if (n == 0 || n == 7 || n == 8)
49
    track (n);
50
 
51
  if (n == 10)
52
    return;
53
 
54
  recurser_void1 (n + 1);
55
}
56
 
57
void *trackpoint;
58
 
59
void
60
track (int n)
61
{
62
  char stackpos[1];
63
 
64
  if (n == 0)
65
    trackpoint = stackpos;
66
  else if ((n != 7 && n != 8) || trackpoint != stackpos)
67
    abort ();
68
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.