Commit 05842ff5 by Martin Jambor Committed by Martin Jambor

common.opt (fdevirtualize): New flag.

2011-01-15  Martin Jambor  <mjambor@suse.cz>

	* common.opt (fdevirtualize): New flag.
	* doc/invoke.texi (Option Summary): Document it.
	* opts.c (default_options_table): Add devirtualize flag.
	* ipa-prop.c (detect_type_change): Return immediately if
	devirtualize flag is not set.
	(detect_type_change_ssa): Likewise.
	(compute_known_type_jump_func): Likewise.
	(ipa_analyze_virtual_call_uses): Likewise.

From-SVN: r168826
parent f65cf2b7
2011-01-15 Martin Jambor <mjambor@suse.cz>
* common.opt (fdevirtualize): New flag.
* doc/invoke.texi (Option Summary): Document it.
* opts.c (default_options_table): Add devirtualize flag.
* ipa-prop.c (detect_type_change): Return immediately if
devirtualize flag is not set.
(detect_type_change_ssa): Likewise.
(compute_known_type_jump_func): Likewise.
(ipa_analyze_virtual_call_uses): Likewise.
2011-01-14 Martin Jambor <mjambor@suse.cz> 2011-01-14 Martin Jambor <mjambor@suse.cz>
PR tree-optimization/45934 PR tree-optimization/45934
......
...@@ -911,6 +911,10 @@ fdelete-null-pointer-checks ...@@ -911,6 +911,10 @@ fdelete-null-pointer-checks
Common Report Var(flag_delete_null_pointer_checks) Init(1) Optimization Common Report Var(flag_delete_null_pointer_checks) Init(1) Optimization
Delete useless null pointer checks Delete useless null pointer checks
fdevirtualize
Common Report Var(flag_devirtualize) Optimization
Try to convert virtual calls to direct ones.
fdiagnostics-show-location= fdiagnostics-show-location=
Common Joined RejectNegative Enum(diagnostic_prefixing_rule) Common Joined RejectNegative Enum(diagnostic_prefixing_rule)
-fdiagnostics-show-location=[once|every-line] How often to emit source location at the beginning of line-wrapped diagnostics -fdiagnostics-show-location=[once|every-line] How often to emit source location at the beginning of line-wrapped diagnostics
......
...@@ -340,8 +340,8 @@ Objective-C and Objective-C++ Dialects}. ...@@ -340,8 +340,8 @@ Objective-C and Objective-C++ Dialects}.
-fcprop-registers -fcrossjumping @gol -fcprop-registers -fcrossjumping @gol
-fcse-follow-jumps -fcse-skip-blocks -fcx-fortran-rules @gol -fcse-follow-jumps -fcse-skip-blocks -fcx-fortran-rules @gol
-fcx-limited-range @gol -fcx-limited-range @gol
-fdata-sections -fdce -fdce @gol -fdata-sections -fdce -fdce -fdelayed-branch @gol
-fdelayed-branch -fdelete-null-pointer-checks -fdse -fdse @gol -fdelete-null-pointer-checks -fdse -fdevirtualize -fdse @gol
-fearly-inlining -fipa-sra -fexpensive-optimizations -ffast-math @gol -fearly-inlining -fipa-sra -fexpensive-optimizations -ffast-math @gol
-ffinite-math-only -ffloat-store -fexcess-precision=@var{style} @gol -ffinite-math-only -ffloat-store -fexcess-precision=@var{style} @gol
-fforward-propagate -ffp-contract=@var{style} -ffunction-sections @gol -fforward-propagate -ffp-contract=@var{style} -ffunction-sections @gol
...@@ -5918,6 +5918,7 @@ also turns on the following optimization flags: ...@@ -5918,6 +5918,7 @@ also turns on the following optimization flags:
-fcrossjumping @gol -fcrossjumping @gol
-fcse-follow-jumps -fcse-skip-blocks @gol -fcse-follow-jumps -fcse-skip-blocks @gol
-fdelete-null-pointer-checks @gol -fdelete-null-pointer-checks @gol
-fdevirtualize @gol
-fexpensive-optimizations @gol -fexpensive-optimizations @gol
-fgcse -fgcse-lm @gol -fgcse -fgcse-lm @gol
-finline-small-functions @gol -finline-small-functions @gol
...@@ -6421,6 +6422,14 @@ Otherwise it is enabled at all levels: @option{-O0}, @option{-O1}, ...@@ -6421,6 +6422,14 @@ Otherwise it is enabled at all levels: @option{-O0}, @option{-O1},
@option{-O2}, @option{-O3}, @option{-Os}. Passes that use the information @option{-O2}, @option{-O3}, @option{-Os}. Passes that use the information
are enabled independently at different optimization levels. are enabled independently at different optimization levels.
@item -fdevirtualize
@opindex fdevirtualize
Attempt to convert calls to virtual functions to direct calls. This
is done both within a procedure and interprocedurally as part of
indirect inlining (@code{-findirect-inlining}) and interprocedural constant
propagation (@option{-fipa-cp}).
Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
@item -fexpensive-optimizations @item -fexpensive-optimizations
@opindex fexpensive-optimizations @opindex fexpensive-optimizations
Perform a number of minor optimizations that are relatively expensive. Perform a number of minor optimizations that are relatively expensive.
......
...@@ -456,7 +456,7 @@ detect_type_change (tree arg, tree base, gimple call, ...@@ -456,7 +456,7 @@ detect_type_change (tree arg, tree base, gimple call,
|| handled_component_p (arg)); || handled_component_p (arg));
/* Const calls cannot call virtual methods through VMT and so type changes do /* Const calls cannot call virtual methods through VMT and so type changes do
not matter. */ not matter. */
if (!gimple_vuse (call)) if (!flag_devirtualize || !gimple_vuse (call))
return false; return false;
tci.type_maybe_changed = false; tci.type_maybe_changed = false;
...@@ -486,7 +486,8 @@ static bool ...@@ -486,7 +486,8 @@ static bool
detect_type_change_ssa (tree arg, gimple call, struct ipa_jump_func *jfunc) detect_type_change_ssa (tree arg, gimple call, struct ipa_jump_func *jfunc)
{ {
gcc_checking_assert (TREE_CODE (arg) == SSA_NAME); gcc_checking_assert (TREE_CODE (arg) == SSA_NAME);
if (!POINTER_TYPE_P (TREE_TYPE (arg)) if (!flag_devirtualize
|| !POINTER_TYPE_P (TREE_TYPE (arg))
|| TREE_CODE (TREE_TYPE (TREE_TYPE (arg))) != RECORD_TYPE) || TREE_CODE (TREE_TYPE (TREE_TYPE (arg))) != RECORD_TYPE)
return false; return false;
...@@ -689,7 +690,8 @@ compute_known_type_jump_func (tree op, struct ipa_jump_func *jfunc, ...@@ -689,7 +690,8 @@ compute_known_type_jump_func (tree op, struct ipa_jump_func *jfunc,
HOST_WIDE_INT offset, size, max_size; HOST_WIDE_INT offset, size, max_size;
tree base, binfo; tree base, binfo;
if (TREE_CODE (op) != ADDR_EXPR if (!flag_devirtualize
|| TREE_CODE (op) != ADDR_EXPR
|| TREE_CODE (TREE_TYPE (TREE_TYPE (op))) != RECORD_TYPE) || TREE_CODE (TREE_TYPE (TREE_TYPE (op))) != RECORD_TYPE)
return; return;
...@@ -1378,6 +1380,9 @@ ipa_analyze_virtual_call_uses (struct cgraph_node *node, ...@@ -1378,6 +1380,9 @@ ipa_analyze_virtual_call_uses (struct cgraph_node *node,
tree var; tree var;
int index; int index;
if (!flag_devirtualize)
return;
if (TREE_CODE (obj) == ADDR_EXPR) if (TREE_CODE (obj) == ADDR_EXPR)
{ {
do do
......
...@@ -485,6 +485,7 @@ static const struct default_options default_options_table[] = ...@@ -485,6 +485,7 @@ static const struct default_options default_options_table[] =
{ OPT_LEVELS_2_PLUS, OPT_ftree_pre, NULL, 1 }, { OPT_LEVELS_2_PLUS, OPT_ftree_pre, NULL, 1 },
{ OPT_LEVELS_2_PLUS, OPT_ftree_switch_conversion, NULL, 1 }, { OPT_LEVELS_2_PLUS, OPT_ftree_switch_conversion, NULL, 1 },
{ OPT_LEVELS_2_PLUS, OPT_fipa_cp, NULL, 1 }, { OPT_LEVELS_2_PLUS, OPT_fipa_cp, NULL, 1 },
{ OPT_LEVELS_2_PLUS, OPT_fdevirtualize, NULL, 1 },
{ OPT_LEVELS_2_PLUS, OPT_fipa_sra, NULL, 1 }, { OPT_LEVELS_2_PLUS, OPT_fipa_sra, NULL, 1 },
{ OPT_LEVELS_2_PLUS, OPT_falign_loops, NULL, 1 }, { OPT_LEVELS_2_PLUS, OPT_falign_loops, NULL, 1 },
{ OPT_LEVELS_2_PLUS, OPT_falign_jumps, NULL, 1 }, { OPT_LEVELS_2_PLUS, OPT_falign_jumps, NULL, 1 },
......
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