https://gcc.gnu.org/g:0895aef01c64c317b489811dbe4ac55f9c13aab3

commit r15-6345-g0895aef01c64c317b489811dbe4ac55f9c13aab3
Author: Michal Jires <mji...@suse.cz>
Date:   Thu Oct 24 02:21:00 2024 +0200

    Node clones share order.
    
    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.

Diff:
---
 gcc/cgraph.h        | 5 +++--
 gcc/cgraphclones.cc | 1 +
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/gcc/cgraph.h b/gcc/cgraph.h
index 9b4cb6383afc..099fae654da1 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)
@@ -2819,7 +2819,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 33cab4583348..9f05477cb825 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;

Reply via email to