Re: [PATCH 09/14] Remove cgraph_node::summary_uid and make cgraph_node::uid really unique.

2018-06-08 Thread Christophe Lyon
On 8 June 2018 at 22:05, Martin Liška  wrote:
> On 06/08/2018 09:58 PM, Christophe Lyon wrote:
>>
>> On 7 June 2018 at 14:09, Jan Hubicka  wrote:


 gcc/ChangeLog:

 2018-05-16  Martin Liska  

* cgraph.c (cgraph_node::remove): Do not recycle uid.
* cgraph.h (symbol_table::release_symbol): Do not pass uid.
(symbol_table::allocate_cgraph_symbol): Do not set uid.
* passes.c (uid_hash_t): Record removed_nodes by their uids.
(remove_cgraph_node_from_order): Use the removed_nodes set.
(do_per_function_toporder): Likwise.
* symbol-summary.h (symtab_insertion): Use cgraph_node::uid
instead of summary_uid.
(symtab_removal): Likewise.
(symtab_duplication): Likewise.

 gcc/lto/ChangeLog:

 2018-05-16  Martin Liska  

* lto-partition.c (lto_balanced_map): Use cgraph_node::uid
instead of summary_uid.
>>>
>>>
>>> I am still now convinced that competely moving from arrays made dense by
>>> uid recyclic to hash tables is performance-wise smart idea, but current
>>> uid is not working very well for this purpose - most summaries we have
>>> are only for definitions so we want something like definition uid.
>>>
>>> In general it seems bad that we allocate same memory for object with
>>> definition
>>> and external symbol. Something I planned to change but did not get to do
>>> that yet.
>>>
>>> So the patch is OK. With new abstraction we can always re-invent dense
>>> uids for
>>> this purpose later.
>>>
>>> Honza
>>
>>
>>
>> Hi!
>>
>> This patch broke the GCC build:
>
>
> Sorry for that. It was just short breakage, it's fixed in r261320.
>

OK, good to know. My build queue hasn't reached that stage yet :)

Thanks

> Martin
>
>
>> /tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:
>> In function ‘void remove_cgraph_node_from_order(cgraph_node*, void*)’:
>>
>> /tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1646:
>> warning: ‘>>’ operator will be treated as two right angle brackets in
>> C++0x
>>
>> /tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1646:
>> warning: suggest parentheses around ‘>>’ expression
>>
>> /tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1646:
>> error: ‘removed_nodes’ was not declared in this scope
>>
>> /tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1646:
>> error: ‘*’ cannot appear in a constant-expression
>>
>> /tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1646:
>> warning: ‘>>’ operator will be treated as two right angle brackets in
>> C++0x
>>
>> /tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1646:
>> warning: suggest parentheses around ‘>>’ expression
>>
>> /tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1646:
>> error: ‘*’ cannot appear in a constant-expression
>>
>> /tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1646:
>> error: template argument 3 is invalid
>>
>> /tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1646:
>> error: template argument 1 is invalid
>>
>> /tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1646:
>> error: template argument 2 is invalid
>>
>> /tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1646:
>> error: an assignment cannot appear in a constant-expression
>>
>> /tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1646:
>> error: template argument 3 is invalid
>>
>> /tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1646:
>> error: template argument 1 is invalid
>>
>> /tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1646:
>> error: template argument 2 is invalid
>> /tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:
>> In function ‘void do_per_function_toporder(void (*)(function*, void*),
>> void*)’:
>>
>> /tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1664:
>> warning: ‘>>’ operator will be treated as two right angle brackets in
>> C++0x
>>
>> /tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1664:
>> warning: suggest parentheses around ‘>>’ expression
>>
>> /tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1664:
>> error: ‘removed_nodes’ was not declared in this scope
>>
>> /tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1664:
>> error: template argument 3 is invalid
>>
>> /tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1664:
>> error: template argument 1 is invalid
>>
>> /tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1664:
>> error: template argument 2 is invalid
>> make[2]: *** [passes.o] Error 1
>>
>


Re: [PATCH 09/14] Remove cgraph_node::summary_uid and make cgraph_node::uid really unique.

2018-06-08 Thread Martin Liška

On 06/08/2018 09:58 PM, Christophe Lyon wrote:

On 7 June 2018 at 14:09, Jan Hubicka  wrote:


gcc/ChangeLog:

