re PR ipa/64963 (IPA Cloning/Splitting does not copy function section attributes...
authorJakub Jelinek <jakub@redhat.com>
Mon, 16 Feb 2015 19:22:57 +0000 (20:22 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 16 Feb 2015 19:22:57 +0000 (20:22 +0100)
PR ipa/64963
* cgraphclones.c (cgraph_node::create_virtual_clone): Copy
section if not linkonce.  Fix up formatting.
(cgraph_node::create_version_clone_with_body): Copy section.
* trans-mem.c (ipa_tm_create_version): Likewise.

* gcc.dg/ipa/ipa-clone-1.c: New test.

Co-Authored-By: James Greenhalgh <james.greenhalgh@arm.com>
From-SVN: r220742

gcc/ChangeLog
gcc/cgraphclones.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/ipa/ipa-clone-1.c [new file with mode: 0644]
gcc/trans-mem.c

index 061e0341c5091c8e4e8b790a40c155bca2ff108a..9ef0d8c5f21ccc3e5b44da159df3dae9da58d3fa 100644 (file)
@@ -1,3 +1,12 @@
+2015-02-16  Jakub Jelinek  <jakub@redhat.com>
+           James Greenhalgh  <james.greenhalgh@arm.com>
+
+       PR ipa/64963
+       * cgraphclones.c (cgraph_node::create_virtual_clone): Copy
+       section if not linkonce.  Fix up formatting.
+       (cgraph_node::create_version_clone_with_body): Copy section.
+       * trans-mem.c (ipa_tm_create_version): Likewise.
+
 2015-02-16  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/65077
index 2a7de2e6689f1bc29124f2d015c81d6b1fc86955..863081e20207f37df72e069ed0225660aee63ea1 100644 (file)
@@ -577,7 +577,7 @@ cgraph_node::create_virtual_clone (vec<cgraph_edge *> redirect_callers,
   char *name;
 
   if (!in_lto_p)
-    gcc_checking_assert  (tree_versionable_function_p (old_decl));
+    gcc_checking_assert (tree_versionable_function_p (old_decl));
 
   gcc_assert (local.can_change_signature || !args_to_skip);
 
@@ -617,6 +617,8 @@ cgraph_node::create_virtual_clone (vec<cgraph_edge *> redirect_callers,
      ABI support for this.  */
   set_new_clone_decl_and_node_flags (new_node);
   new_node->clone.tree_map = tree_map;
+  if (!DECL_ONE_ONLY (old_decl))
+    new_node->set_section (get_section ());
 
   /* Clones of global symbols or symbols with unique names are unique.  */
   if ((TREE_PUBLIC (old_decl)
@@ -1009,6 +1011,7 @@ cgraph_node::create_version_clone_with_body
   new_version_node->externally_visible = 0;
   new_version_node->local.local = 1;
   new_version_node->lowered = true;
+  new_version_node->set_section (get_section ());
   /* Clones of global symbols or symbols with unique names are unique.  */
   if ((TREE_PUBLIC (old_decl)
        && !DECL_EXTERNAL (old_decl)
index 8af42fa44582893d241e42e4324a1c4ddcb42c61..d5769b70b2025feb05ba9e6e25024b7f744656a6 100644 (file)
@@ -1,3 +1,9 @@
+2015-02-16  Jakub Jelinek  <jakub@redhat.com>
+           James Greenhalgh  <james.greenhalgh@arm.com>
+
+       PR ipa/64963
+       * gcc.dg/ipa/ipa-clone-1.c: New test.
+
 2015-02-16  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/65077
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-clone-1.c b/gcc/testsuite/gcc.dg/ipa/ipa-clone-1.c
new file mode 100644 (file)
index 0000000..5ee8166
--- /dev/null
@@ -0,0 +1,20 @@
+/* PR ipa/64693 */
+/* { dg-do compile } */
+/* { dg-require-named-sections "" } */
+/* { dg-options "-O3 -fipa-cp -fipa-cp-clone -fdump-ipa-cp"  } */
+
+static int __attribute__ ((noinline, section ("test_section")))
+foo (int arg)
+{
+  return 7 * arg;
+}
+
+int
+bar (int arg)
+{
+  return foo (5);
+}
+
+/* { dg-final { scan-assembler "test_section" } } */
+/* { dg-final { scan-ipa-dump "Creating a specialized node of foo" "cp" } } */
+/* { dg-final { cleanup-ipa-dump "cp" } } */
index 21fa497802eab8dc91cc8b40ef649b99613721ae..146a9759db1ab326ca63eff4c2ed98d6a3929a85 100644 (file)
@@ -4967,6 +4967,7 @@ ipa_tm_create_version (struct cgraph_node *old_node)
   new_node->externally_visible = old_node->externally_visible;
   new_node->lowered = true;
   new_node->tm_clone = 1;
+  new_node->set_section (old_node->get_section ());
   get_cg_data (&old_node, true)->clone = new_node;
 
   if (old_node->get_availability () >= AVAIL_INTERPOSABLE)