Reload global options when strict aliasing is dropped (PR ipa/79043).

2017-01-13  Martin Liska  <mliska@suse.cz>

	PR ipa/79043
	* function.c (set_cfun): Add new argument force.
	* function.h (set_cfun): Likewise.
	* ipa-inline-transform.c (inline_call): Use the function when
	strict alising from is dropped for function we inline to.
2017-01-13  Martin Liska  <mliska@suse.cz>

	PR ipa/79043
	* gcc.c-torture/execute/pr79043.c: New test.

From-SVN: r244435
This commit is contained in:
Martin Liska 2017-01-13 13:56:54 +01:00 committed by Martin Liska
parent b1c95bb595
commit 77719b0675
6 changed files with 45 additions and 3 deletions

View File

@ -1,3 +1,11 @@
2017-01-13 Martin Liska <mliska@suse.cz>
PR ipa/79043
* function.c (set_cfun): Add new argument force.
* function.h (set_cfun): Likewise.
* ipa-inline-transform.c (inline_call): Use the function when
strict alising from is dropped for function we inline to.
2017-01-13 Richard Biener <rguenther@suse.de>
* tree-pretty-print.c (dump_generic_node): Fix inverted condition

View File

@ -4811,9 +4811,9 @@ invoke_set_current_function_hook (tree fndecl)
/* cfun should never be set directly; use this function. */
void
set_cfun (struct function *new_cfun)
set_cfun (struct function *new_cfun, bool force)
{
if (cfun != new_cfun)
if (cfun != new_cfun || force)
{
cfun = new_cfun;
invoke_set_current_function_hook (new_cfun ? new_cfun->decl : NULL_TREE);

View File

@ -613,7 +613,7 @@ extern tree block_chainon (tree, tree);
extern void number_blocks (tree);
/* cfun shouldn't be set directly; use one of these functions instead. */
extern void set_cfun (struct function *new_cfun);
extern void set_cfun (struct function *new_cfun, bool force = false);
extern void push_cfun (struct function *new_cfun);
extern void pop_cfun (void);

View File

@ -340,6 +340,8 @@ inline_call (struct cgraph_edge *e, bool update_original,
if (DECL_FUNCTION_PERSONALITY (callee->decl))
DECL_FUNCTION_PERSONALITY (to->decl)
= DECL_FUNCTION_PERSONALITY (callee->decl);
bool reload_optimization_node = false;
if (!opt_for_fn (callee->decl, flag_strict_aliasing)
&& opt_for_fn (to->decl, flag_strict_aliasing))
{
@ -352,6 +354,7 @@ inline_call (struct cgraph_edge *e, bool update_original,
to->name (), to->order);
DECL_FUNCTION_SPECIFIC_OPTIMIZATION (to->decl)
= build_optimization_node (&opts);
reload_optimization_node = true;
}
inline_summary *caller_info = inline_summaries->get (to);
@ -412,9 +415,14 @@ inline_call (struct cgraph_edge *e, bool update_original,
callee->name (), callee->order, to->name (), to->order);
DECL_FUNCTION_SPECIFIC_OPTIMIZATION (to->decl)
= build_optimization_node (&opts);
reload_optimization_node = true;
}
}
/* Reload global optimization flags. */
if (reload_optimization_node && DECL_STRUCT_FUNCTION (to->decl) == cfun)
set_cfun (cfun, true);
/* If aliases are involved, redirect edge to the actual destination and
possibly remove the aliases. */
if (e->callee != callee)

View File

@ -1,3 +1,8 @@
2017-01-13 Martin Liska <mliska@suse.cz>
PR ipa/79043
* gcc.c-torture/execute/pr79043.c: New test.
2017-01-13 Richard Biener <rguenther@suse.de>
PR middle-end/78411

View File

@ -0,0 +1,21 @@
/* PR ipa/78791 */
int val;
int *ptr = &val;
float *ptr2 = &val;
static
__attribute__((always_inline, optimize ("-fno-strict-aliasing")))
typepun ()
{
*ptr2=0;
}
main()
{
*ptr=1;
typepun ();
if (*ptr)
__builtin_abort ();
}