> Hi,
> this is updated patch which adds -fmalloc-dce flag to control malloc/free
> removal.  I ended up copying what -fallocation-dse does so -fmalloc-dce=1
> enables malloc/free removal provided return value is unused otherwise and
> -fmalloc-dce=2 allows additional NULL pointer checks which it folds to 
> non-NULL
> direction.
> 
> I also added compensation for the gcc.dg/analyzer/pr101837.c testcase and
> added testcase that std::nothrow variant of operator new is now optimized way.
> 
> With the -fmalloc-dce=n I can also add a level which emits runtime check for 
> half
> of address space and calloc overflow if it seems useful, but perhaps
> incrementally.  Adding size parameter tracking is not that hard (I posted WIP
> patch for that).
> 
> Bootstrapped/regtested x86_64-linux, OK?
> 
>       * common.opt: Add -fmalloc-dce.
>       * doc/invoke.texi: Document it; also add missing -flifetime-dse entry.
>       * tree-ssa-dce.cc (is_removable_allocation_p): Break out from
>       ...
>       (mark_stmt_if_obviously_necessary): ... here; also check that
>       operator new satisfies gimple_call_from_new_or_delete.
>       (checks_return_value_of_removable_allocation_p): New Function.
>       (mark_all_reaching_defs_necessary_1): add missing case ofr
>       STRDUP and STRNDUP
>       (propagate_necessity): Use is_removable_allocation_p and
>       checks_return_value_of_removable_allocation_p.
>       (eliminate_unnecessary_stmts): Update conditionals that use
>       removed allocation; use is_removable_allocation_p.
> 
> gcc/testsuite/ChangeLog:
> 
>       * g++.dg/cdce3.C: Disable allocation dce.
>       * g++.dg/tree-ssa/pr19476-1.C: Likewise.
>       * g++.dg/tree-ssa/pr19476-2.C: Likewise.
>       * g++.dg/tree-ssa/pr19476-3.C: Likewise.
>       * g++.dg/tree-ssa/pr19476-4.C: Likewise.
>       * gcc.dg/analyzer/pr101837.c: Disable malloc dce.
>       * gcc.dg/tree-ssa/pr19831-3.c: Update.
>       * gfortran.dg/pr68078.f90: Disable malloc DCE.
>       * g++.dg/tree-ssa/dce-1.C: New test.

I would like to ping this, since I have some followup changes on DCE.

thanks,
Honza

Reply via email to