summaryrefslogtreecommitdiff
path: root/gcc/ira-conflicts.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ira-conflicts.c')
-rw-r--r--gcc/ira-conflicts.c65
1 files changed, 47 insertions, 18 deletions
diff --git a/gcc/ira-conflicts.c b/gcc/ira-conflicts.c
index ff116b5da8a..244d3bc9b3e 100644
--- a/gcc/ira-conflicts.c
+++ b/gcc/ira-conflicts.c
@@ -60,8 +60,10 @@ static IRA_INT_TYPE **conflicts;
-/* Build allocno conflict table by processing allocno live ranges. */
-static void
+/* Build allocno conflict table by processing allocno live ranges.
+ Return true if the table was built. The table is not built if it
+ is too big. */
+static bool
build_conflict_bit_table (void)
{
int i, num, id, allocated_words_num, conflict_bit_vec_words_num;
@@ -74,6 +76,26 @@ build_conflict_bit_table (void)
int allocno_set_words;
allocno_set_words = (ira_allocnos_num + IRA_INT_BITS - 1) / IRA_INT_BITS;
+ allocated_words_num = 0;
+ FOR_EACH_ALLOCNO (allocno, ai)
+ {
+ if (ALLOCNO_MAX (allocno) < ALLOCNO_MIN (allocno))
+ continue;
+ conflict_bit_vec_words_num
+ = ((ALLOCNO_MAX (allocno) - ALLOCNO_MIN (allocno) + IRA_INT_BITS)
+ / IRA_INT_BITS);
+ allocated_words_num += conflict_bit_vec_words_num;
+ if ((unsigned long long) allocated_words_num * sizeof (IRA_INT_TYPE)
+ > (unsigned long long) IRA_MAX_CONFLICT_TABLE_SIZE * 1024 * 1024)
+ {
+ if (internal_flag_ira_verbose > 0 && ira_dump_file != NULL)
+ fprintf
+ (ira_dump_file,
+ "+++Conflict table will be too big(>%dMB) -- don't use it\n",
+ IRA_MAX_CONFLICT_TABLE_SIZE);
+ return false;
+ }
+ }
allocnos_live = sparseset_alloc (ira_allocnos_num);
conflicts = (IRA_INT_TYPE **) ira_allocate (sizeof (IRA_INT_TYPE *)
* ira_allocnos_num);
@@ -134,6 +156,7 @@ build_conflict_bit_table (void)
sparseset_clear_bit (allocnos_live, ALLOCNO_NUM (r->allocno));
}
sparseset_free (allocnos_live);
+ return true;
}
@@ -743,29 +766,34 @@ ira_build_conflicts (void)
ira_allocno_iterator ai;
HARD_REG_SET temp_hard_reg_set;
- if (optimize)
+ if (ira_conflicts_p)
{
- build_conflict_bit_table ();
- build_conflicts ();
- ira_traverse_loop_tree (true, ira_loop_tree_root, NULL, add_copies);
- /* We need finished conflict table for the subsequent call. */
- if (flag_ira_region == IRA_REGION_ALL
- || flag_ira_region == IRA_REGION_MIXED)
- propagate_copies ();
- /* Now we can free memory for the conflict table (see function
- build_allocno_conflicts for details). */
- FOR_EACH_ALLOCNO (a, ai)
+ ira_conflicts_p = build_conflict_bit_table ();
+ if (ira_conflicts_p)
{
- if (ALLOCNO_CONFLICT_ALLOCNO_ARRAY (a) != conflicts[ALLOCNO_NUM (a)])
- ira_free (conflicts[ALLOCNO_NUM (a)]);
+ build_conflicts ();
+ ira_traverse_loop_tree (true, ira_loop_tree_root, NULL, add_copies);
+ /* We need finished conflict table for the subsequent call. */
+ if (flag_ira_region == IRA_REGION_ALL
+ || flag_ira_region == IRA_REGION_MIXED)
+ propagate_copies ();
+ /* Now we can free memory for the conflict table (see function
+ build_allocno_conflicts for details). */
+ FOR_EACH_ALLOCNO (a, ai)
+ {
+ if (ALLOCNO_CONFLICT_ALLOCNO_ARRAY (a)
+ != conflicts[ALLOCNO_NUM (a)])
+ ira_free (conflicts[ALLOCNO_NUM (a)]);
+ }
+ ira_free (conflicts);
}
- ira_free (conflicts);
}
if (! CLASS_LIKELY_SPILLED_P (BASE_REG_CLASS))
CLEAR_HARD_REG_SET (temp_hard_reg_set);
else
{
- COPY_HARD_REG_SET (temp_hard_reg_set, reg_class_contents[BASE_REG_CLASS]);
+ COPY_HARD_REG_SET (temp_hard_reg_set,
+ reg_class_contents[BASE_REG_CLASS]);
AND_COMPL_HARD_REG_SET (temp_hard_reg_set, ira_no_alloc_regs);
AND_HARD_REG_SET (temp_hard_reg_set, call_used_reg_set);
}
@@ -796,6 +824,7 @@ ira_build_conflicts (void)
}
}
}
- if (optimize && internal_flag_ira_verbose > 2 && ira_dump_file != NULL)
+ if (optimize && ira_conflicts_p
+ && internal_flag_ira_verbose > 2 && ira_dump_file != NULL)
print_conflicts (ira_dump_file, false);
}