2018-05-16  Martin Liska  

   * cgraph.c (cgraph_node::remove): Do not recycle uid.
   * cgraph.h (symbol_table::release_symbol): Do not pass uid.
   (symbol_table::allocate_cgraph_symbol): Do not set uid.
   * passes.c (uid_hash_t): Record removed_nodes by their uids.
   (remove_cgraph_node_from_order): Use the removed_nodes set.
   (do_per_function_toporder): Likwise.
   * symbol-summary.h (symtab_insertion): Use cgraph_node::uid
   instead of summary_uid.
   (symtab_removal): Likewise.
   (symtab_duplication): Likewise.

gcc/lto/ChangeLog:

2018-05-16  Martin Liska  

   * lto-partition.c (lto_balanced_map): Use cgraph_node::uid
   instead of summary_uid.


I am still now convinced that competely moving from arrays made dense by
uid recyclic to hash tables is performance-wise smart idea, but current
uid is not working very well for this purpose - most summaries we have
are only for definitions so we want something like definition uid.

In general it seems bad that we allocate same memory for object with definition
and external symbol. Something I planned to change but did not get to do that 
yet.

So the patch is OK. With new abstraction we can always re-invent dense uids for
this purpose later.

Honza



Hi!

This patch broke the GCC build:


Sorry for that. It was just short breakage, it's fixed in r261320.

Martin


/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:
In function ‘void remove_cgraph_node_from_order(cgraph_node*, void*)’:
/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1646:
warning: ‘>>’ operator will be treated as two right angle brackets in
C++0x
/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1646:
warning: suggest parentheses around ‘>>’ expression
/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1646:
error: ‘removed_nodes’ was not declared in this scope
/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1646:
error: ‘*’ cannot appear in a constant-expression
/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1646:
warning: ‘>>’ operator will be treated as two right angle brackets in
C++0x
/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1646:
warning: suggest parentheses around ‘>>’ expression
/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1646:
error: ‘*’ cannot appear in a constant-expression
/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1646:
error: template argument 3 is invalid
/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1646:
error: template argument 1 is invalid
/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1646:
error: template argument 2 is invalid
/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1646:
error: an assignment cannot appear in a constant-expression
/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1646:
error: template argument 3 is invalid
/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1646:
error: template argument 1 is invalid
/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1646:
error: template argument 2 is invalid
/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:
In function ‘void do_per_function_toporder(void (*)(function*, void*),
void*)’:
/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1664:
warning: ‘>>’ operator will be treated as two right angle brackets in
C++0x
/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1664:
warning: suggest parentheses around ‘>>’ expression
/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1664:
error: ‘removed_nodes’ was not declared in this scope
/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1664:
error: template argument 3 is invalid
/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1664:
error: template argument 1 is invalid
/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1664:
error: template argument 2 is invalid
make[2]: *** [passes.o] Error 1





Re: [PATCH 09/14] Remove cgraph_node::summary_uid and make cgraph_node::uid really unique.

2018-06-08 Thread Christophe Lyon
On 7 June 2018 at 14:09, Jan Hubicka  wrote:
>>
>> gcc/ChangeLog:
>>
>> 2018-05-16  Martin Liska  
>>
>>   * cgraph.c (cgraph_node::remove): Do not recycle uid.
>>   * cgraph.h (symbol_table::release_symbol): Do not pass uid.
>>   (symbol_table::allocate_cgraph_symbol): Do not set uid.
>>   * passes.c (uid_hash_t): Record removed_nodes by their uids.
>>   (remove_cgraph_node_from_order): Use the removed_nodes set.
>>   (do_per_function_toporder): Likwise.
>>   * symbol-summary.h (symtab_insertion): Use cgraph_node::uid
>>   instead of summary_uid.
>>   (symtab_removal): Likewise.
>>   (symtab_duplication): Likewise.
>>
>> gcc/lto/ChangeLog:
>>
>> 2018-05-16  Martin Liska  
>>
>>   * lto-partition.c (lto_balanced_map): Use cgraph_node::uid
>>   instead of summary_uid.
>
> I am still now convinced that competely moving from arrays made dense by
> uid recyclic to hash tables is performance-wise smart idea, but current
> uid is not working very well for this purpose - most summaries we have
> are only for definitions so we want something like definition uid.
>
> In general it seems bad that we allocate same memory for object with 
> definition
> and external symbol. Something I planned to change but did not get to do that 
> yet.
>
> So the patch is OK. With new abstraction we can always re-invent dense uids 
> for
> this purpose later.
>
> Honza


Hi!

