From: Richard Biener Date: Fri, 29 Jan 2021 12:25:49 +0000 (+0100) Subject: rtl-optimization/98863 - fix PRE/CPROP memory usage check X-Git-Tag: releases/gcc-10.3.0~334 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4311ae206da13a9bfdb4245feb400dbee0f528a0;p=thirdparty%2Fgcc.git rtl-optimization/98863 - fix PRE/CPROP memory usage check This fixes overflow of the memory usage estimate in turn failing to disable itself on WRF with LTO, causing a few GBs worth of memory peak. 2021-01-29 Richard Biener PR rtl-optimization/98863 * gcse.c (gcse_or_cprop_is_too_expensive): Use unsigned HOST_WIDE_INT for the memory estimate. (cherry picked from commit cb52e59e33845152cef6f9042a142a246e9447f6) --- diff --git a/gcc/gcse.c b/gcc/gcse.c index 1f1e5a59b74f..b3cb2f4fd52e 100644 --- a/gcc/gcse.c +++ b/gcc/gcse.c @@ -3982,9 +3982,9 @@ update_ld_motion_stores (struct gcse_expr * expr) bool gcse_or_cprop_is_too_expensive (const char *pass) { - int memory_request = (n_basic_blocks_for_fn (cfun) - * SBITMAP_SET_SIZE (max_reg_num ()) - * sizeof (SBITMAP_ELT_TYPE)); + unsigned HOST_WIDE_INT memory_request + = ((unsigned HOST_WIDE_INT)n_basic_blocks_for_fn (cfun) + * SBITMAP_SET_SIZE (max_reg_num ()) * sizeof (SBITMAP_ELT_TYPE)); /* Trying to perform global optimizations on flow graphs which have a high connectivity will take a long time and is unlikely to be @@ -4007,11 +4007,12 @@ gcse_or_cprop_is_too_expensive (const char *pass) /* If allocating memory for the dataflow bitmaps would take up too much storage it's better just to disable the optimization. */ - if (memory_request > param_max_gcse_memory) + if (memory_request > (unsigned HOST_WIDE_INT)param_max_gcse_memory) { warning (OPT_Wdisabled_optimization, "%s: %d basic blocks and %d registers; " - "increase %<--param max-gcse-memory%> above %d", + "increase %<--param max-gcse-memory%> above " + HOST_WIDE_INT_PRINT_UNSIGNED, pass, n_basic_blocks_for_fn (cfun), max_reg_num (), memory_request);