Commit 2e14744f by Martin Liska Committed by Martin Liska

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
parent 9ed31860
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> 2018-11-09 David Malcolm <dmalcolm@redhat.com>
* json.cc (selftest::test_writing_literals): Fix comment. * json.cc (selftest::test_writing_literals): Fix comment.
...@@ -2403,7 +2403,7 @@ void record_references_in_initializer (tree, bool); ...@@ -2403,7 +2403,7 @@ void record_references_in_initializer (tree, bool);
/* In ipa.c */ /* In ipa.c */
void cgraph_build_static_cdtor (char which, tree body, int priority); 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 */ /* In varpool.c */
tree ctor_for_folding (tree); tree ctor_for_folding (tree);
......
...@@ -1722,7 +1722,11 @@ Perform Identical Code Folding for variables. ...@@ -1722,7 +1722,11 @@ Perform Identical Code Folding for variables.
fipa-reference fipa-reference
Common Report Var(flag_ipa_reference) Init(0) Optimization 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 fipa-matrix-reorg
Common Ignore Common Ignore
......
...@@ -413,8 +413,8 @@ Objective-C and Objective-C++ Dialects}. ...@@ -413,8 +413,8 @@ Objective-C and Objective-C++ Dialects}.
-finline-functions -finline-functions-called-once -finline-limit=@var{n} @gol -finline-functions -finline-functions-called-once -finline-limit=@var{n} @gol
-finline-small-functions -fipa-cp -fipa-cp-clone @gol -finline-small-functions -fipa-cp -fipa-cp-clone @gol
-fipa-bit-cp -fipa-vrp @gol -fipa-bit-cp -fipa-vrp @gol
-fipa-pta -fipa-profile -fipa-pure-const -fipa-reference -fipa-icf @gol -fipa-pta -fipa-profile -fipa-pure-const -fipa-reference -fipa-reference-addressable @gol
-fira-algorithm=@var{algorithm} @gol -fipa-icf -fira-algorithm=@var{algorithm} @gol
-fira-region=@var{region} -fira-hoist-pressure @gol -fira-region=@var{region} -fira-hoist-pressure @gol
-fira-loop-pressure -fno-ira-share-save-slots @gol -fira-loop-pressure -fno-ira-share-save-slots @gol
-fno-ira-share-spill-slots @gol -fno-ira-share-spill-slots @gol
...@@ -7882,6 +7882,7 @@ compilation time. ...@@ -7882,6 +7882,7 @@ compilation time.
-fipa-pure-const @gol -fipa-pure-const @gol
-fipa-profile @gol -fipa-profile @gol
-fipa-reference @gol -fipa-reference @gol
-fipa-reference-addressable @gol
-fmerge-constants @gol -fmerge-constants @gol
-fmove-loop-invariants @gol -fmove-loop-invariants @gol
-fomit-frame-pointer @gol -fomit-frame-pointer @gol
...@@ -8911,6 +8912,11 @@ Discover which static variables do not escape the ...@@ -8911,6 +8912,11 @@ Discover which static variables do not escape the
compilation unit. compilation unit.
Enabled by default at @option{-O} and higher. 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 @item -fipa-pta
@opindex fipa-pta @opindex fipa-pta
Perform interprocedural pointer analysis and interprocedural modification Perform interprocedural pointer analysis and interprocedural modification
...@@ -705,7 +705,7 @@ propagate (void) ...@@ -705,7 +705,7 @@ propagate (void)
if (dump_file) if (dump_file)
cgraph_node::dump_cgraph (dump_file); cgraph_node::dump_cgraph (dump_file);
remove_p = ipa_discover_readonly_nonaddressable_vars (); remove_p = ipa_discover_variable_flags ();
generate_summary (); generate_summary ();
/* Propagate the local information through the call graph to produce /* Propagate the local information through the call graph to produce
......
...@@ -911,7 +911,7 @@ whole_program_function_and_variable_visibility (void) ...@@ -911,7 +911,7 @@ whole_program_function_and_variable_visibility (void)
{ {
function_and_variable_visibility (flag_whole_program); function_and_variable_visibility (flag_whole_program);
if (optimize || in_lto_p) if (optimize || in_lto_p)
ipa_discover_readonly_nonaddressable_vars (); ipa_discover_variable_flags ();
return 0; return 0;
} }
......
...@@ -752,10 +752,10 @@ clear_addressable_bit (varpool_node *vnode, void *data ATTRIBUTE_UNUSED) ...@@ -752,10 +752,10 @@ clear_addressable_bit (varpool_node *vnode, void *data ATTRIBUTE_UNUSED)
return false; return false;
} }
/* Discover variables that have no longer address taken or that are read only /* Discover variables that have no longer address taken, are read-only or
and update their flags. 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 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 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) ...@@ -764,8 +764,11 @@ clear_addressable_bit (varpool_node *vnode, void *data ATTRIBUTE_UNUSED)
make sense to do it before early optimizations. */ make sense to do it before early optimizations. */
bool bool
ipa_discover_readonly_nonaddressable_vars (void) ipa_discover_variable_flags (void)
{ {
if (!flag_ipa_reference_addressable)
return false;
bool remove_p = false; bool remove_p = false;
varpool_node *vnode; varpool_node *vnode;
if (dump_file) if (dump_file)
......
...@@ -451,6 +451,7 @@ static const struct default_options default_options_table[] = ...@@ -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_NOT_DEBUG, OPT_fif_conversion2, NULL, 1 },
{ OPT_LEVELS_1_PLUS, OPT_fipa_pure_const, 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, 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_fipa_profile, NULL, 1 },
{ OPT_LEVELS_1_PLUS, OPT_fmerge_constants, NULL, 1 }, { OPT_LEVELS_1_PLUS, OPT_fmerge_constants, NULL, 1 },
{ OPT_LEVELS_1_PLUS, OPT_freorder_blocks, 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> 2018-11-09 Jakub Jelinek <jakub@redhat.com>
* gcc.dg/gomp/workshare-reduction-1.c: New test. * gcc.dg/gomp/workshare-reduction-1.c: New test.
......
/* { 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"} } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment