]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
lto: Fix reversed sorting of node order.
authorMichal Jires <mjires@suse.cz>
Thu, 15 May 2025 14:37:12 +0000 (16:37 +0200)
committerMichal Jires <mjires@suse.cz>
Thu, 30 Oct 2025 15:49:33 +0000 (16:49 +0100)
Sorting by node order in lto partitioning is incorrectly reversed.
For default balanced partitioning this caused all noreorder symbols
to be partitioned into a single partition where they were sorted again,
but correctly.

gcc/lto/ChangeLog:

* lto-partition.cc (cmp_partitions_order): Reverse sort.
(node_cmp): Reverse sort.

gcc/lto/lto-partition.cc

index c7e69ee31614084c84cd358d1978e5a135854cd8..c53471173deab0951ee905cdd1ddb6122e085a14 100644 (file)
@@ -61,7 +61,7 @@ cmp_partitions_order (const void *a, const void *b)
     ordera = lto_symtab_encoder_deref (pa->encoder, 0)->order;
   if (lto_symtab_encoder_size (pb->encoder))
     orderb = lto_symtab_encoder_deref (pb->encoder, 0)->order;
-  return orderb - ordera;
+  return ordera - orderb;
 }
 
 /* Create new partition with name NAME.
@@ -398,7 +398,7 @@ node_cmp (const void *pa, const void *pb)
 {
   const symtab_node *a = *static_cast<const symtab_node * const *> (pa);
   const symtab_node *b = *static_cast<const symtab_node * const *> (pb);
-  return b->order - a->order;
+  return a->order - b->order;
 }
 
 /* Add all symtab nodes from NEXT_NODE to PARTITION in order.  */