4 int bad0(void) { return __builtin_constant_p(global); }
5 int bad1(void) { return __builtin_constant_p(global++); }
6 inline int bad2(int x) { return __builtin_constant_p(x++); }
7 inline int bad3(int x) { return __builtin_constant_p(x); }
8 inline int bad4(const char *x) { return __builtin_constant_p(x); }
9 int bad5(void) { return bad2(1); }
10 inline int bad6(int x) { return __builtin_constant_p(x+1); }
11 int bad7(void) { return __builtin_constant_p(abort()); }
12 int bad8(void) { char buf[10]; return __builtin_constant_p(buf); }
13 int bad9(const char *x) { return __builtin_constant_p(x[123456]); }
14 int bad10(void) { return __builtin_constant_p(&global); }
16 /* These must pass, or we've broken gcc2 functionality. */
17 int good0(void) { return __builtin_constant_p(1); }
18 int good1(void) { return __builtin_constant_p("hi"); }
19 int good2(void) { return __builtin_constant_p((1234 + 45) & ~7); }
21 /* These are extensions to gcc2. Failure indicates an optimization
23 int opt0(void) { return bad3(1); }
24 int opt1(void) { return bad6(1); }
25 int opt2(void) { return __builtin_constant_p("hi"[0]); }
28 * Opt3 is known to fail. It is one of the important cases that glibc
29 * was interested in though, so keep this around as a reminder.
31 * The solution is to add bits to recover bytes from constant pool
32 * elements given nothing but a constant pool label and an offset.
33 * When we can do that, and we can simplify strlen after the fact,
34 * then we can enable recognition of constant pool labels as constants.
37 /* int opt3(void) { return bad4("hi"); } */
40 /* Call through tables so -finline-functions can't screw with us. */
41 int (*bad_t0[])(void) = {
42 bad0, bad1, bad5, bad7, bad8, bad10
45 int (*bad_t1[])(int x) = {
49 int (*bad_t2[])(const char *x) = {
53 int (*good_t0[])(void) = {
57 int (*opt_t0[])(void) = {
58 opt0, opt1, opt2 /* , opt3 */
61 #define N(arr) (sizeof(arr)/sizeof(*arr))
67 for (i = 0; i < N(bad_t0); ++i)
71 for (i = 0; i < N(bad_t1); ++i)
75 for (i = 0; i < N(bad_t2); ++i)
76 if ((*bad_t2[i])("hi"))
79 for (i = 0; i < N(good_t0); ++i)
80 if (! (*good_t0[i])())
84 for (i = 0; i < N(opt_t0); ++i)