[Bug target/77587] [5/6/7 Regression] C compiler produces incorrect stack alignment with __attribute__((weak))
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Sep 15 11:20:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77587
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
From what I can see, this happens because expand_call does:
2736 if (fndecl)
2737 {
2738 struct cgraph_rtl_info *i = cgraph_node::rtl_info (fndecl);
2739 /* Without automatic stack alignment, we can't increase preferred
2740 stack boundary. With automatic stack alignment, it is
2741 unnecessary since unless we can guarantee that all callers
will
2742 align the outgoing stack properly, callee has to align its
2743 stack anyway. */
2744 if (i
2745 && i->preferred_incoming_stack_boundary
2746 && i->preferred_incoming_stack_boundary <
preferred_stack_boundary)
2747 preferred_stack_boundary =
i->preferred_incoming_stack_boundary;
and
1951 cgraph_rtl_info *
1952 cgraph_node::rtl_info (tree decl)
1953 {
1954 gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
1955 cgraph_node *node = get (decl);
1956 if (!node)
1957 return NULL;
1958 node = node->ultimate_alias_target ();
1959 if (node->decl != current_function_decl
1960 && !TREE_ASM_WRITTEN (node->decl))
1961 return NULL;
1962 /* Allocate if it doesnt exist. */
1963 if (node->ultimate_alias_target ()->rtl == NULL)
1964 node->ultimate_alias_target ()->rtl =
ggc_cleared_alloc<cgraph_rtl_info> ();
1965 return node->ultimate_alias_target ()->rtl;
First of all, it is confusing, because it calls ultimate_alias_target up to 3
times, wouldn't one call be enough?
And the second issue is that ultimate_alias_target and its helpers return foo's
node even when the alias is a weak alias (global) to a local routine, which
could (and is in this case) be overridden with something different at link
time.
Honza, shall ultimate_alias_target ignore such aliases, something else?
More information about the Gcc-bugs
mailing list