]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Backport r246530
authorMartin Liska <mliska@suse.cz>
Mon, 29 May 2017 09:08:48 +0000 (11:08 +0200)
committerMartin Liska <marxin@gcc.gnu.org>
Mon, 29 May 2017 09:08:48 +0000 (09:08 +0000)
2017-05-29  Martin Liska  <mliska@suse.cz>

Backport from mainline
2017-03-28  Richard Biener  <rguenther@suse.de>

PR ipa/80205
* tree-inline.c (copy_phis_for_bb): Do not create PHI node
without arguments, generate default definition of a SSA name.
2017-05-29  Martin Liska  <mliska@suse.cz>

Backport from mainline
2017-03-28  Martin Liska  <mliska@suse.cz>

PR ipa/80205
* g++.dg/ipa/pr80205.C: New test.

From-SVN: r248559

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ipa/pr80205.C [new file with mode: 0644]
gcc/tree-inline.c

index 19748ee377411e8ca036cdd0bb8b979f97167538..3dd0d560a74fa6475ea4c925490bf8536c2fb97d 100644 (file)
@@ -1,3 +1,12 @@
+2017-05-29  Martin Liska  <mliska@suse.cz>
+
+       Backport from mainline
+       2017-03-28  Richard Biener  <rguenther@suse.de>
+
+       PR ipa/80205
+       * tree-inline.c (copy_phis_for_bb): Do not create PHI node
+       without arguments, generate default definition of a SSA name.
+
 2017-05-29  Martin Liska  <mliska@suse.cz>
 
        Backport from mainline
index bec6fec204aae1e275af23d611516233ecfa37d4..28d6920aae9c56533ceef813e4ca7c9856a6b99e 100644 (file)
@@ -1,3 +1,11 @@
+2017-05-29  Martin Liska  <mliska@suse.cz>
+
+       Backport from mainline
+       2017-03-28  Martin Liska  <mliska@suse.cz>
+
+       PR ipa/80205
+       * g++.dg/ipa/pr80205.C: New test.
+
 2017-05-29  Martin Liska  <mliska@suse.cz>
 
        Backport from mainline
diff --git a/gcc/testsuite/g++.dg/ipa/pr80205.C b/gcc/testsuite/g++.dg/ipa/pr80205.C
new file mode 100644 (file)
index 0000000..460bdcb
--- /dev/null
@@ -0,0 +1,34 @@
+// PR ipa/80205
+// { dg-options "-fnon-call-exceptions --param early-inlining-insns=100 -O2" }
+
+class a
+{
+public:
+  virtual ~a ();
+};
+class b
+{
+public:
+  template <typename c> b (c);
+  ~b () { delete d; }
+  void
+  operator= (b e)
+  {
+    b (e).f (*this);
+  }
+  void
+  f (b &e)
+  {
+    a g;
+    d = e.d;
+    e.d = &g;
+  }
+  a *d;
+};
+void
+h ()
+{
+  b i = int();
+  void j ();
+  i = j;
+}
index e8c066015f5fe44b13d9a83e1e9514d72402cac8..60f79336cd7edd8ff946007e986366ba5dced749 100644 (file)
@@ -2347,53 +2347,59 @@ copy_phis_for_bb (basic_block bb, copy_body_data *id)
        {
          walk_tree (&new_res, copy_tree_body_r, id, NULL);
          new_phi = create_phi_node (new_res, new_bb);
-         FOR_EACH_EDGE (new_edge, ei, new_bb->preds)
+         if (EDGE_COUNT (new_bb->preds) == 0)
            {
-             edge old_edge = find_edge ((basic_block) new_edge->src->aux, bb);
-             tree arg;
-             tree new_arg;
-             edge_iterator ei2;
-             location_t locus;
-
-             /* When doing partial cloning, we allow PHIs on the entry block
-                as long as all the arguments are the same.  Find any input
-                edge to see argument to copy.  */
-             if (!old_edge)
-               FOR_EACH_EDGE (old_edge, ei2, bb->preds)
-                 if (!old_edge->src->aux)
-                   break;
+             /* Technically we'd want a SSA_DEFAULT_DEF here... */
+             SSA_NAME_DEF_STMT (new_res) = gimple_build_nop ();
+           }
+         else
+           FOR_EACH_EDGE (new_edge, ei, new_bb->preds)
+             {
+               edge old_edge = find_edge ((basic_block) new_edge->src->aux, bb);
+               tree arg;
+               tree new_arg;
+               edge_iterator ei2;
+               location_t locus;
+
+               /* When doing partial cloning, we allow PHIs on the entry block
+                  as long as all the arguments are the same.  Find any input
+                  edge to see argument to copy.  */
+               if (!old_edge)
+                 FOR_EACH_EDGE (old_edge, ei2, bb->preds)
+                   if (!old_edge->src->aux)
+                     break;
 
-             arg = PHI_ARG_DEF_FROM_EDGE (phi, old_edge);
-             new_arg = arg;
-             walk_tree (&new_arg, copy_tree_body_r, id, NULL);
-             gcc_assert (new_arg);
-             /* With return slot optimization we can end up with
-                non-gimple (foo *)&this->m, fix that here.  */
-             if (TREE_CODE (new_arg) != SSA_NAME
-                 && TREE_CODE (new_arg) != FUNCTION_DECL
-                 && !is_gimple_val (new_arg))
-               {
-                 gimple_seq stmts = NULL;
-                 new_arg = force_gimple_operand (new_arg, &stmts, true, NULL);
-                 gsi_insert_seq_on_edge (new_edge, stmts);
-                 inserted = true;
-               }
-             locus = gimple_phi_arg_location_from_edge (phi, old_edge);
-             if (LOCATION_BLOCK (locus))
-               {
-                 tree *n;
-                 n = id->decl_map->get (LOCATION_BLOCK (locus));
-                 gcc_assert (n);
-                 if (*n)
-                   locus = COMBINE_LOCATION_DATA (line_table, locus, *n);
-                 else
-                   locus = LOCATION_LOCUS (locus);
-               }
-             else
-               locus = LOCATION_LOCUS (locus);
+               arg = PHI_ARG_DEF_FROM_EDGE (phi, old_edge);
+               new_arg = arg;
+               walk_tree (&new_arg, copy_tree_body_r, id, NULL);
+               gcc_assert (new_arg);
+               /* With return slot optimization we can end up with
+                  non-gimple (foo *)&this->m, fix that here.  */
+               if (TREE_CODE (new_arg) != SSA_NAME
+                   && TREE_CODE (new_arg) != FUNCTION_DECL
+                   && !is_gimple_val (new_arg))
+                 {
+                   gimple_seq stmts = NULL;
+                   new_arg = force_gimple_operand (new_arg, &stmts, true, NULL);
+                   gsi_insert_seq_on_edge (new_edge, stmts);
+                   inserted = true;
+                 }
+               locus = gimple_phi_arg_location_from_edge (phi, old_edge);
+               if (LOCATION_BLOCK (locus))
+                 {
+                   tree *n;
+                   n = id->decl_map->get (LOCATION_BLOCK (locus));
+                   gcc_assert (n);
+                   if (*n)
+                     locus = COMBINE_LOCATION_DATA (line_table, locus, *n);
+                   else
+                     locus = LOCATION_LOCUS (locus);
+                 }
+                else
+                  locus = LOCATION_LOCUS (locus);
 
-             add_phi_arg (new_phi, new_arg, new_edge, locus);
-           }
+               add_phi_arg (new_phi, new_arg, new_edge, locus);
+             }
        }
     }