OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.dg/] [pr10392-1.c] - Blame information for rev 298

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 298 jeremybenn
/* PR optimization/10392
2
 * Reporter: marcus@mc.pp.se
3
 * Summary: [3.3/3.4 regression] [SH] optimizer generates faulty array indexing
4
 * Description:
5
 * The address calculation of an index operation on an array on the stack
6
 * can _under some conditions_ get messed up completely
7
 *
8
 * Testcase tweaked by dank@kegel.com
9
 * Problem only happens with -O2 -m4, so it should only happen on sh4,
10
 * but what the heck, let's test other architectures, too.
11
 * Not marked as xfail since it's a regression.
12
*/
13
/* { dg-do run } */
14
/* { dg-options "-O2" } */
15
/* { dg-options "-O2 -m4" { target sh4-*-* } } */
16
extern void abort (void);
17
const char *dont_optimize_function_away;
18
 
19
const char *use(const char *str)
20
{
21
        dont_optimize_function_away = str;
22
        if (str[0] != 'v')
23
                abort();
24
        if (str[1] < '1' || str[1] > '6')
25
                abort();
26
        if (str[2])
27
                abort();
28
        return str[2] ? "notused" : "v6";
29
}
30
 
31
const char *func(char *a, char *b)
32
{
33
        char buf[128];
34
        unsigned char i;
35
        const char *result;
36
 
37
        char *item[] = {
38
                "v1",
39
                "v2",
40
        };
41
 
42
        buf[0] = 'v';
43
        buf[1] = '3';
44
        buf[2] = 0;
45
 
46
        for (i = 0; i < 2; i++) {
47
                /* bug is: following line passes wild pointer to use() on sh4 -O2 */
48
                result = use(item[i]);
49
 
50
                use(buf);
51
                use(a);
52
                use(b);
53
                result = use(result);
54
        }
55
        return result;
56
}
57
 
58
int main()
59
{
60
        func("v4", "v5");
61
        return 0;
62
}
63
 

powered by: WebSVN 2.1.0

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