https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79399

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2017-02-07
                 CC|                            |jakub at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
You would save a lot of pain and even could compile it at -O2 if the generator
generated many, but much smaller, functions, for such sizes it certainly pays
off.
What I see is after allocating ~ 24GB of memory ira-costs.c (init_costs) tries
to allocate 124 * 17380077 bytes, but both values are ints, so the
multiplication result is int too and is negative, while it should have
allocated just slightly over 2GB.  So the following patch should cure this,
though not sure if that is the only problem (and will see if I manage to
compile, have only 32GB in my box).

--- gcc/ira-costs.c.jj  2017-01-16 12:28:35.000000000 +0100
+++ gcc/ira-costs.c     2017-02-07 09:07:00.744696695 +0100
@@ -1704,7 +1704,7 @@ find_costs_and_classes (FILE *dump_file)
                                  process_bb_node_for_costs, NULL);

          memcpy (total_allocno_costs, costs,
-                 max_struct_costs_size * ira_allocnos_num);
+                 (size_t) max_struct_costs_size * ira_allocnos_num);
        }
       else
        {
@@ -2205,7 +2205,7 @@ static void
 init_costs (void)
 {
   init_subregs_of_mode ();
-  costs = (struct costs *) ira_allocate (max_struct_costs_size
+  costs = (struct costs *) ira_allocate ((size_t) max_struct_costs_size
                                         * cost_elements_num);
   pref_buffer = (enum reg_class *) ira_allocate (sizeof (enum reg_class)
                                                 * cost_elements_num);
@@ -2235,8 +2235,9 @@ ira_costs (void)
   allocno_p = true;
   cost_elements_num = ira_allocnos_num;
   init_costs ();
-  total_allocno_costs = (struct costs *) ira_allocate (max_struct_costs_size
-                                                      * ira_allocnos_num);
+  total_allocno_costs
+    = (struct costs *) ira_allocate ((size_t) max_struct_costs_size
+                                    * ira_allocnos_num);
   initiate_regno_cost_classes ();
   calculate_elim_costs_all_insns ();
   find_costs_and_classes (ira_dump_file);

Reply via email to