Commit aaae719d by Jan Hubicka Committed by Jan Hubicka

attr-alias.c: New testcase.

	* gcc.dg/tree-ssa/attr-alias.c: New testcase.

	* ipa-inline.c (update_caller_keys): Fix availability test.
	(update_callee_keys): Likewise.
	* symtab.c (symtab_alias_ultimate_target): Make availaiblity logic
	to follow ELF standard.

From-SVN: r199670
parent 107eea2c
2013-06-04 Jan Hubicka <jh@suse.cz>
* ipa-inline.c (update_caller_keys): Fix availability test.
(update_callee_keys): Likewise.
* symtab.c (symtab_alias_ultimate_target): Make availaiblity logic
to follow ELF standard.
2013-06-04 Jürgen Urban <JuergenUrban@gmx.de> 2013-06-04 Jürgen Urban <JuergenUrban@gmx.de>
* config.gcc (mipsr5900-*-elf*, mipsr5900el-*-elf*, mips64r5900-*-elf*) * config.gcc (mipsr5900-*-elf*, mipsr5900el-*-elf*, mips64r5900-*-elf*)
......
...@@ -1101,7 +1101,6 @@ update_caller_keys (fibheap_t heap, struct cgraph_node *node, ...@@ -1101,7 +1101,6 @@ update_caller_keys (fibheap_t heap, struct cgraph_node *node,
struct ipa_ref *ref; struct ipa_ref *ref;
if ((!node->symbol.alias && !inline_summary (node)->inlinable) if ((!node->symbol.alias && !inline_summary (node)->inlinable)
|| cgraph_function_body_availability (node) <= AVAIL_OVERWRITABLE
|| node->global.inlined_to) || node->global.inlined_to)
return; return;
if (!bitmap_set_bit (updated_nodes, node->uid)) if (!bitmap_set_bit (updated_nodes, node->uid))
...@@ -1162,7 +1161,7 @@ update_callee_keys (fibheap_t heap, struct cgraph_node *node, ...@@ -1162,7 +1161,7 @@ update_callee_keys (fibheap_t heap, struct cgraph_node *node,
if (e->inline_failed if (e->inline_failed
&& (callee = cgraph_function_or_thunk_node (e->callee, &avail)) && (callee = cgraph_function_or_thunk_node (e->callee, &avail))
&& inline_summary (callee)->inlinable && inline_summary (callee)->inlinable
&& cgraph_function_body_availability (callee) >= AVAIL_AVAILABLE && avail >= AVAIL_AVAILABLE
&& !bitmap_bit_p (updated_nodes, callee->uid)) && !bitmap_bit_p (updated_nodes, callee->uid))
{ {
if (can_inline_edge_p (e, false) if (can_inline_edge_p (e, false)
......
...@@ -834,19 +834,64 @@ symtab_node_availability (symtab_node node) ...@@ -834,19 +834,64 @@ symtab_node_availability (symtab_node node)
symtab_node symtab_node
symtab_alias_ultimate_target (symtab_node node, enum availability *availability) symtab_alias_ultimate_target (symtab_node node, enum availability *availability)
{ {
bool weakref_p = false;
if (!node->symbol.alias)
{
if (availability)
*availability = symtab_node_availability (node);
return node;
}
/* To determine visibility of the target, we follow ELF semantic of aliases.
Here alias is an alternative assembler name of a given definition. Its
availablity prevails the availablity of its target (i.e. static alias of
weak definition is available.
Weakref is a different animal (and not part of ELF per se). It is just
alternative name of a given symbol used within one complation unit
and is translated prior hitting the object file. It inherits the
visibility of its target (i.e. weakref of non-overwritable definition
is non-overwritable, while weakref of weak definition is weak).
If we ever get into supporting targets with different semantics, a target
hook will be needed here. */
if (availability) if (availability)
*availability = symtab_node_availability (node); {
weakref_p = DECL_EXTERNAL (node->symbol.decl) && node->symbol.alias;
if (!weakref_p)
*availability = symtab_node_availability (node);
else
*availability = AVAIL_LOCAL;
}
while (node) while (node)
{ {
if (node->symbol.alias && node->symbol.analyzed) if (node->symbol.alias && node->symbol.analyzed)
node = symtab_alias_target (node); node = symtab_alias_target (node);
else else
return node; {
if (node && availability) if (!availability)
;
else if (node->symbol.analyzed)
{
if (weakref_p)
{
enum availability a = symtab_node_availability (node);
if (a < *availability)
*availability = a;
}
}
else
*availability = AVAIL_NOT_AVAILABLE;
return node;
}
if (node && availability && weakref_p)
{ {
enum availability a = symtab_node_availability (node); enum availability a = symtab_node_availability (node);
if (a < *availability) if (a < *availability)
*availability = a; *availability = a;
weakref_p = DECL_EXTERNAL (node->symbol.decl) && node->symbol.alias;
} }
} }
if (availability) if (availability)
......
2013-06-04 Jan Hubicka <jh@suse.cz>
* gcc.dg/tree-ssa/attr-alias.c: New testcase.
2013-06-04 Balaji V. Iyer <balaji.v.iyer@intel.com> 2013-06-04 Balaji V. Iyer <balaji.v.iyer@intel.com>
* c-c++-common/cilk-plus/AN/array_test1.c (main): Replaced argc, argv * c-c++-common/cilk-plus/AN/array_test1.c (main): Replaced argc, argv
......
/* { dg-do compile } */
/* { dg-require-alias "" } */
/* { dg-options "-O2 -fdump-tree-optimized" } */
void abort (void);
__attribute__ ((weak))
int test()
{
return 0;
}
static int test2() __attribute__ ((alias("test")));
static int test3() __attribute__ ((weakref)) __attribute__ ((alias("test2")));
static int test4() __attribute__ ((weakref)) __attribute__ ((alias("test")));
main()
{
test();
test2();
test3();
test4();
}
/* calls to test1 and test2 can be inlined and optmized away. Calls
to test and test4 are overwritable. */
/* { dg-final { scan-tree-dump-times "test (" 2 "optimized" } } */
/* { dg-final { scan-tree-dump-times "test4 (" 1 "optimized" } } */
/* { dg-final { scan-tree-dump-not "test1 (" "optimized" } } */
/* { dg-final { scan-tree-dump-not "test2 (" "optimized" } } */
/* { dg-final { cleanup-tree-dump "optimized" } } */
/* { dg-do compile } */
/* { dg-require-alias "" } */
/* { dg-options "-O2 -fdump-tree-optimized" } */
void abort (void);
__attribute__ ((weak))
int test()
{
return 0;
}
static int test2() __attribute__ ((alias("test")));
static int test3() __attribute__ ((weakref)) __attribute__ ((alias("test2")));
static int test4() __attribute__ ((weakref)) __attribute__ ((alias("test")));
main()
{
test();
test2();
test3();
test4();
}
/* calls to test1 and test2 can be inlined and optmized away. Calls
to test and test4 are overwritable. */
/* { dg-final { scan-tree-dump-times "test (" 2 "optimized" } } */
/* { dg-final { scan-tree-dump-times "test4 (" 1 "optimized" } } */
/* { dg-final { scan-tree-dump-not "test1 (" "optimized" } } */
/* { dg-final { scan-tree-dump-not "test2 (" "optimized" } } */
/* { dg-final { cleanup-tree-dump "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