]> git.ipfire.org Git - thirdparty/gcc.git/commit
Avoid expicit builtion list in tree-ssa-dce
authorJan Hubicka <hubicka@ucw.cz>
Sat, 16 Nov 2024 22:45:57 +0000 (23:45 +0100)
committerJan Hubicka <hubicka@ucw.cz>
Sat, 16 Nov 2024 22:45:57 +0000 (23:45 +0100)
commitcc33f880e553d1aa94d19a349ad755f34c33de9e
treecdb3d608e449d8296c7592813a77a13790c951f1
parent101f8c73d575b4746e49b0ea35eb6cc24de1dfdc
Avoid expicit builtion list in tree-ssa-dce

while working on -fmalloc-dce I noticed that tree-ssa-dce.cc still has an
outdated list of builtions that are known to not read memory that can be
replaced by query to fnspec and modref.

If I get things right, dce does some dead store removal, but only on those
memory object that are non-aliased (automatic variabels with no address taken)
and for all other memory addresses it resorts to
mark_all_reaching_defs_necessary expecting DSE to do the rest.  So we really
want to only check if there are no memory reads at all rather then trying to
understand them by parsing fnspec or modref summary.

I did run testsuite ensuring that all builtins matched previously are
still matched.  There are few testcases where this check fails, due to
type incompatibility.  New code uses gimple_call_builtin while other
just checked callee_decl.

We test things like calling free() without parmeter which I don't think
we want to care about, but there is also testase declaring

void * calloc (long, long)

where builtin declaration expects unsigned long.  I am not sure if this
case should not be allowed by gimple_call_builtin?

Bootstrappe/regtested x86_64-linux. OK?

gcc/ChangeLog:

* ipa-modref.cc (ipa_modref_callee_reads_no_memory_p): New function.
* ipa-modref.h (ipa_modref_callee_reads_no_memory_p): Declare
* tree-ssa-dce.cc (propagate_necessity): Use it.
gcc/ipa-modref.cc
gcc/ipa-modref.h
gcc/testsuite/g++.dg/tree-ssa/pr109442.C [new file with mode: 0644]
gcc/tree-ssa-dce.cc