aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
authorJan Hubicka <hubicka@ucw.cz>2024-11-16 23:45:57 +0100
committerJan Hubicka <hubicka@ucw.cz>2024-11-16 23:45:57 +0100
commitcc33f880e553d1aa94d19a349ad755f34c33de9e (patch)
treecdb3d608e449d8296c7592813a77a13790c951f1 /gcc/testsuite
parent101f8c73d575b4746e49b0ea35eb6cc24de1dfdc (diff)
downloadgcc-cc33f880e553d1aa94d19a349ad755f34c33de9e.zip
gcc-cc33f880e553d1aa94d19a349ad755f34c33de9e.tar.gz
gcc-cc33f880e553d1aa94d19a349ad755f34c33de9e.tar.bz2
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.
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/g++.dg/tree-ssa/pr109442.C12
1 files changed, 12 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr109442.C b/gcc/testsuite/g++.dg/tree-ssa/pr109442.C
new file mode 100644
index 0000000..ec40c47
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tree-ssa/pr109442.C
@@ -0,0 +1,12 @@
+// { dg-do compile { target c++11 } }
+// { dg-options "-O1 -fdump-tree-optimized" }
+#include <vector>
+#define T int
+T vat1(std::vector<T> v1) {
+ auto v = v1;
+ return 10;
+}
+// This should compile to empty function; check that no size of
+// vector is determined and there is no allocation
+// { dg-final { scan-tree-dump-not "_M_start" "optimized" } }
+// { dg-final { scan-tree-dump-not "delete" "optimized" } }