]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
cgraph.c (cgraph_redirect_edge_call_stmt_to_callee): Clear static chain if needed.
authorJan Hubicka <hubicka@gcc.gnu.org>
Fri, 28 Mar 2014 22:19:27 +0000 (22:19 +0000)
committerJan Hubicka <hubicka@gcc.gnu.org>
Fri, 28 Mar 2014 22:19:27 +0000 (22:19 +0000)
* cgraph.c (cgraph_redirect_edge_call_stmt_to_callee): Clear
static chain if needed.
* g++.dg/torture/pr60659.C: New testcase.

From-SVN: r208927

gcc/ChangeLog
gcc/cgraph.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/opt33.adb [new file with mode: 0644]

index d68adcf338e4a4b6ccf04a16f9cd1bb29baf264f..ded35eb7e72ccdc14ea591c7e859ece18671e61a 100644 (file)
@@ -1,3 +1,8 @@
+2014-03-28  Jan Hubicka  <hubicka@ucw.cz>
+
+       * cgraph.c (cgraph_redirect_edge_call_stmt_to_callee): Clear
+       static chain if needed.
+
 2014-03-28  Vladimir Makarov  <vmakarov@redhat.com>
 
        PR target/60697
index 3b76aa4d470372a023fdee9596f6658abe65568d..dcab9848307e4db4de1f39d21af9610dd042db46 100644 (file)
@@ -1488,6 +1488,14 @@ cgraph_redirect_edge_call_stmt_to_callee (struct cgraph_edge *e)
          gsi_insert_before (&gsi, set_stmt, GSI_SAME_STMT);
        }
       gimple_call_set_lhs (new_stmt, NULL_TREE);
+      update_stmt_fn (DECL_STRUCT_FUNCTION (e->caller->decl), new_stmt);
+    }
+
+  /* If new callee has no static chain, remove it.  */
+  if (gimple_call_chain (new_stmt) && !DECL_STATIC_CHAIN (e->callee->decl))
+    {
+      gimple_call_set_chain (new_stmt, NULL);
+      update_stmt_fn (DECL_STRUCT_FUNCTION (e->caller->decl), new_stmt);
     }
 
   cgraph_set_call_stmt_including_clones (e->caller, e->call_stmt, new_stmt, false);
index fa427966cf8a168cf9e6cc22ff47631b6e89ea9f..63a43c2c3adb22ba5a68e5d9607ffcf6cf420919 100644 (file)
@@ -1,3 +1,7 @@
+2014-03-28  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/opt33.adb: New testcase.
+
 2014-03-28  Vladimir Makarov  <vmakarov@redhat.com>
 
        PR target/60697
diff --git a/gcc/testsuite/gnat.dg/opt33.adb b/gcc/testsuite/gnat.dg/opt33.adb
new file mode 100644 (file)
index 0000000..e1ac27c
--- /dev/null
@@ -0,0 +1,41 @@
+-- { dg-do compile }
+-- { dg-options "-O" }
+
+with Ada.Containers.Ordered_Sets;
+with Ada.Strings.Unbounded;
+
+procedure Opt33 is
+
+   type Rec is record
+      Name : Ada.Strings.Unbounded.Unbounded_String;
+   end record;
+
+   function "<" (Left : Rec; Right : Rec) return Boolean;
+
+   package My_Ordered_Sets is new Ada.Containers.Ordered_Sets (Rec);
+
+   protected type Data is
+      procedure Do_It;
+   private
+      Set : My_Ordered_Sets.Set;
+   end Data;
+
+   function "<" (Left : Rec; Right : Rec) return Boolean is
+   begin
+      return False;
+   end "<";
+
+   protected body Data is
+      procedure Do_It is
+         procedure Dummy (Position : My_Ordered_Sets.Cursor) is
+         begin
+            null;
+         end;
+      begin
+         Set.Iterate (Dummy'Access);
+      end;
+   end Data;
+
+begin
+   null;
+end;