Commit f22712bd by Jan Hubicka

Fix inliner ICE on alias with flatten attribute [PR92372]

gcc/ChangeLog:

2020-03-19  Jan Hubicka  <hubicka@ucw.cz>

	PR ipa/92372
	* cgraphunit.c (process_function_and_variable_attributes): warn
	for flatten attribute on alias.
	* ipa-inline.c (ipa_inline): Do not ICE on flatten attribute on alias.

gcc/testsuite/ChangeLog:

2020-03-19  Jan Hubicka  <hubicka@ucw.cz>

	PR ipa/92372
	* gcc.c-torture/pr92372.c: New test.
	* gcc.dg/attr-flatten-1.c: New test.
parent c8429c2a
2020-03-19 Jan Hubicka <hubicka@ucw.cz>
PR ipa/92372
* cgraphunit.c (process_function_and_variable_attributes): warn
for flatten attribute on alias.
* ipa-inline.c (ipa_inline): Do not ICE on flatten attribute on alias.
2020-03-19 Martin Liska <mliska@suse.cz> 2020-03-19 Martin Liska <mliska@suse.cz>
* lto-section-in.c: Add ext_symtab. * lto-section-in.c: Add ext_symtab.
......
...@@ -851,6 +851,14 @@ process_function_and_variable_attributes (cgraph_node *first, ...@@ -851,6 +851,14 @@ process_function_and_variable_attributes (cgraph_node *first,
node = symtab->next_function (node)) node = symtab->next_function (node))
{ {
tree decl = node->decl; tree decl = node->decl;
if (node->alias
&& lookup_attribute ("flatten", DECL_ATTRIBUTES (decl)))
{
warning_at (DECL_SOURCE_LOCATION (node->decl), OPT_Wattributes,
"%<flatten%>"
" attribute attribute is ignored on aliases");
}
if (DECL_PRESERVE_P (decl)) if (DECL_PRESERVE_P (decl))
node->mark_force_output (); node->mark_force_output ();
else if (lookup_attribute ("externally_visible", DECL_ATTRIBUTES (decl))) else if (lookup_attribute ("externally_visible", DECL_ATTRIBUTES (decl)))
......
...@@ -2634,6 +2634,9 @@ ipa_inline (void) ...@@ -2634,6 +2634,9 @@ ipa_inline (void)
{ {
node = order[i]; node = order[i];
if (node->definition if (node->definition
/* Do not try to flatten aliases. These may happen for example when
creating local aliases. */
&& !node->alias
&& lookup_attribute ("flatten", && lookup_attribute ("flatten",
DECL_ATTRIBUTES (node->decl)) != NULL) DECL_ATTRIBUTES (node->decl)) != NULL)
order[j--] = order[i]; order[j--] = order[i];
......
2020-03-19 Jan Hubicka <hubicka@ucw.cz>
PR ipa/92372
* gcc.c-torture/pr92372.c: New test.
* gcc.dg/attr-flatten-1.c: New test.
2020-03-19 Jakub Jelinek <jakub@redhat.com> 2020-03-19 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/94211 PR tree-optimization/94211
......
int fn2(int);
int fn3(int);
__attribute__((flatten))
int fn1(int p1)
{
int a = fn2(p1);
return fn3(a);
}
__attribute__((flatten))
int fn4(int p1)
{
int j = fn2(p1);
return fn3(j);
}
/* { dg-require-alias "" } */
int fn2(int);
int fn3(int);
__attribute__((flatten))
int fn1(int p1)
{
int a = fn2(p1);
return fn3(a);
}
__attribute__((flatten))
__attribute__((alias("fn1")))
int fn4(int p1); /* { dg-warning "ignored" } */
int
test ()
{
return fn4(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