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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [bcp-1.c] - Blame information for rev 774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 688 jeremybenn
__attribute__ ((externally_visible)) int global;
2
int func(void);
3
 
4
/* These must fail.  */
5
int bad0(void) { return __builtin_constant_p(global); }
6
int bad1(void) { return __builtin_constant_p(global++); }
7
inline int bad2(int x) { return __builtin_constant_p(x++); }
8
inline int bad3(int x) { return __builtin_constant_p(x); }
9
inline int bad4(const char *x) { return __builtin_constant_p(x); }
10
int bad5(void) { return bad2(1); }
11
inline int bad6(int x) { return __builtin_constant_p(x+1); }
12
int bad7(void) { return __builtin_constant_p(func()); }
13
int bad8(void) { char buf[10]; return __builtin_constant_p(buf); }
14
int bad9(const char *x) { return __builtin_constant_p(x[123456]); }
15
int bad10(void) { return __builtin_constant_p(&global); }
16
 
17
/* These must pass, or we've broken gcc2 functionality.  */
18
int good0(void) { return __builtin_constant_p(1); }
19
int good1(void) { return __builtin_constant_p("hi"); }
20
int good2(void) { return __builtin_constant_p((1234 + 45) & ~7); }
21
 
22
/* These are extensions to gcc2.  Failure indicates an optimization
23
   regression.  */
24
int opt0(void) { return bad3(1); }
25
int opt1(void) { return bad6(1); }
26
int opt2(void) { return __builtin_constant_p("hi"[0]); }
27
 
28
/*
29
 * Opt3 is known to fail.  It is one of the important cases that glibc
30
 * was interested in though, so keep this around as a reminder.
31
 *
32
 * The solution is to add bits to recover bytes from constant pool
33
 * elements given nothing but a constant pool label and an offset.
34
 * When we can do that, and we can simplify strlen after the fact,
35
 * then we can enable recognition of constant pool labels as constants.
36
 */
37
 
38
/* int opt3(void) { return bad4("hi"); } */
39
 
40
 
41
/* Call through tables so -finline-functions can't screw with us.  */
42
int (* volatile bad_t0[])(void) = {
43
        bad0, bad1, bad5, bad7, bad8, bad10
44
};
45
 
46
int (* volatile bad_t1[])(int x) = {
47
        bad2, bad3, bad6
48
};
49
 
50
int (* volatile bad_t2[])(const char *x) = {
51
        bad4, bad9
52
};
53
 
54
int (* volatile good_t0[])(void) = {
55
        good0, good1, good2
56
};
57
 
58
int (* volatile opt_t0[])(void) = {
59
        opt0, opt1, opt2 /* , opt3 */
60
};
61
 
62
#define N(arr) (sizeof(arr)/sizeof(*arr))
63
 
64
int main()
65
{
66
  int i;
67
 
68
  for (i = 0; i < N(bad_t0); ++i)
69
    if ((*bad_t0[i])())
70
      abort();
71
 
72
  for (i = 0; i < N(bad_t1); ++i)
73
    if ((*bad_t1[i])(1))
74
      abort();
75
 
76
  for (i = 0; i < N(bad_t2); ++i)
77
    if ((*bad_t2[i])("hi"))
78
      abort();
79
 
80
  for (i = 0; i < N(good_t0); ++i)
81
    if (! (*good_t0[i])())
82
      abort();
83
 
84
#ifdef __OPTIMIZE__
85
  for (i = 0; i < N(opt_t0); ++i)
86
    if (! (*opt_t0[i])())
87
      abort();
88
#endif
89
 
90
  exit(0);
91
}

powered by: WebSVN 2.1.0

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