[gcc(refs/vendors/riscv/heads/gcc-15-with-riscv-opts)] Refactor record_function_versions.
https://gcc.gnu.org/g:bec3307c3005f6e282dacbb2c06abca2ddba4da4
commit bec3307c3005f6e282dacbb2c06abca2ddba4da4
Author: Alfie Richards
Date: Thu Mar 27 14:12:06 2025 +
Refactor record_function_versions.
Renames record_function_versions to add_function_version, and make it
explicit that it is adding a single version to the function structure.
Additionally, change the insertion point to always maintain priority
ordering
of the versions.
This allows for removing logic for moving the default to the first
position which was duplicated across target specific code and enables
easier reasoning about function sets.
gcc/ChangeLog:
* cgraph.cc (cgraph_node::record_function_versions): Refactor and
rename to...
(cgraph_node::add_function_version): new function.
* cgraph.h (cgraph_node::record_function_versions): Refactor and
rename to...
(cgraph_node::add_function_version): new function.
* config/aarch64/aarch64.cc
(aarch64_get_function_versions_dispatcher):
Remove reordering.
* config/i386/i386-features.cc
(ix86_get_function_versions_dispatcher):
Remove reordering.
* config/riscv/riscv.cc (riscv_get_function_versions_dispatcher):
Remove reordering.
* config/rs6000/rs6000.cc (rs6000_get_function_versions_dispatcher):
Remove reordering.
gcc/cp/ChangeLog:
* decl.cc (maybe_version_functions): Change record_function_versions
call to add_function_version.
(cherry picked from commit 5ed7e29d5d903f469d32d8f945f094e4c2881418)
Diff:
---
gcc/cgraph.cc| 75
gcc/cgraph.h | 6 ++--
gcc/config/aarch64/aarch64.cc| 34 --
gcc/config/i386/i386-features.cc | 34 --
gcc/config/riscv/riscv.cc| 38
gcc/config/rs6000/rs6000.cc | 35 ---
gcc/cp/decl.cc | 10 +-
7 files changed, 81 insertions(+), 151 deletions(-)
diff --git a/gcc/cgraph.cc b/gcc/cgraph.cc
index 9e4ebd351fe3..eca175ca0882 100644
--- a/gcc/cgraph.cc
+++ b/gcc/cgraph.cc
@@ -231,45 +231,60 @@ cgraph_node::delete_function_version_by_decl (tree decl)
decl_node->remove ();
}
-/* Record that DECL1 and DECL2 are semantically identical function
+/* Add decl to the structure of semantically identical function versions.
+ The node is inserted at the point maintaining the priority ordering on the
versions. */
void
-cgraph_node::record_function_versions (tree decl1, tree decl2)
+cgraph_node::add_function_version (cgraph_function_version_info *fn_v,
+ tree decl)
{
- cgraph_node *decl1_node = cgraph_node::get_create (decl1);
- cgraph_node *decl2_node = cgraph_node::get_create (decl2);
- cgraph_function_version_info *decl1_v = NULL;
- cgraph_function_version_info *decl2_v = NULL;
- cgraph_function_version_info *before;
- cgraph_function_version_info *after;
-
- gcc_assert (decl1_node != NULL && decl2_node != NULL);
- decl1_v = decl1_node->function_version ();
- decl2_v = decl2_node->function_version ();
-
- if (decl1_v != NULL && decl2_v != NULL)
-return;
-
- if (decl1_v == NULL)
-decl1_v = decl1_node->insert_new_function_version ();
+ cgraph_node *decl_node = cgraph_node::get_create (decl);
+ cgraph_function_version_info *decl_v = NULL;
- if (decl2_v == NULL)
-decl2_v = decl2_node->insert_new_function_version ();
+ gcc_assert (decl_node != NULL);
- /* Chain decl2_v and decl1_v. All semantically identical versions
- will be chained together. */
+ decl_v = decl_node->function_version ();
- before = decl1_v;
- after = decl2_v;
+ /* If the nodes are already linked, skip. */
+ if (decl_v != NULL && (decl_v->next || decl_v->prev))
+return;
- while (before->next != NULL)
-before = before->next;
+ if (decl_v == NULL)
+decl_v = decl_node->insert_new_function_version ();
+
+ gcc_assert (decl_v);
+ gcc_assert (fn_v);
+
+ /* Go to start of the FMV structure. */
+ while (fn_v->prev)
+fn_v = fn_v->prev;
+
+ cgraph_function_version_info *insert_point_before = NULL;
+ cgraph_function_version_info *insert_point_after = fn_v;
+
+ /* Find the insertion point for the new version to maintain ordering.
+ The default node must always go at the beginning. */
+ if (!is_function_default_version (decl))
+while (insert_point_after
+ && (targetm.compare_version_priority
+(decl, insert_point_after->this_node->decl) > 0
+ || is_function_default_version
+ (insert_point_after->this_node->decl)
+ || lookup_attribute
+ ("target_clones",
+DECL_ATTRIBUTES (insert_point_after->this_node->decl
+ {
+ insert_poi
[gcc(refs/vendors/riscv/heads/gcc-15-with-riscv-opts)] Refactor record_function_versions.
https://gcc.gnu.org/g:e6f63029cb4f0db59cf9dfb07b464b82bfcd955f
commit e6f63029cb4f0db59cf9dfb07b464b82bfcd955f
Author: Alfie Richards
Date: Thu Mar 27 14:12:06 2025 +
Refactor record_function_versions.
Renames record_function_versions to add_function_version, and make it
explicit that it is adding a single version to the function structure.
Additionally, change the insertion point to always maintain priority
ordering
of the versions.
This allows for removing logic for moving the default to the first
position which was duplicated across target specific code and enables
easier reasoning about function sets.
gcc/ChangeLog:
* cgraph.cc (cgraph_node::record_function_versions): Refactor and
rename to...
(cgraph_node::add_function_version): new function.
* cgraph.h (cgraph_node::record_function_versions): Refactor and
rename to...
(cgraph_node::add_function_version): new function.
* config/aarch64/aarch64.cc
(aarch64_get_function_versions_dispatcher):
Remove reordering.
* config/i386/i386-features.cc
(ix86_get_function_versions_dispatcher):
Remove reordering.
* config/riscv/riscv.cc (riscv_get_function_versions_dispatcher):
Remove reordering.
* config/rs6000/rs6000.cc (rs6000_get_function_versions_dispatcher):
Remove reordering.
gcc/cp/ChangeLog:
* decl.cc (maybe_version_functions): Change record_function_versions
call to add_function_version.
(cherry picked from commit 5ed7e29d5d903f469d32d8f945f094e4c2881418)
Diff:
---
gcc/cgraph.cc| 75
gcc/cgraph.h | 6 ++--
gcc/config/aarch64/aarch64.cc| 34 --
gcc/config/i386/i386-features.cc | 34 --
gcc/config/riscv/riscv.cc| 38
gcc/config/rs6000/rs6000.cc | 35 ---
gcc/cp/decl.cc | 10 +-
7 files changed, 81 insertions(+), 151 deletions(-)
diff --git a/gcc/cgraph.cc b/gcc/cgraph.cc
index 9e4ebd351fe3..eca175ca0882 100644
--- a/gcc/cgraph.cc
+++ b/gcc/cgraph.cc
@@ -231,45 +231,60 @@ cgraph_node::delete_function_version_by_decl (tree decl)
decl_node->remove ();
}
-/* Record that DECL1 and DECL2 are semantically identical function
+/* Add decl to the structure of semantically identical function versions.
+ The node is inserted at the point maintaining the priority ordering on the
versions. */
void
-cgraph_node::record_function_versions (tree decl1, tree decl2)
+cgraph_node::add_function_version (cgraph_function_version_info *fn_v,
+ tree decl)
{
- cgraph_node *decl1_node = cgraph_node::get_create (decl1);
- cgraph_node *decl2_node = cgraph_node::get_create (decl2);
- cgraph_function_version_info *decl1_v = NULL;
- cgraph_function_version_info *decl2_v = NULL;
- cgraph_function_version_info *before;
- cgraph_function_version_info *after;
-
- gcc_assert (decl1_node != NULL && decl2_node != NULL);
- decl1_v = decl1_node->function_version ();
- decl2_v = decl2_node->function_version ();
-
- if (decl1_v != NULL && decl2_v != NULL)
-return;
-
- if (decl1_v == NULL)
-decl1_v = decl1_node->insert_new_function_version ();
+ cgraph_node *decl_node = cgraph_node::get_create (decl);
+ cgraph_function_version_info *decl_v = NULL;
- if (decl2_v == NULL)
-decl2_v = decl2_node->insert_new_function_version ();
+ gcc_assert (decl_node != NULL);
- /* Chain decl2_v and decl1_v. All semantically identical versions
- will be chained together. */
+ decl_v = decl_node->function_version ();
- before = decl1_v;
- after = decl2_v;
+ /* If the nodes are already linked, skip. */
+ if (decl_v != NULL && (decl_v->next || decl_v->prev))
+return;
- while (before->next != NULL)
-before = before->next;
+ if (decl_v == NULL)
+decl_v = decl_node->insert_new_function_version ();
+
+ gcc_assert (decl_v);
+ gcc_assert (fn_v);
+
+ /* Go to start of the FMV structure. */
+ while (fn_v->prev)
+fn_v = fn_v->prev;
+
+ cgraph_function_version_info *insert_point_before = NULL;
+ cgraph_function_version_info *insert_point_after = fn_v;
+
+ /* Find the insertion point for the new version to maintain ordering.
+ The default node must always go at the beginning. */
+ if (!is_function_default_version (decl))
+while (insert_point_after
+ && (targetm.compare_version_priority
+(decl, insert_point_after->this_node->decl) > 0
+ || is_function_default_version
+ (insert_point_after->this_node->decl)
+ || lookup_attribute
+ ("target_clones",
+DECL_ATTRIBUTES (insert_point_after->this_node->decl
+ {
+ insert_poi
[gcc(refs/vendors/riscv/heads/gcc-15-with-riscv-opts)] Refactor record_function_versions.
https://gcc.gnu.org/g:aaba6bdb81f18020c263bdaf5a81c15ffc94c88e
commit aaba6bdb81f18020c263bdaf5a81c15ffc94c88e
Author: Alfie Richards
Date: Thu Mar 27 14:12:06 2025 +
Refactor record_function_versions.
Renames record_function_versions to add_function_version, and make it
explicit that it is adding a single version to the function structure.
Additionally, change the insertion point to always maintain priority
ordering
of the versions.
This allows for removing logic for moving the default to the first
position which was duplicated across target specific code and enables
easier reasoning about function sets.
gcc/ChangeLog:
* cgraph.cc (cgraph_node::record_function_versions): Refactor and
rename to...
(cgraph_node::add_function_version): new function.
* cgraph.h (cgraph_node::record_function_versions): Refactor and
rename to...
(cgraph_node::add_function_version): new function.
* config/aarch64/aarch64.cc
(aarch64_get_function_versions_dispatcher):
Remove reordering.
* config/i386/i386-features.cc
(ix86_get_function_versions_dispatcher):
Remove reordering.
* config/riscv/riscv.cc (riscv_get_function_versions_dispatcher):
Remove reordering.
* config/rs6000/rs6000.cc (rs6000_get_function_versions_dispatcher):
Remove reordering.
gcc/cp/ChangeLog:
* decl.cc (maybe_version_functions): Change record_function_versions
call to add_function_version.
(cherry picked from commit 5ed7e29d5d903f469d32d8f945f094e4c2881418)
Diff:
---
gcc/cgraph.cc| 75
gcc/cgraph.h | 6 ++--
gcc/config/aarch64/aarch64.cc| 34 --
gcc/config/i386/i386-features.cc | 34 --
gcc/config/riscv/riscv.cc| 38
gcc/config/rs6000/rs6000.cc | 35 ---
gcc/cp/decl.cc | 10 +-
7 files changed, 81 insertions(+), 151 deletions(-)
diff --git a/gcc/cgraph.cc b/gcc/cgraph.cc
index 9e4ebd351fe3..eca175ca0882 100644
--- a/gcc/cgraph.cc
+++ b/gcc/cgraph.cc
@@ -231,45 +231,60 @@ cgraph_node::delete_function_version_by_decl (tree decl)
decl_node->remove ();
}
-/* Record that DECL1 and DECL2 are semantically identical function
+/* Add decl to the structure of semantically identical function versions.
+ The node is inserted at the point maintaining the priority ordering on the
versions. */
void
-cgraph_node::record_function_versions (tree decl1, tree decl2)
+cgraph_node::add_function_version (cgraph_function_version_info *fn_v,
+ tree decl)
{
- cgraph_node *decl1_node = cgraph_node::get_create (decl1);
- cgraph_node *decl2_node = cgraph_node::get_create (decl2);
- cgraph_function_version_info *decl1_v = NULL;
- cgraph_function_version_info *decl2_v = NULL;
- cgraph_function_version_info *before;
- cgraph_function_version_info *after;
-
- gcc_assert (decl1_node != NULL && decl2_node != NULL);
- decl1_v = decl1_node->function_version ();
- decl2_v = decl2_node->function_version ();
-
- if (decl1_v != NULL && decl2_v != NULL)
-return;
-
- if (decl1_v == NULL)
-decl1_v = decl1_node->insert_new_function_version ();
+ cgraph_node *decl_node = cgraph_node::get_create (decl);
+ cgraph_function_version_info *decl_v = NULL;
- if (decl2_v == NULL)
-decl2_v = decl2_node->insert_new_function_version ();
+ gcc_assert (decl_node != NULL);
- /* Chain decl2_v and decl1_v. All semantically identical versions
- will be chained together. */
+ decl_v = decl_node->function_version ();
- before = decl1_v;
- after = decl2_v;
+ /* If the nodes are already linked, skip. */
+ if (decl_v != NULL && (decl_v->next || decl_v->prev))
+return;
- while (before->next != NULL)
-before = before->next;
+ if (decl_v == NULL)
+decl_v = decl_node->insert_new_function_version ();
+
+ gcc_assert (decl_v);
+ gcc_assert (fn_v);
+
+ /* Go to start of the FMV structure. */
+ while (fn_v->prev)
+fn_v = fn_v->prev;
+
+ cgraph_function_version_info *insert_point_before = NULL;
+ cgraph_function_version_info *insert_point_after = fn_v;
+
+ /* Find the insertion point for the new version to maintain ordering.
+ The default node must always go at the beginning. */
+ if (!is_function_default_version (decl))
+while (insert_point_after
+ && (targetm.compare_version_priority
+(decl, insert_point_after->this_node->decl) > 0
+ || is_function_default_version
+ (insert_point_after->this_node->decl)
+ || lookup_attribute
+ ("target_clones",
+DECL_ATTRIBUTES (insert_point_after->this_node->decl
+ {
+ insert_poi
[gcc(refs/vendors/riscv/heads/gcc-15-with-riscv-opts)] Refactor record_function_versions.
https://gcc.gnu.org/g:41e68672adbfd1bdc87f9464142112732b6fcda3
commit 41e68672adbfd1bdc87f9464142112732b6fcda3
Author: Alfie Richards
Date: Thu Mar 27 14:12:06 2025 +
Refactor record_function_versions.
Renames record_function_versions to add_function_version, and make it
explicit that it is adding a single version to the function structure.
Additionally, change the insertion point to always maintain priority
ordering
of the versions.
This allows for removing logic for moving the default to the first
position which was duplicated across target specific code and enables
easier reasoning about function sets.
gcc/ChangeLog:
* cgraph.cc (cgraph_node::record_function_versions): Refactor and
rename to...
(cgraph_node::add_function_version): new function.
* cgraph.h (cgraph_node::record_function_versions): Refactor and
rename to...
(cgraph_node::add_function_version): new function.
* config/aarch64/aarch64.cc
(aarch64_get_function_versions_dispatcher):
Remove reordering.
* config/i386/i386-features.cc
(ix86_get_function_versions_dispatcher):
Remove reordering.
* config/riscv/riscv.cc (riscv_get_function_versions_dispatcher):
Remove reordering.
* config/rs6000/rs6000.cc (rs6000_get_function_versions_dispatcher):
Remove reordering.
gcc/cp/ChangeLog:
* decl.cc (maybe_version_functions): Change record_function_versions
call to add_function_version.
(cherry picked from commit 5ed7e29d5d903f469d32d8f945f094e4c2881418)
Diff:
---
gcc/cgraph.cc| 75
gcc/cgraph.h | 6 ++--
gcc/config/aarch64/aarch64.cc| 34 --
gcc/config/i386/i386-features.cc | 34 --
gcc/config/riscv/riscv.cc| 38
gcc/config/rs6000/rs6000.cc | 35 ---
gcc/cp/decl.cc | 10 +-
7 files changed, 81 insertions(+), 151 deletions(-)
diff --git a/gcc/cgraph.cc b/gcc/cgraph.cc
index 9e4ebd351fe3..eca175ca0882 100644
--- a/gcc/cgraph.cc
+++ b/gcc/cgraph.cc
@@ -231,45 +231,60 @@ cgraph_node::delete_function_version_by_decl (tree decl)
decl_node->remove ();
}
-/* Record that DECL1 and DECL2 are semantically identical function
+/* Add decl to the structure of semantically identical function versions.
+ The node is inserted at the point maintaining the priority ordering on the
versions. */
void
-cgraph_node::record_function_versions (tree decl1, tree decl2)
+cgraph_node::add_function_version (cgraph_function_version_info *fn_v,
+ tree decl)
{
- cgraph_node *decl1_node = cgraph_node::get_create (decl1);
- cgraph_node *decl2_node = cgraph_node::get_create (decl2);
- cgraph_function_version_info *decl1_v = NULL;
- cgraph_function_version_info *decl2_v = NULL;
- cgraph_function_version_info *before;
- cgraph_function_version_info *after;
-
- gcc_assert (decl1_node != NULL && decl2_node != NULL);
- decl1_v = decl1_node->function_version ();
- decl2_v = decl2_node->function_version ();
-
- if (decl1_v != NULL && decl2_v != NULL)
-return;
-
- if (decl1_v == NULL)
-decl1_v = decl1_node->insert_new_function_version ();
+ cgraph_node *decl_node = cgraph_node::get_create (decl);
+ cgraph_function_version_info *decl_v = NULL;
- if (decl2_v == NULL)
-decl2_v = decl2_node->insert_new_function_version ();
+ gcc_assert (decl_node != NULL);
- /* Chain decl2_v and decl1_v. All semantically identical versions
- will be chained together. */
+ decl_v = decl_node->function_version ();
- before = decl1_v;
- after = decl2_v;
+ /* If the nodes are already linked, skip. */
+ if (decl_v != NULL && (decl_v->next || decl_v->prev))
+return;
- while (before->next != NULL)
-before = before->next;
+ if (decl_v == NULL)
+decl_v = decl_node->insert_new_function_version ();
+
+ gcc_assert (decl_v);
+ gcc_assert (fn_v);
+
+ /* Go to start of the FMV structure. */
+ while (fn_v->prev)
+fn_v = fn_v->prev;
+
+ cgraph_function_version_info *insert_point_before = NULL;
+ cgraph_function_version_info *insert_point_after = fn_v;
+
+ /* Find the insertion point for the new version to maintain ordering.
+ The default node must always go at the beginning. */
+ if (!is_function_default_version (decl))
+while (insert_point_after
+ && (targetm.compare_version_priority
+(decl, insert_point_after->this_node->decl) > 0
+ || is_function_default_version
+ (insert_point_after->this_node->decl)
+ || lookup_attribute
+ ("target_clones",
+DECL_ATTRIBUTES (insert_point_after->this_node->decl
+ {
+ insert_poi
[gcc(refs/vendors/riscv/heads/gcc-15-with-riscv-opts)] Refactor record_function_versions.
https://gcc.gnu.org/g:f158bcda93d0e680e6051a338b1daded24eef854
commit f158bcda93d0e680e6051a338b1daded24eef854
Author: Alfie Richards
Date: Thu Mar 27 14:12:06 2025 +
Refactor record_function_versions.
Renames record_function_versions to add_function_version, and make it
explicit that it is adding a single version to the function structure.
Additionally, change the insertion point to always maintain priority
ordering
of the versions.
This allows for removing logic for moving the default to the first
position which was duplicated across target specific code and enables
easier reasoning about function sets.
gcc/ChangeLog:
* cgraph.cc (cgraph_node::record_function_versions): Refactor and
rename to...
(cgraph_node::add_function_version): new function.
* cgraph.h (cgraph_node::record_function_versions): Refactor and
rename to...
(cgraph_node::add_function_version): new function.
* config/aarch64/aarch64.cc
(aarch64_get_function_versions_dispatcher):
Remove reordering.
* config/i386/i386-features.cc
(ix86_get_function_versions_dispatcher):
Remove reordering.
* config/riscv/riscv.cc (riscv_get_function_versions_dispatcher):
Remove reordering.
* config/rs6000/rs6000.cc (rs6000_get_function_versions_dispatcher):
Remove reordering.
gcc/cp/ChangeLog:
* decl.cc (maybe_version_functions): Change record_function_versions
call to add_function_version.
(cherry picked from commit 5ed7e29d5d903f469d32d8f945f094e4c2881418)
Diff:
---
gcc/cgraph.cc| 75
gcc/cgraph.h | 6 ++--
gcc/config/aarch64/aarch64.cc| 34 --
gcc/config/i386/i386-features.cc | 34 --
gcc/config/riscv/riscv.cc| 38
gcc/config/rs6000/rs6000.cc | 35 ---
gcc/cp/decl.cc | 10 +-
7 files changed, 81 insertions(+), 151 deletions(-)
diff --git a/gcc/cgraph.cc b/gcc/cgraph.cc
index 9e4ebd351fe3..eca175ca0882 100644
--- a/gcc/cgraph.cc
+++ b/gcc/cgraph.cc
@@ -231,45 +231,60 @@ cgraph_node::delete_function_version_by_decl (tree decl)
decl_node->remove ();
}
-/* Record that DECL1 and DECL2 are semantically identical function
+/* Add decl to the structure of semantically identical function versions.
+ The node is inserted at the point maintaining the priority ordering on the
versions. */
void
-cgraph_node::record_function_versions (tree decl1, tree decl2)
+cgraph_node::add_function_version (cgraph_function_version_info *fn_v,
+ tree decl)
{
- cgraph_node *decl1_node = cgraph_node::get_create (decl1);
- cgraph_node *decl2_node = cgraph_node::get_create (decl2);
- cgraph_function_version_info *decl1_v = NULL;
- cgraph_function_version_info *decl2_v = NULL;
- cgraph_function_version_info *before;
- cgraph_function_version_info *after;
-
- gcc_assert (decl1_node != NULL && decl2_node != NULL);
- decl1_v = decl1_node->function_version ();
- decl2_v = decl2_node->function_version ();
-
- if (decl1_v != NULL && decl2_v != NULL)
-return;
-
- if (decl1_v == NULL)
-decl1_v = decl1_node->insert_new_function_version ();
+ cgraph_node *decl_node = cgraph_node::get_create (decl);
+ cgraph_function_version_info *decl_v = NULL;
- if (decl2_v == NULL)
-decl2_v = decl2_node->insert_new_function_version ();
+ gcc_assert (decl_node != NULL);
- /* Chain decl2_v and decl1_v. All semantically identical versions
- will be chained together. */
+ decl_v = decl_node->function_version ();
- before = decl1_v;
- after = decl2_v;
+ /* If the nodes are already linked, skip. */
+ if (decl_v != NULL && (decl_v->next || decl_v->prev))
+return;
- while (before->next != NULL)
-before = before->next;
+ if (decl_v == NULL)
+decl_v = decl_node->insert_new_function_version ();
+
+ gcc_assert (decl_v);
+ gcc_assert (fn_v);
+
+ /* Go to start of the FMV structure. */
+ while (fn_v->prev)
+fn_v = fn_v->prev;
+
+ cgraph_function_version_info *insert_point_before = NULL;
+ cgraph_function_version_info *insert_point_after = fn_v;
+
+ /* Find the insertion point for the new version to maintain ordering.
+ The default node must always go at the beginning. */
+ if (!is_function_default_version (decl))
+while (insert_point_after
+ && (targetm.compare_version_priority
+(decl, insert_point_after->this_node->decl) > 0
+ || is_function_default_version
+ (insert_point_after->this_node->decl)
+ || lookup_attribute
+ ("target_clones",
+DECL_ATTRIBUTES (insert_point_after->this_node->decl
+ {
+ insert_poi
[gcc(refs/vendors/riscv/heads/gcc-15-with-riscv-opts)] Refactor record_function_versions.
https://gcc.gnu.org/g:fd1a89cb34783783220023806c0c85db675bd5ed
commit fd1a89cb34783783220023806c0c85db675bd5ed
Author: Alfie Richards
Date: Thu Mar 27 14:12:06 2025 +
Refactor record_function_versions.
Renames record_function_versions to add_function_version, and make it
explicit that it is adding a single version to the function structure.
Additionally, change the insertion point to always maintain priority
ordering
of the versions.
This allows for removing logic for moving the default to the first
position which was duplicated across target specific code and enables
easier reasoning about function sets.
gcc/ChangeLog:
* cgraph.cc (cgraph_node::record_function_versions): Refactor and
rename to...
(cgraph_node::add_function_version): new function.
* cgraph.h (cgraph_node::record_function_versions): Refactor and
rename to...
(cgraph_node::add_function_version): new function.
* config/aarch64/aarch64.cc
(aarch64_get_function_versions_dispatcher):
Remove reordering.
* config/i386/i386-features.cc
(ix86_get_function_versions_dispatcher):
Remove reordering.
* config/riscv/riscv.cc (riscv_get_function_versions_dispatcher):
Remove reordering.
* config/rs6000/rs6000.cc (rs6000_get_function_versions_dispatcher):
Remove reordering.
gcc/cp/ChangeLog:
* decl.cc (maybe_version_functions): Change record_function_versions
call to add_function_version.
(cherry picked from commit 5ed7e29d5d903f469d32d8f945f094e4c2881418)
Diff:
---
gcc/cgraph.cc| 75
gcc/cgraph.h | 6 ++--
gcc/config/aarch64/aarch64.cc| 34 --
gcc/config/i386/i386-features.cc | 34 --
gcc/config/riscv/riscv.cc| 38
gcc/config/rs6000/rs6000.cc | 35 ---
gcc/cp/decl.cc | 10 +-
7 files changed, 81 insertions(+), 151 deletions(-)
diff --git a/gcc/cgraph.cc b/gcc/cgraph.cc
index 9e4ebd351fe3..eca175ca0882 100644
--- a/gcc/cgraph.cc
+++ b/gcc/cgraph.cc
@@ -231,45 +231,60 @@ cgraph_node::delete_function_version_by_decl (tree decl)
decl_node->remove ();
}
-/* Record that DECL1 and DECL2 are semantically identical function
+/* Add decl to the structure of semantically identical function versions.
+ The node is inserted at the point maintaining the priority ordering on the
versions. */
void
-cgraph_node::record_function_versions (tree decl1, tree decl2)
+cgraph_node::add_function_version (cgraph_function_version_info *fn_v,
+ tree decl)
{
- cgraph_node *decl1_node = cgraph_node::get_create (decl1);
- cgraph_node *decl2_node = cgraph_node::get_create (decl2);
- cgraph_function_version_info *decl1_v = NULL;
- cgraph_function_version_info *decl2_v = NULL;
- cgraph_function_version_info *before;
- cgraph_function_version_info *after;
-
- gcc_assert (decl1_node != NULL && decl2_node != NULL);
- decl1_v = decl1_node->function_version ();
- decl2_v = decl2_node->function_version ();
-
- if (decl1_v != NULL && decl2_v != NULL)
-return;
-
- if (decl1_v == NULL)
-decl1_v = decl1_node->insert_new_function_version ();
+ cgraph_node *decl_node = cgraph_node::get_create (decl);
+ cgraph_function_version_info *decl_v = NULL;
- if (decl2_v == NULL)
-decl2_v = decl2_node->insert_new_function_version ();
+ gcc_assert (decl_node != NULL);
- /* Chain decl2_v and decl1_v. All semantically identical versions
- will be chained together. */
+ decl_v = decl_node->function_version ();
- before = decl1_v;
- after = decl2_v;
+ /* If the nodes are already linked, skip. */
+ if (decl_v != NULL && (decl_v->next || decl_v->prev))
+return;
- while (before->next != NULL)
-before = before->next;
+ if (decl_v == NULL)
+decl_v = decl_node->insert_new_function_version ();
+
+ gcc_assert (decl_v);
+ gcc_assert (fn_v);
+
+ /* Go to start of the FMV structure. */
+ while (fn_v->prev)
+fn_v = fn_v->prev;
+
+ cgraph_function_version_info *insert_point_before = NULL;
+ cgraph_function_version_info *insert_point_after = fn_v;
+
+ /* Find the insertion point for the new version to maintain ordering.
+ The default node must always go at the beginning. */
+ if (!is_function_default_version (decl))
+while (insert_point_after
+ && (targetm.compare_version_priority
+(decl, insert_point_after->this_node->decl) > 0
+ || is_function_default_version
+ (insert_point_after->this_node->decl)
+ || lookup_attribute
+ ("target_clones",
+DECL_ATTRIBUTES (insert_point_after->this_node->decl
+ {
+ insert_poi
[gcc(refs/vendors/riscv/heads/gcc-15-with-riscv-opts)] Refactor record_function_versions.
https://gcc.gnu.org/g:6178f49509e301dbde9c3210a4842fa297612ac1
commit 6178f49509e301dbde9c3210a4842fa297612ac1
Author: Alfie Richards
Date: Thu Mar 27 14:12:06 2025 +
Refactor record_function_versions.
Renames record_function_versions to add_function_version, and make it
explicit that it is adding a single version to the function structure.
Additionally, change the insertion point to always maintain priority
ordering
of the versions.
This allows for removing logic for moving the default to the first
position which was duplicated across target specific code and enables
easier reasoning about function sets.
gcc/ChangeLog:
* cgraph.cc (cgraph_node::record_function_versions): Refactor and
rename to...
(cgraph_node::add_function_version): new function.
* cgraph.h (cgraph_node::record_function_versions): Refactor and
rename to...
(cgraph_node::add_function_version): new function.
* config/aarch64/aarch64.cc
(aarch64_get_function_versions_dispatcher):
Remove reordering.
* config/i386/i386-features.cc
(ix86_get_function_versions_dispatcher):
Remove reordering.
* config/riscv/riscv.cc (riscv_get_function_versions_dispatcher):
Remove reordering.
* config/rs6000/rs6000.cc (rs6000_get_function_versions_dispatcher):
Remove reordering.
gcc/cp/ChangeLog:
* decl.cc (maybe_version_functions): Change record_function_versions
call to add_function_version.
(cherry picked from commit 5ed7e29d5d903f469d32d8f945f094e4c2881418)
Diff:
---
gcc/cgraph.cc| 75
gcc/cgraph.h | 6 ++--
gcc/config/aarch64/aarch64.cc| 34 --
gcc/config/i386/i386-features.cc | 34 --
gcc/config/riscv/riscv.cc| 38
gcc/config/rs6000/rs6000.cc | 35 ---
gcc/cp/decl.cc | 10 +-
7 files changed, 81 insertions(+), 151 deletions(-)
diff --git a/gcc/cgraph.cc b/gcc/cgraph.cc
index 9e4ebd351fe3..eca175ca0882 100644
--- a/gcc/cgraph.cc
+++ b/gcc/cgraph.cc
@@ -231,45 +231,60 @@ cgraph_node::delete_function_version_by_decl (tree decl)
decl_node->remove ();
}
-/* Record that DECL1 and DECL2 are semantically identical function
+/* Add decl to the structure of semantically identical function versions.
+ The node is inserted at the point maintaining the priority ordering on the
versions. */
void
-cgraph_node::record_function_versions (tree decl1, tree decl2)
+cgraph_node::add_function_version (cgraph_function_version_info *fn_v,
+ tree decl)
{
- cgraph_node *decl1_node = cgraph_node::get_create (decl1);
- cgraph_node *decl2_node = cgraph_node::get_create (decl2);
- cgraph_function_version_info *decl1_v = NULL;
- cgraph_function_version_info *decl2_v = NULL;
- cgraph_function_version_info *before;
- cgraph_function_version_info *after;
-
- gcc_assert (decl1_node != NULL && decl2_node != NULL);
- decl1_v = decl1_node->function_version ();
- decl2_v = decl2_node->function_version ();
-
- if (decl1_v != NULL && decl2_v != NULL)
-return;
-
- if (decl1_v == NULL)
-decl1_v = decl1_node->insert_new_function_version ();
+ cgraph_node *decl_node = cgraph_node::get_create (decl);
+ cgraph_function_version_info *decl_v = NULL;
- if (decl2_v == NULL)
-decl2_v = decl2_node->insert_new_function_version ();
+ gcc_assert (decl_node != NULL);
- /* Chain decl2_v and decl1_v. All semantically identical versions
- will be chained together. */
+ decl_v = decl_node->function_version ();
- before = decl1_v;
- after = decl2_v;
+ /* If the nodes are already linked, skip. */
+ if (decl_v != NULL && (decl_v->next || decl_v->prev))
+return;
- while (before->next != NULL)
-before = before->next;
+ if (decl_v == NULL)
+decl_v = decl_node->insert_new_function_version ();
+
+ gcc_assert (decl_v);
+ gcc_assert (fn_v);
+
+ /* Go to start of the FMV structure. */
+ while (fn_v->prev)
+fn_v = fn_v->prev;
+
+ cgraph_function_version_info *insert_point_before = NULL;
+ cgraph_function_version_info *insert_point_after = fn_v;
+
+ /* Find the insertion point for the new version to maintain ordering.
+ The default node must always go at the beginning. */
+ if (!is_function_default_version (decl))
+while (insert_point_after
+ && (targetm.compare_version_priority
+(decl, insert_point_after->this_node->decl) > 0
+ || is_function_default_version
+ (insert_point_after->this_node->decl)
+ || lookup_attribute
+ ("target_clones",
+DECL_ATTRIBUTES (insert_point_after->this_node->decl
+ {
+ insert_poi
[gcc(refs/vendors/riscv/heads/gcc-15-with-riscv-opts)] Refactor record_function_versions.
https://gcc.gnu.org/g:0190716280b5c2da106ae64e9df77fb6e4b21d51
commit 0190716280b5c2da106ae64e9df77fb6e4b21d51
Author: Alfie Richards
Date: Thu Mar 27 14:12:06 2025 +
Refactor record_function_versions.
Renames record_function_versions to add_function_version, and make it
explicit that it is adding a single version to the function structure.
Additionally, change the insertion point to always maintain priority
ordering
of the versions.
This allows for removing logic for moving the default to the first
position which was duplicated across target specific code and enables
easier reasoning about function sets.
gcc/ChangeLog:
* cgraph.cc (cgraph_node::record_function_versions): Refactor and
rename to...
(cgraph_node::add_function_version): new function.
* cgraph.h (cgraph_node::record_function_versions): Refactor and
rename to...
(cgraph_node::add_function_version): new function.
* config/aarch64/aarch64.cc
(aarch64_get_function_versions_dispatcher):
Remove reordering.
* config/i386/i386-features.cc
(ix86_get_function_versions_dispatcher):
Remove reordering.
* config/riscv/riscv.cc (riscv_get_function_versions_dispatcher):
Remove reordering.
* config/rs6000/rs6000.cc (rs6000_get_function_versions_dispatcher):
Remove reordering.
gcc/cp/ChangeLog:
* decl.cc (maybe_version_functions): Change record_function_versions
call to add_function_version.
(cherry picked from commit 5ed7e29d5d903f469d32d8f945f094e4c2881418)
Diff:
---
gcc/cgraph.cc| 75
gcc/cgraph.h | 6 ++--
gcc/config/aarch64/aarch64.cc| 34 --
gcc/config/i386/i386-features.cc | 34 --
gcc/config/riscv/riscv.cc| 38
gcc/config/rs6000/rs6000.cc | 35 ---
gcc/cp/decl.cc | 10 +-
7 files changed, 81 insertions(+), 151 deletions(-)
diff --git a/gcc/cgraph.cc b/gcc/cgraph.cc
index 48646de6aa32..d821e2cd84ee 100644
--- a/gcc/cgraph.cc
+++ b/gcc/cgraph.cc
@@ -231,45 +231,60 @@ cgraph_node::delete_function_version_by_decl (tree decl)
decl_node->remove ();
}
-/* Record that DECL1 and DECL2 are semantically identical function
+/* Add decl to the structure of semantically identical function versions.
+ The node is inserted at the point maintaining the priority ordering on the
versions. */
void
-cgraph_node::record_function_versions (tree decl1, tree decl2)
+cgraph_node::add_function_version (cgraph_function_version_info *fn_v,
+ tree decl)
{
- cgraph_node *decl1_node = cgraph_node::get_create (decl1);
- cgraph_node *decl2_node = cgraph_node::get_create (decl2);
- cgraph_function_version_info *decl1_v = NULL;
- cgraph_function_version_info *decl2_v = NULL;
- cgraph_function_version_info *before;
- cgraph_function_version_info *after;
-
- gcc_assert (decl1_node != NULL && decl2_node != NULL);
- decl1_v = decl1_node->function_version ();
- decl2_v = decl2_node->function_version ();
-
- if (decl1_v != NULL && decl2_v != NULL)
-return;
-
- if (decl1_v == NULL)
-decl1_v = decl1_node->insert_new_function_version ();
+ cgraph_node *decl_node = cgraph_node::get_create (decl);
+ cgraph_function_version_info *decl_v = NULL;
- if (decl2_v == NULL)
-decl2_v = decl2_node->insert_new_function_version ();
+ gcc_assert (decl_node != NULL);
- /* Chain decl2_v and decl1_v. All semantically identical versions
- will be chained together. */
+ decl_v = decl_node->function_version ();
- before = decl1_v;
- after = decl2_v;
+ /* If the nodes are already linked, skip. */
+ if (decl_v != NULL && (decl_v->next || decl_v->prev))
+return;
- while (before->next != NULL)
-before = before->next;
+ if (decl_v == NULL)
+decl_v = decl_node->insert_new_function_version ();
+
+ gcc_assert (decl_v);
+ gcc_assert (fn_v);
+
+ /* Go to start of the FMV structure. */
+ while (fn_v->prev)
+fn_v = fn_v->prev;
+
+ cgraph_function_version_info *insert_point_before = NULL;
+ cgraph_function_version_info *insert_point_after = fn_v;
+
+ /* Find the insertion point for the new version to maintain ordering.
+ The default node must always go at the beginning. */
+ if (!is_function_default_version (decl))
+while (insert_point_after
+ && (targetm.compare_version_priority
+(decl, insert_point_after->this_node->decl) > 0
+ || is_function_default_version
+ (insert_point_after->this_node->decl)
+ || lookup_attribute
+ ("target_clones",
+DECL_ATTRIBUTES (insert_point_after->this_node->decl
+ {
+ insert_poi
[gcc(refs/vendors/riscv/heads/gcc-15-with-riscv-opts)] Refactor record_function_versions.
https://gcc.gnu.org/g:7363e569418ebe52a606c6e2078e07b475881ba0
commit 7363e569418ebe52a606c6e2078e07b475881ba0
Author: Alfie Richards
Date: Thu Mar 27 14:12:06 2025 +
Refactor record_function_versions.
Renames record_function_versions to add_function_version, and make it
explicit that it is adding a single version to the function structure.
Additionally, change the insertion point to always maintain priority
ordering
of the versions.
This allows for removing logic for moving the default to the first
position which was duplicated across target specific code and enables
easier reasoning about function sets.
gcc/ChangeLog:
* cgraph.cc (cgraph_node::record_function_versions): Refactor and
rename to...
(cgraph_node::add_function_version): new function.
* cgraph.h (cgraph_node::record_function_versions): Refactor and
rename to...
(cgraph_node::add_function_version): new function.
* config/aarch64/aarch64.cc
(aarch64_get_function_versions_dispatcher):
Remove reordering.
* config/i386/i386-features.cc
(ix86_get_function_versions_dispatcher):
Remove reordering.
* config/riscv/riscv.cc (riscv_get_function_versions_dispatcher):
Remove reordering.
* config/rs6000/rs6000.cc (rs6000_get_function_versions_dispatcher):
Remove reordering.
gcc/cp/ChangeLog:
* decl.cc (maybe_version_functions): Change record_function_versions
call to add_function_version.
(cherry picked from commit 5ed7e29d5d903f469d32d8f945f094e4c2881418)
Diff:
---
gcc/cgraph.cc| 75
gcc/cgraph.h | 6 ++--
gcc/config/aarch64/aarch64.cc| 34 --
gcc/config/i386/i386-features.cc | 34 --
gcc/config/riscv/riscv.cc| 38
gcc/config/rs6000/rs6000.cc | 35 ---
gcc/cp/decl.cc | 10 +-
7 files changed, 81 insertions(+), 151 deletions(-)
diff --git a/gcc/cgraph.cc b/gcc/cgraph.cc
index 48646de6aa32..d821e2cd84ee 100644
--- a/gcc/cgraph.cc
+++ b/gcc/cgraph.cc
@@ -231,45 +231,60 @@ cgraph_node::delete_function_version_by_decl (tree decl)
decl_node->remove ();
}
-/* Record that DECL1 and DECL2 are semantically identical function
+/* Add decl to the structure of semantically identical function versions.
+ The node is inserted at the point maintaining the priority ordering on the
versions. */
void
-cgraph_node::record_function_versions (tree decl1, tree decl2)
+cgraph_node::add_function_version (cgraph_function_version_info *fn_v,
+ tree decl)
{
- cgraph_node *decl1_node = cgraph_node::get_create (decl1);
- cgraph_node *decl2_node = cgraph_node::get_create (decl2);
- cgraph_function_version_info *decl1_v = NULL;
- cgraph_function_version_info *decl2_v = NULL;
- cgraph_function_version_info *before;
- cgraph_function_version_info *after;
-
- gcc_assert (decl1_node != NULL && decl2_node != NULL);
- decl1_v = decl1_node->function_version ();
- decl2_v = decl2_node->function_version ();
-
- if (decl1_v != NULL && decl2_v != NULL)
-return;
-
- if (decl1_v == NULL)
-decl1_v = decl1_node->insert_new_function_version ();
+ cgraph_node *decl_node = cgraph_node::get_create (decl);
+ cgraph_function_version_info *decl_v = NULL;
- if (decl2_v == NULL)
-decl2_v = decl2_node->insert_new_function_version ();
+ gcc_assert (decl_node != NULL);
- /* Chain decl2_v and decl1_v. All semantically identical versions
- will be chained together. */
+ decl_v = decl_node->function_version ();
- before = decl1_v;
- after = decl2_v;
+ /* If the nodes are already linked, skip. */
+ if (decl_v != NULL && (decl_v->next || decl_v->prev))
+return;
- while (before->next != NULL)
-before = before->next;
+ if (decl_v == NULL)
+decl_v = decl_node->insert_new_function_version ();
+
+ gcc_assert (decl_v);
+ gcc_assert (fn_v);
+
+ /* Go to start of the FMV structure. */
+ while (fn_v->prev)
+fn_v = fn_v->prev;
+
+ cgraph_function_version_info *insert_point_before = NULL;
+ cgraph_function_version_info *insert_point_after = fn_v;
+
+ /* Find the insertion point for the new version to maintain ordering.
+ The default node must always go at the beginning. */
+ if (!is_function_default_version (decl))
+while (insert_point_after
+ && (targetm.compare_version_priority
+(decl, insert_point_after->this_node->decl) > 0
+ || is_function_default_version
+ (insert_point_after->this_node->decl)
+ || lookup_attribute
+ ("target_clones",
+DECL_ATTRIBUTES (insert_point_after->this_node->decl
+ {
+ insert_poi
[gcc(refs/vendors/riscv/heads/gcc-15-with-riscv-opts)] Refactor record_function_versions.
https://gcc.gnu.org/g:1d5cfe644cd2047badb9e247dba2d3d9596e273e
commit 1d5cfe644cd2047badb9e247dba2d3d9596e273e
Author: Alfie Richards
Date: Thu Mar 27 14:12:06 2025 +
Refactor record_function_versions.
Renames record_function_versions to add_function_version, and make it
explicit that it is adding a single version to the function structure.
Additionally, change the insertion point to always maintain priority
ordering
of the versions.
This allows for removing logic for moving the default to the first
position which was duplicated across target specific code and enables
easier reasoning about function sets.
gcc/ChangeLog:
* cgraph.cc (cgraph_node::record_function_versions): Refactor and
rename to...
(cgraph_node::add_function_version): new function.
* cgraph.h (cgraph_node::record_function_versions): Refactor and
rename to...
(cgraph_node::add_function_version): new function.
* config/aarch64/aarch64.cc
(aarch64_get_function_versions_dispatcher):
Remove reordering.
* config/i386/i386-features.cc
(ix86_get_function_versions_dispatcher):
Remove reordering.
* config/riscv/riscv.cc (riscv_get_function_versions_dispatcher):
Remove reordering.
* config/rs6000/rs6000.cc (rs6000_get_function_versions_dispatcher):
Remove reordering.
gcc/cp/ChangeLog:
* decl.cc (maybe_version_functions): Change record_function_versions
call to add_function_version.
(cherry picked from commit 5ed7e29d5d903f469d32d8f945f094e4c2881418)
Diff:
---
gcc/cgraph.cc| 75
gcc/cgraph.h | 6 ++--
gcc/config/aarch64/aarch64.cc| 34 --
gcc/config/i386/i386-features.cc | 34 --
gcc/config/riscv/riscv.cc| 38
gcc/config/rs6000/rs6000.cc | 35 ---
gcc/cp/decl.cc | 10 +-
7 files changed, 81 insertions(+), 151 deletions(-)
diff --git a/gcc/cgraph.cc b/gcc/cgraph.cc
index 6ae6a97f6f56..feaeebec40ba 100644
--- a/gcc/cgraph.cc
+++ b/gcc/cgraph.cc
@@ -231,45 +231,60 @@ cgraph_node::delete_function_version_by_decl (tree decl)
decl_node->remove ();
}
-/* Record that DECL1 and DECL2 are semantically identical function
+/* Add decl to the structure of semantically identical function versions.
+ The node is inserted at the point maintaining the priority ordering on the
versions. */
void
-cgraph_node::record_function_versions (tree decl1, tree decl2)
+cgraph_node::add_function_version (cgraph_function_version_info *fn_v,
+ tree decl)
{
- cgraph_node *decl1_node = cgraph_node::get_create (decl1);
- cgraph_node *decl2_node = cgraph_node::get_create (decl2);
- cgraph_function_version_info *decl1_v = NULL;
- cgraph_function_version_info *decl2_v = NULL;
- cgraph_function_version_info *before;
- cgraph_function_version_info *after;
-
- gcc_assert (decl1_node != NULL && decl2_node != NULL);
- decl1_v = decl1_node->function_version ();
- decl2_v = decl2_node->function_version ();
-
- if (decl1_v != NULL && decl2_v != NULL)
-return;
-
- if (decl1_v == NULL)
-decl1_v = decl1_node->insert_new_function_version ();
+ cgraph_node *decl_node = cgraph_node::get_create (decl);
+ cgraph_function_version_info *decl_v = NULL;
- if (decl2_v == NULL)
-decl2_v = decl2_node->insert_new_function_version ();
+ gcc_assert (decl_node != NULL);
- /* Chain decl2_v and decl1_v. All semantically identical versions
- will be chained together. */
+ decl_v = decl_node->function_version ();
- before = decl1_v;
- after = decl2_v;
+ /* If the nodes are already linked, skip. */
+ if (decl_v != NULL && (decl_v->next || decl_v->prev))
+return;
- while (before->next != NULL)
-before = before->next;
+ if (decl_v == NULL)
+decl_v = decl_node->insert_new_function_version ();
+
+ gcc_assert (decl_v);
+ gcc_assert (fn_v);
+
+ /* Go to start of the FMV structure. */
+ while (fn_v->prev)
+fn_v = fn_v->prev;
+
+ cgraph_function_version_info *insert_point_before = NULL;
+ cgraph_function_version_info *insert_point_after = fn_v;
+
+ /* Find the insertion point for the new version to maintain ordering.
+ The default node must always go at the beginning. */
+ if (!is_function_default_version (decl))
+while (insert_point_after
+ && (targetm.compare_version_priority
+(decl, insert_point_after->this_node->decl) > 0
+ || is_function_default_version
+ (insert_point_after->this_node->decl)
+ || lookup_attribute
+ ("target_clones",
+DECL_ATTRIBUTES (insert_point_after->this_node->decl
+ {
+ insert_poi
