Debian Codegraph @

gcc/testsuite/gcc.dg/ipa/pr110378-4.c

raw
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fdump-ipa-sra -fdump-tree-optimized-slim" } */
3
4 /* This emulates what C++ trstcase pr110378-1.C looks like on 32-bit arm (or
5 any architecture where the destructor returns this pointer. It verifies
6 that when it later becomes known that the return value will be removed, we
7 can split a parameter even in this case. */
8
9 struct S
10 {
11 short move_offset_of_a;
12 int *a;
13 };
14
15 extern int *allocate_stuff (unsigned);
16 extern void deallocate_stuff (void *);
17
18 static void
19 something_like_a_constructor (struct S *p, int len)
20 {
21 p->a = allocate_stuff (len * sizeof (int));
22 *p->a = 4;
23 }
24
25 static int
26 operation (struct S *p)
27 {
28 return *p->a + 1;
29 }
30
31 static struct S * __attribute__((noinline))
32 something_like_an_arm32_destructor (struct S *p)
33 {
34 deallocate_stuff (p->a);
35 return p;
36 }
37
38 volatile int v2 = 20;
39
40 int test (void)
41 {
42 struct S shouldnotexist;
43 something_like_a_constructor (&shouldnotexist, v2);
44 v2 = operation (&shouldnotexist);
45 something_like_an_arm32_destructor (&shouldnotexist);
46 return 0;
47 }
48
49 /* { dg-final { scan-ipa-dump "Will split parameter 0" "sra" } } */
50 /* { dg-final { scan-tree-dump-not "shouldnotexist" "optimized" } } */