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 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) which keeps the malloc live. The testcase wants to verify that we don't CSE errno across malloc. Committed. Richard.