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: PR middle-end/40080


On Sat, May 9, 2009 at 1:11 PM, Jan Hubicka <hubicka@ucw.cz> wrote:
> Hi,
> middle-end/40080 shows side case where ipa-cp clone is created and it is
> fully inlined, one of the callees gets indirect call converted into
> direct call that eventually results in clone materialization to redirect
> the call incorrectly.
>
> Bootstrapped/regtested x86_64-linux and commited.
>
> Index: ChangeLog
> ===================================================================
> --- ChangeLog ? (revision 147319)
> +++ ChangeLog ? (working copy)
> @@ -1,5 +1,11 @@
> ?2009-05-09 ?Jan Hubicka ?<jh@suse.cz>
>
> + ? ? ? PR middle-end/40080
> + ? ? ? * cgraphunit.c (cgraph_materialize_all_clones): Do not redirect
> + ? ? ? indirect calls; verify cgraph afterwards.
> +
> +2009-05-09 ?Jan Hubicka ?<jh@suse.cz>
> +
> ? ? ? ?PR bootstrap/40082
> ? ? ? ?* ipa.c (update_inlined_to_pointer): New function.
> ? ? ? ?(cgraph_remove_unreachable_nodes): Use it.
> Index: cgraphunit.c
> ===================================================================
> --- cgraphunit.c ? ? ? ?(revision 147319)
> +++ cgraphunit.c ? ? ? ?(working copy)
> @@ -1762,7 +1762,12 @@ cgraph_materialize_all_clones (void)
> ? ? ? ?for (e = node->callees; e; e = e->next_callee)
> ? ? ? ? ?{
> ? ? ? ? ? ?tree decl = gimple_call_fndecl (e->call_stmt);
> - ? ? ? ? ? if (decl != e->callee->decl)
> + ? ? ? ? ? /* When function gets inlined, indirect inlining might've invented
> + ? ? ? ? ? ? ?new edge for orginally indirect stmt. ?Since we are not
> + ? ? ? ? ? ? ?preserving clones in the original form, we must not update here
> + ? ? ? ? ? ? ?since other inline clones don't need to contain call to the same
> + ? ? ? ? ? ? ?call. ?Inliner will do the substitution for us later. ?*/
> + ? ? ? ? ? if (decl && decl != e->callee->decl)
> ? ? ? ? ? ? ?{
> ? ? ? ? ? ? ? ?gimple new_stmt;
> ? ? ? ? ? ? ? ?gimple_stmt_iterator gsi;
> @@ -1808,6 +1813,9 @@ cgraph_materialize_all_clones (void)
> ? ? ? ? verify_cgraph_node (node);
> ?#endif
> ? ? ? }
> +#ifdef ENABLE_CHECKING
> + ?verify_cgraph ();
> +#endif
> ? cgraph_remove_unreachable_nodes (false, cgraph_dump_file);
> ?}
>
>

I checked in this patch to add an testcase.

-- 
H.J.
--
Index: gcc.c-torture/compile/pr40080.c
===================================================================
--- gcc.c-torture/compile/pr40080.c	(revision 0)
+++ gcc.c-torture/compile/pr40080.c	(revision 0)
@@ -0,0 +1,44 @@
+extern void *ff(void*,int);
+
+struct lpgl { struct lpgl *next; };
+struct lpgd { struct lpgl *first; };
+
+typedef int (*xfn)( );
+static void xDP_IF_EnumGroupsInGroup ( void *a, int b, xfn fn)
+{
+  struct lpgd *lpGData;
+  struct lpgl *lpGList;
+
+  if( ( lpGData = ff( a, b ) ) == ((void *)0) )
+    return;
+
+  if( lpGData->first  == ((void *)0) )
+    return;
+  lpGList = lpGData->first;
+
+  for( ;; ) {
+    if( !(*fn)( ) )
+      return;
+    if( lpGList->next == ((void *)0) )
+      break;
+    lpGList = lpGList->next;
+  }
+  return;
+}
+
+
+static int
+xcbDeletePlayerFromAllGroups() {
+  xDP_IF_EnumGroupsInGroup(0, 0, 0);
+  return 1;
+}
+
+void xDP_IF_EnumGroups( xfn fn) {
+  xDP_IF_EnumGroupsInGroup( 0, 0, fn);
+}
+
+static void xDP_IF_DestroyPlayer () {
+  xDP_IF_EnumGroups( xcbDeletePlayerFromAllGroups);
+}
+
+void* foo=xDP_IF_DestroyPlayer;
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 147386)
+++ ChangeLog	(working copy)
@@ -1,3 +1,8 @@
+2009-05-11  H.J. Lu  <hongjiu.lu@intel.com>
+
+	PR middle-end/40080
+	* gcc.c-torture/compile/pr40080.c: New.
+
 2009-05-11  Paolo Bonzini  <bonzini@gnu.org>

 	* gcc.c-torture/compile/pr40026.c: New testcase.


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