mirror of
https://github.com/gcc-mirror/gcc.git
synced 2024-11-21 13:40:47 +00:00
7828dc0705
Extend tree-ssa-dse to remove memory allocations that are used only to check that return value is non-NULL and freed. New -fmalloc-dce flag can be used 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). gcc/ChangeLog: PR tree-optimization/117370 * common.opt: Add -fmalloc-dce. * common.opt.urls: Update. * 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 for 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. |
||
---|---|---|
.forgejo | ||
.github | ||
c++tools | ||
config | ||
contrib | ||
fixincludes | ||
gcc | ||
gnattools | ||
gotools | ||
include | ||
INSTALL | ||
libada | ||
libatomic | ||
libbacktrace | ||
libcc1 | ||
libcody | ||
libcpp | ||
libdecnumber | ||
libffi | ||
libgcc | ||
libgfortran | ||
libgm2 | ||
libgo | ||
libgomp | ||
libgrust | ||
libiberty | ||
libitm | ||
libobjc | ||
libphobos | ||
libquadmath | ||
libsanitizer | ||
libssp | ||
libstdc++-v3 | ||
libvtv | ||
lto-plugin | ||
maintainer-scripts | ||
zlib | ||
.b4-config | ||
.dir-locals.el | ||
.gitattributes | ||
.gitignore | ||
ABOUT-NLS | ||
ar-lib | ||
ChangeLog | ||
ChangeLog.jit | ||
ChangeLog.tree-ssa | ||
compile | ||
config-ml.in | ||
config.guess | ||
config.rpath | ||
config.sub | ||
configure | ||
configure.ac | ||
COPYING | ||
COPYING3 | ||
COPYING3.LIB | ||
COPYING.LIB | ||
COPYING.RUNTIME | ||
depcomp | ||
install-sh | ||
libtool-ldflags | ||
libtool.m4 | ||
lt~obsolete.m4 | ||
ltgcc.m4 | ||
ltmain.sh | ||
ltoptions.m4 | ||
ltsugar.m4 | ||
ltversion.m4 | ||
MAINTAINERS | ||
Makefile.def | ||
Makefile.in | ||
Makefile.tpl | ||
missing | ||
mkdep | ||
mkinstalldirs | ||
move-if-change | ||
multilib.am | ||
README | ||
SECURITY.txt | ||
symlink-tree | ||
test-driver | ||
ylwrap |
This directory contains the GNU Compiler Collection (GCC). The GNU Compiler Collection is free software. See the files whose names start with COPYING for copying permission. The manuals, and some of the runtime libraries, are under different terms; see the individual source files for details. The directory INSTALL contains copies of the installation information as HTML and plain text. The source of this information is gcc/doc/install.texi. The installation information includes details of what is included in the GCC sources and what files GCC installs. See the file gcc/doc/gcc.texi (together with other files that it includes) for usage and porting information. An online readable version of the manual is in the files gcc/doc/gcc.info*. See http://gcc.gnu.org/bugs/ for how to report bugs usefully. Copyright years on GCC source files may be listed using range notation, e.g., 1987-2012, indicating that every year in the range, inclusive, is a copyrightable year that could otherwise be listed individually.