diff mbox

Fix PR19831, remove malloc/free pairs

Message ID alpine.LNX.2.00.1109081454340.2130@zhemvz.fhfr.qr
State New
Headers show

Commit Message

Richard Biener Sept. 8, 2011, 12:55 p.m. UTC
On Thu, 8 Sep 2011, Richard Guenther wrote:

> 
> This implements removal of malloc/free pairs when allowed for a
> subset of all possible cases.  The idea is to identify possible
> candidates (we free the return value of an allocation call) and
> for them do not make the allocation function necessary because
> of the free.  If nothing else made the allocation necessary,
> go ahead and make the free call not necessary as well after
> propagation.
> 
> Integrating this with control-dependence is much harder but
> would then handle also if (p) free (p).  The testcases contain
> some tricky cases that break when you do it too simple-minded.
> 
> Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

And we hit gcc.dg/errno-1.c, adjusted as follows


which keeps the malloc live.  The testcase wants to verify
that we don't CSE errno across malloc.

Committed.

Richard.
diff mbox

Patch

Index: gcc/testsuite/gcc.dg/errno-1.c
===================================================================
--- gcc/testsuite/gcc.dg/errno-1.c      (revision 178684)
+++ gcc/testsuite/gcc.dg/errno-1.c      (working copy)
@@ -6,7 +6,7 @@ 

 int main()
 {
-  void *p;
+  void * volatile p;
   errno = 0;
   p = malloc (-1);
   if (errno != 0)