Debian Codegraph @

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

raw
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fdump-tree-local-pure-const-details -fdelete-null-pointer-checks" } */
3 /* { dg-skip-if "" keeps_null_pointer_checks } */
4
5 void *foo(int cond1, int cond2, int cond3)
6 {
7 void *ret;
8 void *a;
9 void *b;
10
11 if (cond1)
12 a = __builtin_malloc (10);
13 else
14 a = __builtin_malloc (20);
15
16 if (cond2)
17 b = __builtin_malloc (30);
18 else
19 b = __builtin_malloc (40);
20
21 if (cond3)
22 ret = a;
23 else
24 ret = b;
25
26 return ret;
27 }
28
29 void *foo2(int cond1, int cond2, int cond3)
30 {
31 void *ret;
32 void *a;
33 void *b;
34 void bar(void *, void *);
35
36 if (cond1)
37 a = __builtin_malloc (10);
38 else
39 a = __builtin_malloc (20);
40
41 if (cond2)
42 b = __builtin_malloc (30);
43 else
44 b = __builtin_malloc (40);
45
46 bar (a, b);
47
48 if (cond3)
49 ret = a;
50 else
51 ret = b;
52
53 return ret;
54 }
55
56 /* { dg-final { scan-tree-dump "Function found to be malloc: foo" "local-pure-const1" } } */
57 /* { dg-final { scan-tree-dump-not "Function found to be malloc: foo2" "local-pure-const1" } } */