aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2018-11-09 16:04:52 +0100
committerMartin Liska <marxin@gcc.gnu.org>2018-11-09 15:04:52 +0000
commit2e14744fcd7820033b91c9516e22eb42b02b5290 (patch)
treecd0f6b1d8e87c8bebf1881f75790b1da936e3006 /gcc
parent9ed3186036f25d9dd870cc2a02bfdf6fc31cde42 (diff)
downloadgcc-2e14744fcd7820033b91c9516e22eb42b02b5290.zip
gcc-2e14744fcd7820033b91c9516e22eb42b02b5290.tar.gz
gcc-2e14744fcd7820033b91c9516e22eb42b02b5290.tar.bz2
Come up with -fipa-reference-addressable flag.
2018-11-09 Martin Liska <mliska@suse.cz> * cgraph.h (ipa_discover_readonly_nonaddressable_vars): Rename to ... (ipa_discover_variable_flags): ... this. * common.opt: Come up with new flag -fipa-reference-addressable. * doc/invoke.texi: Document it. * ipa-reference.c (propagate): Call the renamed fn. * ipa-visibility.c (whole_program_function_and_variable_visibility): Likewise. * ipa.c (ipa_discover_readonly_nonaddressable_vars): Renamed to ... (ipa_discover_variable_flags): ... this. Discover non-addressable variables only with the newly added flag. * opts.c: Enable the newly added flag with -O1 and higher optimization level. 2018-11-09 Martin Liska <mliska@suse.cz> * gcc.dg/tree-ssa/writeonly-2.c: New test. From-SVN: r265969
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog17
-rw-r--r--gcc/cgraph.h2
-rw-r--r--gcc/common.opt6
-rw-r--r--gcc/doc/invoke.texi10
-rw-r--r--gcc/ipa-reference.c2
-rw-r--r--gcc/ipa-visibility.c2
-rw-r--r--gcc/ipa.c11
-rw-r--r--gcc/opts.c1
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/writeonly-2.c20
10 files changed, 65 insertions, 10 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 6bdbaae..6a30303 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,20 @@
+2018-11-09 Martin Liska <mliska@suse.cz>
+
+ * cgraph.h (ipa_discover_readonly_nonaddressable_vars): Rename
+ to ...
+ (ipa_discover_variable_flags): ... this.
+ * common.opt: Come up with new flag -fipa-reference-addressable.
+ * doc/invoke.texi: Document it.
+ * ipa-reference.c (propagate): Call the renamed fn.
+ * ipa-visibility.c (whole_program_function_and_variable_visibility):
+ Likewise.
+ * ipa.c (ipa_discover_readonly_nonaddressable_vars): Renamed to
+ ...
+ (ipa_discover_variable_flags): ... this. Discover
+ non-addressable variables only with the newly added flag.
+ * opts.c: Enable the newly added flag with -O1 and higher
+ optimization level.
+
2018-11-09 David Malcolm <dmalcolm@redhat.com>
* json.cc (selftest::test_writing_literals): Fix comment.
diff --git a/gcc/cgraph.h b/gcc/cgraph.h
index 0215522..dd1e8fd 100644
--- a/gcc/cgraph.h
+++ b/gcc/cgraph.h
@@ -2403,7 +2403,7 @@ void record_references_in_initializer (tree, bool);
/* In ipa.c */
void cgraph_build_static_cdtor (char which, tree body, int priority);
-bool ipa_discover_readonly_nonaddressable_vars (void);
+bool ipa_discover_variable_flags (void);
/* In varpool.c */
tree ctor_for_folding (tree);
diff --git a/gcc/common.opt b/gcc/common.opt
index 99489fb..cba516e 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1722,7 +1722,11 @@ Perform Identical Code Folding for variables.
fipa-reference
Common Report Var(flag_ipa_reference) Init(0) Optimization
-Discover readonly and non addressable static variables.
+Discover read-only and non addressable static variables.
+
+fipa-reference-addressable
+Common Report Var(flag_ipa_reference_addressable) Init(0) Optimization
+Discover read-only, write-only and non-addressable static variables.
fipa-matrix-reorg
Common Ignore
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 028a896..e510fef 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -413,8 +413,8 @@ Objective-C and Objective-C++ Dialects}.
-finline-functions -finline-functions-called-once -finline-limit=@var{n} @gol
-finline-small-functions -fipa-cp -fipa-cp-clone @gol
-fipa-bit-cp -fipa-vrp @gol
--fipa-pta -fipa-profile -fipa-pure-const -fipa-reference -fipa-icf @gol
--fira-algorithm=@var{algorithm} @gol
+-fipa-pta -fipa-profile -fipa-pure-const -fipa-reference -fipa-reference-addressable @gol
+-fipa-icf -fira-algorithm=@var{algorithm} @gol
-fira-region=@var{region} -fira-hoist-pressure @gol
-fira-loop-pressure -fno-ira-share-save-slots @gol
-fno-ira-share-spill-slots @gol
@@ -7882,6 +7882,7 @@ compilation time.
-fipa-pure-const @gol
-fipa-profile @gol
-fipa-reference @gol
+-fipa-reference-addressable @gol
-fmerge-constants @gol
-fmove-loop-invariants @gol
-fomit-frame-pointer @gol
@@ -8911,6 +8912,11 @@ Discover which static variables do not escape the
compilation unit.
Enabled by default at @option{-O} and higher.
+@item -fipa-reference-addressable
+@opindex fipa-reference-addressable
+Discover read-only, write-only and non-addressable static variables.
+Enabled by default at @option{-O} and higher.
+
@item -fipa-pta
@opindex fipa-pta
Perform interprocedural pointer analysis and interprocedural modification
diff --git a/gcc/ipa-reference.c b/gcc/ipa-reference.c
index 43bbdae..6242aef 100644
--- a/gcc/ipa-reference.c
+++ b/gcc/ipa-reference.c
@@ -705,7 +705,7 @@ propagate (void)
if (dump_file)
cgraph_node::dump_cgraph (dump_file);
- remove_p = ipa_discover_readonly_nonaddressable_vars ();
+ remove_p = ipa_discover_variable_flags ();
generate_summary ();
/* Propagate the local information through the call graph to produce
diff --git a/gcc/ipa-visibility.c b/gcc/ipa-visibility.c
index 000207fa..35de913 100644
--- a/gcc/ipa-visibility.c
+++ b/gcc/ipa-visibility.c
@@ -911,7 +911,7 @@ whole_program_function_and_variable_visibility (void)
{
function_and_variable_visibility (flag_whole_program);
if (optimize || in_lto_p)
- ipa_discover_readonly_nonaddressable_vars ();
+ ipa_discover_variable_flags ();
return 0;
}
diff --git a/gcc/ipa.c b/gcc/ipa.c
index 3b6b5e5..22c2135 100644
--- a/gcc/ipa.c
+++ b/gcc/ipa.c
@@ -752,10 +752,10 @@ clear_addressable_bit (varpool_node *vnode, void *data ATTRIBUTE_UNUSED)
return false;
}
-/* Discover variables that have no longer address taken or that are read only
- and update their flags.
+/* Discover variables that have no longer address taken, are read-only or
+ write-only and update their flags.
- Return true when unreachable symbol removan should be done.
+ Return true when unreachable symbol removal should be done.
FIXME: This can not be done in between gimplify and omp_expand since
readonly flag plays role on what is shared and what is not. Currently we do
@@ -764,8 +764,11 @@ clear_addressable_bit (varpool_node *vnode, void *data ATTRIBUTE_UNUSED)
make sense to do it before early optimizations. */
bool
-ipa_discover_readonly_nonaddressable_vars (void)
+ipa_discover_variable_flags (void)
{
+ if (!flag_ipa_reference_addressable)
+ return false;
+
bool remove_p = false;
varpool_node *vnode;
if (dump_file)
diff --git a/gcc/opts.c b/gcc/opts.c
index f094f5f..e21967b 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -451,6 +451,7 @@ static const struct default_options default_options_table[] =
{ OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_fif_conversion2, NULL, 1 },
{ OPT_LEVELS_1_PLUS, OPT_fipa_pure_const, NULL, 1 },
{ OPT_LEVELS_1_PLUS, OPT_fipa_reference, NULL, 1 },
+ { OPT_LEVELS_1_PLUS, OPT_fipa_reference_addressable, NULL, 1 },
{ OPT_LEVELS_1_PLUS, OPT_fipa_profile, NULL, 1 },
{ OPT_LEVELS_1_PLUS, OPT_fmerge_constants, NULL, 1 },
{ OPT_LEVELS_1_PLUS, OPT_freorder_blocks, NULL, 1 },
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 8fa0c47..6dd28ff 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2018-11-09 Martin Liska <mliska@suse.cz>
+
+ * gcc.dg/tree-ssa/writeonly-2.c: New test.
+
2018-11-09 Jakub Jelinek <jakub@redhat.com>
* gcc.dg/gomp/workshare-reduction-1.c: New test.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/writeonly-2.c b/gcc/testsuite/gcc.dg/tree-ssa/writeonly-2.c
new file mode 100644
index 0000000..2272d15
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/writeonly-2.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -fdump-tree-optimized -fno-ipa-reference-addressable" } */
+static struct a {int magic1,b;} a;
+volatile int magic2;
+static struct b {int a,b,c,d,e,f;} magic3;
+
+struct b foo();
+
+void
+t()
+{
+ a.magic1 = 1;
+ magic2 = 1;
+ magic3 = foo();
+}
+/* { dg-final { scan-tree-dump "magic1" "optimized"} } */
+/* { dg-final { scan-tree-dump "magic3" "optimized"} } */
+/* { dg-final { scan-tree-dump "magic2" "optimized"} } */
+/* { dg-final { scan-tree-dump "foo" "optimized"} } */
+