OSDN Git Service

2011-01-17 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 17 Jan 2011 14:48:35 +0000 (14:48 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 17 Jan 2011 14:48:35 +0000 (14:48 +0000)
PR tree-optimization/47313
* tree-inline.c (tree_function_versioning): Move DECL_RESULT
handling before copying the body.  Properly deal with
by-reference result in SSA form.

* g++.dg/torture/pr47313.C: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@168907 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 8b269ef..b5c8fa1 100644 (file)
@@ -1,3 +1,10 @@
+2011-01-17  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/47313
+       * tree-inline.c (tree_function_versioning): Move DECL_RESULT
+       handling before copying the body.  Properly deal with
+       by-reference result in SSA form.
+
 2011-01-17  Ian Lance Taylor  <iant@google.com>
 
        PR target/47219
index 8db0111..2ab6f53 100644 (file)
@@ -1,3 +1,8 @@
+2011-01-17  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/47313
+       * g++.dg/torture/pr47313.C: New testcase.
+
 2011-01-17  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR target/47318
diff --git a/gcc/testsuite/g++.dg/torture/pr47313.C b/gcc/testsuite/g++.dg/torture/pr47313.C
new file mode 100644 (file)
index 0000000..c10f558
--- /dev/null
@@ -0,0 +1,53 @@
+// { dg-do compile }
+
+namespace internal {
+    template < class DSC, bool Const >   struct CC_iterator   {
+       typedef CC_iterator iterator;
+       typedef typename DSC::value_type value_type;
+       typedef const value_type* pointer;
+       CC_iterator ()     ;
+       CC_iterator (const iterator &it)     {
+       }
+       pointer p;
+       pointer operator->() const ;
+    };
+}
+template < class T > struct Compact_container {
+    typedef Compact_container <T> Self;
+    typedef T value_type;
+    typedef internal::CC_iterator<Self, false> iterator;
+};
+template < typename TDS = void > struct Periodic_3_triangulation_ds_cell_base_3 {
+    typedef typename TDS::Vertex_handle Vertex_handle;
+    const Vertex_handle& vertex(int i) const   {
+    }
+};
+struct Triangulation_data_structure_3    {
+    typedef Triangulation_data_structure_3 Tds;
+    typedef Periodic_3_triangulation_ds_cell_base_3<Tds> Cell;
+    typedef Compact_container<Cell> Cell_range;
+    typedef Compact_container<int> Vertex_range;
+    typedef typename Cell_range::iterator Cell_handle;
+    typedef typename Vertex_range::iterator Vertex_handle;
+};
+typedef Triangulation_data_structure_3 TDS1;
+template <  class > struct Periodic_3_Delaunay_triangulation_3 {
+    typedef TDS1::Vertex_handle Vertex_handle;
+    typedef TDS1::Cell_handle Cell_handle;
+    int compare_distance() const {
+    }
+    Vertex_handle nearest_vertex() const;
+};
+template < class Tds > typename Periodic_3_Delaunay_triangulation_3<Tds>::Vertex_handle Periodic_3_Delaunay_triangulation_3<Tds>::nearest_vertex() const {
+    Cell_handle c ;
+    Vertex_handle nearest = c->vertex(0);
+    nearest = (compare_distance() == -1) ?       nearest : c->vertex(0);
+    return nearest;
+}
+typedef Periodic_3_Delaunay_triangulation_3<TDS1> PDT1;
+struct Periodic_3_triangulation_hierarchy_3   : PDT1 {
+    Vertex_handle   nearest_vertex() const;
+};
+Periodic_3_triangulation_hierarchy_3::Vertex_handle Periodic_3_triangulation_hierarchy_3:: nearest_vertex() const {
+    return PDT1::nearest_vertex();
+}
index a73cb39..c5ab4ca 100644 (file)
@@ -5173,17 +5173,27 @@ tree_function_versioning (tree old_decl, tree new_decl,
     /* Add local vars.  */
     add_local_variables (DECL_STRUCT_FUNCTION (old_decl), cfun, &id, false);
 
-  /* Copy the Function's body.  */
-  copy_body (&id, old_entry_block->count, REG_BR_PROB_BASE,
-            ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, blocks_to_copy, new_entry);
-
   if (DECL_RESULT (old_decl) != NULL_TREE)
     {
-      tree *res_decl = &DECL_RESULT (old_decl);
-      DECL_RESULT (new_decl) = remap_decl (*res_decl, &id);
+      tree old_name;
+      DECL_RESULT (new_decl) = remap_decl (DECL_RESULT (old_decl), &id);
       lang_hooks.dup_lang_specific_decl (DECL_RESULT (new_decl));
+      if (gimple_in_ssa_p (id.src_cfun)
+         && DECL_BY_REFERENCE (DECL_RESULT (old_decl))
+         && (old_name
+             = gimple_default_def (id.src_cfun, DECL_RESULT (old_decl))))
+       {
+         tree new_name = make_ssa_name (DECL_RESULT (new_decl), NULL);
+         insert_decl_map (&id, old_name, new_name);
+         SSA_NAME_DEF_STMT (new_name) = gimple_build_nop ();
+         set_default_def (DECL_RESULT (new_decl), new_name);
+       }
     }
 
+  /* Copy the Function's body.  */
+  copy_body (&id, old_entry_block->count, REG_BR_PROB_BASE,
+            ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, blocks_to_copy, new_entry);
+
   /* Renumber the lexical scoping (non-code) blocks consecutively.  */
   number_blocks (new_decl);