This patch broke the GCC build:
/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:
In function ‘void remove_cgraph_node_from_order(cgraph_node*, void*)’:
/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1646:
warning: ‘>>’ operator will be treated as two right angle brackets in
C++0x
/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1646:
warning: suggest parentheses around ‘>>’ expression
/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1646:
error: ‘removed_nodes’ was not declared in this scope
/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1646:
error: ‘*’ cannot appear in a constant-expression
/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1646:
warning: ‘>>’ operator will be treated as two right angle brackets in
C++0x
/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1646:
warning: suggest parentheses around ‘>>’ expression
/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1646:
error: ‘*’ cannot appear in a constant-expression
/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1646:
error: template argument 3 is invalid
/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1646:
error: template argument 1 is invalid
/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1646:
error: template argument 2 is invalid
/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1646:
error: an assignment cannot appear in a constant-expression
/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1646:
error: template argument 3 is invalid
/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1646:
error: template argument 1 is invalid
/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1646:
error: template argument 2 is invalid
/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:
In function ‘void do_per_function_toporder(void (*)(function*, void*),
void*)’:
/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1664:
warning: ‘>>’ operator will be treated as two right angle brackets in
C++0x
/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1664:
warning: suggest parentheses around ‘>>’ expression
/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1664:
error: ‘removed_nodes’ was not declared in this scope
/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1664:
error: template argument 3 is invalid
/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1664:
error: template argument 1 is invalid
/tmp/9400570_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1664:
error: template argument 2 is invalid
make[2]: *** [passes.o] Error 1


Re: [PATCH 09/14] Remove cgraph_node::summary_uid and make cgraph_node::uid really unique.

2018-06-07 Thread Jan Hubicka
> 
> gcc/ChangeLog:
> 
> 2018-05-16  Martin Liska  
> 
>   * cgraph.c (cgraph_node::remove): Do not recycle uid.
>   * cgraph.h (symbol_table::release_symbol): Do not pass uid.
>   (symbol_table::allocate_cgraph_symbol): Do not set uid.
>   * passes.c (uid_hash_t): Record removed_nodes by their uids.
>   (remove_cgraph_node_from_order): Use the removed_nodes set.
>   (do_per_function_toporder): Likwise.
>   * symbol-summary.h (symtab_insertion): Use cgraph_node::uid
>   instead of summary_uid.
>   (symtab_removal): Likewise.
>   (symtab_duplication): Likewise.
> 
> gcc/lto/ChangeLog:
> 
> 2018-05-16  Martin Liska  
> 
>   * lto-partition.c (lto_balanced_map): Use cgraph_node::uid
>   instead of summary_uid.

I am still now convinced that competely moving from arrays made dense by
uid recyclic to hash tables is performance-wise smart idea, but current
uid is not working very well for this purpose - most summaries we have
are only for definitions so we want something like definition uid.

In general it seems bad that we allocate same memory for object with definition
and external symbol. Something I planned to change but did not get to do that 
yet.

So the patch is OK. With new abstraction we can always re-invent dense uids for
this purpose later.

Honza


[PATCH 09/14] Remove cgraph_node::summary_uid and make cgraph_node::uid really unique.

2018-05-17 Thread marxin

gcc/ChangeLog:

2018-05-16  Martin Liska  

* cgraph.c (cgraph_node::remove): Do not recycle uid.
* cgraph.h (symbol_table::release_symbol): Do not pass uid.
(symbol_table::allocate_cgraph_symbol): Do not set uid.
* passes.c (uid_hash_t): Record removed_nodes by their uids.
(remove_cgraph_node_from_order): Use the removed_nodes set.
(do_per_function_toporder): Likwise.
* symbol-summary.h (symtab_insertion): Use cgraph_node::uid
instead of summary_uid.
(symtab_removal): Likewise.
(symtab_duplication): Likewise.

gcc/lto/ChangeLog:

2018-05-16  Martin Liska  

* lto-partition.c (lto_balanced_map): Use cgraph_node::uid
instead of summary_uid.
---
 gcc/cgraph.c|  3 +--
 gcc/cgraph.h| 20 ++--
 gcc/lto/lto-partition.c | 26 +++---
 gcc/passes.c| 37 -
 gcc/symbol-summary.h| 18 +-
 5 files changed, 39 insertions(+), 65 deletions(-)

diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index 9a7d54d7cee..a24a5ffe521 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -1805,7 +1805,6 @@ void
 cgraph_node::remove (void)
 {
   cgraph_node *n;
-  int uid = this->uid;
 
   if (symtab->ipa_clones_dump_file && symtab->cloned_nodes.contains (this))
 fprintf (symtab->ipa_clones_dump_file,
@@ -1907,7 +1906,7 @@ cgraph_node::remove (void)
   instrumented_version = NULL;
 }
 
-  symtab->release_symbol (this, uid);
+  symtab->release_symbol (this);
 }
 
 /* Likewise indicate that a node is having address taken.  */
