From 11f37e99ef818b92f8a8ada5cfb42fecaeb9732c Mon Sep 17 00:00:00 2001 From: Michal Jires Date: Thu, 15 May 2025 16:37:12 +0200 Subject: [PATCH] lto: Fix reversed sorting of node order. 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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/lto/lto-partition.cc b/gcc/lto/lto-partition.cc index c7e69ee3161..c53471173de 100644 --- a/gcc/lto/lto-partition.cc +++ b/gcc/lto/lto-partition.cc @@ -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 (pa); const symtab_node *b = *static_cast (pb); - return b->order - a->order; + return a->order - b->order; } /* Add all symtab nodes from NEXT_NODE to PARTITION in order. */ -- 2.47.3