111
|
1 /* { dg-do compile } */
|
|
2 /* { dg-options "-O2 -fno-ipa-icf -fdump-tree-optimized" } */
|
|
3
|
|
4 void test2(void)
|
|
5 {
|
|
6 int *p = __builtin_malloc (sizeof (int) * 4);
|
|
7 if (p == (void *)0)
|
|
8 __builtin_abort ();
|
|
9 __builtin_free (p);
|
|
10 }
|
|
11
|
|
12 void test5(int b)
|
|
13 {
|
|
14 int *p = __builtin_malloc (sizeof (int) * 4);
|
|
15 if (p)
|
|
16 __builtin_free (p);
|
|
17 }
|
|
18
|
|
19 void test6(void)
|
|
20 {
|
|
21 int *p = __builtin_malloc (sizeof (int) * 4);
|
|
22 if (p == (void *)0)
|
|
23 __builtin_abort ();
|
|
24 if (p)
|
|
25 __builtin_free (p);
|
|
26 }
|
|
27
|
|
28 /* We should be able to remove all malloc/free pairs with CDDCE.
|
|
29 Assume p was non-NULL for test2.
|
|
30 For test5, it doesn't matter if p is NULL or non-NULL. */
|
|
31
|
|
32 /* { dg-final { scan-tree-dump-times "free" 0 "optimized" { xfail *-*-* } } } */
|
|
33 /* { dg-final { scan-tree-dump-times "malloc" 0 "optimized" { xfail *-*-* } } } */
|
|
34
|
|
35 /* But make sure we don't partially optimize for now. */
|
|
36
|
|
37 /* { dg-final { scan-tree-dump-times "free" 3 "optimized" } } */
|
|
38 /* { dg-final { scan-tree-dump-times "malloc" 3 "optimized" } } */
|