diff --git a/gcc/cgraph.h b/gcc/cgraph.h
index ee7ebb41c24..0e3b1a1785e 100644
--- a/gcc/cgraph.h
+++ b/gcc/cgraph.h
@@ -1396,8 +1396,6 @@ public:
   int count_materialization_scale;
   /* Unique id of the node.  */
   int uid;
-  /* Summary unique id of the node.  */
-  int summary_uid;
   /* ID assigned by the profiling.  */
   unsigned int profile_id;
   /* Time profiler: first run of function.  */
@@ -2020,7 +2018,7 @@ public:
   friend class cgraph_node;
   friend class cgraph_edge;
 
-  symbol_table (): cgraph_max_summary_uid (1)
+  symbol_table (): cgraph_max_uid (1)
   {
   }
 
@@ -2080,9 +2078,8 @@ public:
   /* Allocate new callgraph node and insert it into basic data structures.  */
   cgraph_node *create_empty (void);
 
-  /* Release a callgraph NODE with UID and put in to the list
- of free nodes.  */
-  void release_symbol (cgraph_node *node, int uid);
+  /* Release a callgraph NODE.  */
+  void release_symbol (cgraph_node *node);
 
   /* Output all variables enqueued to be assembled.  */
   bool output_variables (void);
@@ -2230,7 +2227,6 @@ public:
 
   int cgraph_count;
   int cgraph_max_uid;
-  int cgraph_max_summary_uid;
 
   int edges_count;
   int edges_max_uid;
@@ -2598,7 +2594,7 @@ symbol_table::unregister (symtab_node *node)
 /* Release a callgraph NODE with UID and put in to the list of free nodes.  */
 
 inline void
-symbol_table::release_symbol (cgraph_node *node, int uid)
+symbol_table::release_symbol (cgraph_node *node)
 {
   cgraph_count--;
 
@@ -2606,7 +2602,6 @@ symbol_table::release_symbol (cgraph_node *node, int uid)
  list.  */
   memset (node, 0, sizeof (*node));
   node->type = SYMTAB_FUNCTION;
-  node->uid = uid;
   SET_NEXT_FREE_NODE (node, free_nodes);
   free_nodes = node;
 }
@@ -2624,12 +2619,9 @@ symbol_table::allocate_cgraph_symbol (void)
   free_nodes = NEXT_FREE_NODE (node);
 }
   else
-{
-  node = ggc_cleared_alloc ();
-  node->uid = cgraph_max_uid++;
-}
+node = ggc_cleared_alloc ();
 
-  node->summary_uid = cgraph_max_summary_uid++;
+  node->uid = cgraph_max_uid++;
   return node;
 }
 
diff --git a/gcc/lto/lto-partition.c b/gcc/lto/lto-partition.c
index 76086a2ba2e..9049a372256 100644
--- a/gcc/lto/lto-partition.c
+++ b/gcc/lto/lto-partition.c
@@ -506,12 +506,10 @@ account_reference_p (symtab_node *n1, symtab_node *n2)
 void
 lto_balanced_map (int n_lto_partitions, int max_partition_size)
 {
-  int n_nodes = 0;
   int n_varpool_nodes = 0, varpool_pos = 0, best_varpool_pos = 0;
-  struct cgraph_node **order = XNEWVEC (cgraph_node *, symtab->cgraph_max_uid);
+  auto_vec  order (symtab->cgraph_count);
   auto_vec noreorder;
   auto_vec varpool_order;
-  int i;
   struct cgraph_node *node;
   int64_t original_total_size, total_size = 0;
   int64_t partition_size;
@@ -519,7 +517,7 @@ lto_balanced_map (int n_lto_partitions, int max_partition_size)
   int last_visited_node = 0;
   varpool_node *vnode;
   int64_t cost = 0, internal = 0;
-  int best_n_nodes = 0, best_i = 0;
+  unsigned int best_n_nodes = 0, best_i = 0;
   int64_t best_cost = -1, best_internal = 0, best_size = 0;
   int npartitions;
   int current_order = -1;
@@ -527,14 +525,14 @@ lto_balanced_map (int n_lto_partitions, int max_partition_size)
 
   FOR_EACH_VARIABLE (vnode)
 gcc_assert (!vnode->aux);
-
+