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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@265969
138bc75d-0d04-0410-961f-
82ee72b054a4
+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.
/* 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);
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
-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
-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
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
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
{
function_and_variable_visibility (flag_whole_program);
if (optimize || in_lto_p)
- ipa_discover_readonly_nonaddressable_vars ();
+ ipa_discover_variable_flags ();
return 0;
}
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
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)
{ 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 },
+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.
--- /dev/null
+/* { 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"} } */
+