This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [IFUNC}: Properly handle indirect function return


On Mon, Jul 6, 2009 at 12:41 PM, Andrew Pinski<pinskia@gmail.com> wrote:
> On Mon, Jul 6, 2009 at 12:36 PM, H.J. Lu<hongjiu.lu@intel.com> wrote:
>> Hi,
>> + ? ?case GIMPLE_RETURN:
>> + ? ? ?if (DECL_IS_IFUNC (current_function_decl))
>> + ? ? ? {
>> + ? ? ? ? if (dump_file)
>> + ? ? ? ? ? fprintf (dump_file, " ? ?Indirect function is not const/pure");
>> + ? ? ? ? local->pure_const_state = IPA_NEITHER;
>> + ? ? ? }
>> + ? ? ?break;
>
> This seems like the incorrect place to put this check as it does not
> depend on the return statement. ?It seems like it is better if it is
> put analyze_function and then skip the walk of the IR.
>

I checked in this patch to do this.

Thanks.


H.J.
---
Index: ipa-pure-const.c
===================================================================
--- ipa-pure-const.c	(revision 149294)
+++ ipa-pure-const.c	(working copy)
@@ -471,14 +471,6 @@ check_stmt (gimple_stmt_iterator *gsip,
           local->looping = true;
 	}
       return;
-    case GIMPLE_RETURN:
-      if (DECL_IS_IFUNC (current_function_decl))
-	{
-	  if (dump_file)
-	    fprintf (dump_file, "    Indirect function is not const/pure");
-	  local->pure_const_state = IPA_NEITHER;
-	}
-      break;
     default:
       break;
     }
@@ -492,7 +484,7 @@ static funct_state
 analyze_function (struct cgraph_node *fn, bool ipa)
 {
   tree decl = fn->decl;
-  tree old_decl = current_function_decl;
+  tree old_decl;
   funct_state l;
   basic_block this_block;

@@ -504,11 +496,17 @@ analyze_function (struct cgraph_node *fn
     }

   l = XCNEW (struct funct_state_d);
-  l->pure_const_state = IPA_CONST;
   l->state_previously_known = IPA_NEITHER;
   l->looping_previously_known = true;
   l->looping = false;
   l->can_throw = false;
+  if (DECL_IS_IFUNC (decl))
+    {
+      l->pure_const_state = IPA_NEITHER;
+      goto skip;
+    }
+  else
+    l->pure_const_state = IPA_CONST;

   if (dump_file)
     {
@@ -516,6 +514,7 @@ analyze_function (struct cgraph_node *fn
 	       cgraph_node_name (fn));
     }

+  old_decl = current_function_decl;
   push_cfun (DECL_STRUCT_FUNCTION (decl));
   current_function_decl = decl;

@@ -595,6 +594,8 @@ end:

   pop_cfun ();
   current_function_decl = old_decl;
+
+skip:
   if (dump_file)
     {
       if (l->looping)
Index: ChangeLog.ifunc
===================================================================
--- ChangeLog.ifunc	(revision 149294)
+++ ChangeLog.ifunc	(working copy)
@@ -1,5 +1,10 @@
 2009-07-06  H.J. Lu  <hongjiu.lu@intel.com>

+	* ipa-pure-const.c (check_stmt): Revert the last change.
+	(analyze_function):  Skip analysis for indirect function.
+
+2009-07-06  H.J. Lu  <hongjiu.lu@intel.com>
+
 	* ipa-pure-const.c (check_stmt): Properly handle indirect function
 	return.



-- 
H.J.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]