diff mbox

[AARCH64] Enable fuse-caller-save for AARCH64

Message ID 53A2A1B7.1060209@mentor.com
State New
Headers show

Commit Message

Tom de Vries June 19, 2014, 8:39 a.m. UTC
On 19-06-14 05:53, Richard Henderson wrote:
> Do we in fact make sure this isn't an ifunc resolver?  I don't immediately see
> how those get wired up in the cgraph...

Richard,

using the patch below I changed the 
gcc/testsuite/gcc.target/i386/fuse-caller-save.c testcase to use an ifunc 
resolver, and observed that the fuse-caller-save optimization didn't work.

The reason the optimization doesn't work in this case is that 
default_binds_local_p_1 checks the ifunc attribute:
...
   /* Weakrefs may not bind locally, even though the weakref itself is always
      static and therefore local.  Similarly, the resolver for ifunc functions
      might resolve to a non-local function.
      FIXME: We can resolve the weakref case more curefuly by looking at the
      weakref alias.  */
   else if (lookup_attribute ("weakref", DECL_ATTRIBUTES (exp))
	   || (TREE_CODE (exp) == FUNCTION_DECL
	       && lookup_attribute ("ifunc", DECL_ATTRIBUTES (exp))))
     local_p = false;
...

The default_binds_local_p_1 function is used via this path in the optimization:
get_call_reg_set_usage -> get_call_cgraph_rtl_info -> 
decl_binds_to_current_def_p -> default_binds_local_p -> default_binds_local_p_1 .

Thanks,
- Tom

Comments

Richard Henderson June 19, 2014, 3:44 p.m. UTC | #1
On 06/19/2014 01:39 AM, Tom de Vries wrote:
> On 19-06-14 05:53, Richard Henderson wrote:
>> Do we in fact make sure this isn't an ifunc resolver?  I don't immediately see
>> how those get wired up in the cgraph...
> 
> Richard,
> 
> using the patch below I changed the
> gcc/testsuite/gcc.target/i386/fuse-caller-save.c testcase to use an ifunc
> resolver, and observed that the fuse-caller-save optimization didn't work.
> 
> The reason the optimization doesn't work in this case is that
> default_binds_local_p_1 checks the ifunc attribute:
> ...
>   /* Weakrefs may not bind locally, even though the weakref itself is always
>      static and therefore local.  Similarly, the resolver for ifunc functions
>      might resolve to a non-local function.
>      FIXME: We can resolve the weakref case more curefuly by looking at the
>      weakref alias.  */
>   else if (lookup_attribute ("weakref", DECL_ATTRIBUTES (exp))
>        || (TREE_CODE (exp) == FUNCTION_DECL
>            && lookup_attribute ("ifunc", DECL_ATTRIBUTES (exp))))
>     local_p = false;
> ...
> 
> The default_binds_local_p_1 function is used via this path in the optimization:
> get_call_reg_set_usage -> get_call_cgraph_rtl_info ->
> decl_binds_to_current_def_p -> default_binds_local_p -> default_binds_local_p_1 .

Excellent.  Thanks for doing the digging I was too lazy to finish last night.


r~
diff mbox

Patch

diff --git a/gcc/testsuite/gcc.target/i386/fuse-caller-save.c b/gcc/testsuite/gcc.target/i386/fuse-caller-save.c
index 4ec4995..012dc12 100644
--- a/gcc/testsuite/gcc.target/i386/fuse-caller-save.c
+++ b/gcc/testsuite/gcc.target/i386/fuse-caller-save.c
@@ -5,11 +5,18 @@ 
 /* Testing -fuse-caller-save optimization option.  */
 
 static int __attribute__((noinline))
-bar (int x)
+my_bar (int x)
 {
   return x + 3;
 }
 
+static void (*resolve_bar (void)) (void)
+{
+  return (void*) my_bar;
+}
+
+static int __attribute__((noinline)) __attribute__((ifunc ("resolve_bar"))) bar (int x);
+
 int __attribute__((noinline))
 foo (int y)
 {
-- 
1.9.1