diff mbox series

[2/3] Node clones share order.

Message ID fbcdc899dd6763046783b7e2cdbeba4dd1c99afa.1730885483.git.mjires@suse.cz
State New
Headers show
Series incremental lto: Stabilizing node order. | expand

Commit Message

Michal Jires Nov. 6, 2024, 1:02 p.m. UTC
Symbol order corresponds to the order in source code.
For clones their order is currently arbitrarily chosen as max order++
But it would be more consistent with original purpose to choose clones
order to be shared with the original node order.
This stabilizes clone order for Incremental LTO.

Order is thus no longer unique, but this property is not used outside
of previous patch, where we can use uid.
If total order would be needed, sorting by order and then uid suffices.

gcc/ChangeLog:

	* cgraph.h (symbol_table::register_symbol):
	  Order can be already set.
	* cgraphclones.cc (cgraph_node::create_clone):
	  Reuse order for clones.
---
 gcc/cgraph.h        | 5 +++--
 gcc/cgraphclones.cc | 1 +
 2 files changed, 4 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/gcc/cgraph.h b/gcc/cgraph.h
index a8c3224802c..508788b062b 100644
--- a/gcc/cgraph.h
+++ b/gcc/cgraph.h
@@ -121,7 +121,7 @@  public:
       used_from_other_partition (false), in_other_partition (false),
       address_taken (false), in_init_priority_hash (false),
       need_lto_streaming (false), offloadable (false), ifunc_resolver (false),
-      order (false), next_sharing_asm_name (NULL),
+      order (-1), next_sharing_asm_name (NULL),
       previous_sharing_asm_name (NULL), same_comdat_group (NULL), ref_list (),
       alias_target (NULL), lto_file_data (NULL), aux (NULL),
       x_comdat_group (NULL_TREE), x_section (NULL)
@@ -2815,7 +2815,8 @@  symbol_table::register_symbol (symtab_node *node)
     nodes->previous = node;
   nodes = node;
 
-  node->order = order++;
+  if (node->order == -1)
+    node->order = order++;
 }
 
 /* Register a top-level asm statement ASM_STR.  */
diff --git a/gcc/cgraphclones.cc b/gcc/cgraphclones.cc
index 4fff6873a36..fc0f9046d99 100644
--- a/gcc/cgraphclones.cc
+++ b/gcc/cgraphclones.cc
@@ -401,6 +401,7 @@  cgraph_node::create_clone (tree new_decl, profile_count prof_count,
         count = count.combine_with_ipa_count (count.ipa () - prof_count.ipa ());
     }
   new_node->decl = new_decl;
+  new_node->order = order;
   new_node->register_symbol ();
   new_node->lto_file_data = lto_file_data;
   new_node->analyzed = analyzed;