Debian Codegraph @

gcc/testsuite/gcc.c-torture/execute/pr15262-1.c

raw
1 /* PR 15262.
2 The alias analyzer only considers relations between pointers and
3 symbols. If two pointers P and Q point to the same symbol S, then
4 their respective memory tags will either be the same or they will
5 have S in their alias set.
6
7 However, if there are no common symbols between P and Q, TBAA will
8 currently miss their alias relationship altogether. */
9
10 void abort (void);
11
12 struct A
13 {
14 int t;
15 int i;
16 };
17
18 int foo () { return 3; }
19
20 int
21 main (void)
22 {
23 struct A loc, *locp;
24 float f, g, *p;
25 int T355, *T356;
26
27 /* Avoid the partial hack in TBAA that would consider memory tags if
28 the program had no addressable symbols. */
29 f = 3;
30 g = 2;
31 p = foo () ? &g : &f;
32 if (*p > 0.0)
33 g = 1;
34
35 /* Store into *locp and cache its current value. */
36 locp = __builtin_malloc (sizeof (*locp));
37 locp->i = 10;
38 T355 = locp->i;
39
40 /* Take the address of one of locp's fields and write to it. */
41 T356 = &locp->i;
42 *T356 = 1;
43
44 /* Read the recently stored value. If TBAA fails, this will appear
45 as a redundant load that will be replaced with '10'. */
46 T355 = locp->i;
47 if (T355 != 1)
48 abort ();
49
50 return 0;
51 }