From 2392baa59e266a320c55d9a2245d70fd97a43075 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 3 Aug 2017 11:43:11 +0200 Subject: [PATCH] re PR driver/81650 (gcc -m32 mishandles -Walloc-size-larger-than=9223372036854775807) PR driver/81650 * calls.c (alloc_max_size): Use HOST_WIDE_INT_UC (10??) instead of 10??LU, perform unit multiplication in wide_int, don't change alloc_object_size_limit if the limit is larger than SSIZE_MAX. * gcc.dg/pr81650.c: New test. From-SVN: r250850 --- gcc/ChangeLog | 6 ++++++ gcc/calls.c | 30 ++++++++++++++++++------------ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr81650.c | 9 +++++++++ 4 files changed, 38 insertions(+), 12 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr81650.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 466afb908b6..f7b620c4d0d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,11 @@ 2017-08-03 Jakub Jelinek + PR driver/81650 + * calls.c (alloc_max_size): Use HOST_WIDE_INT_UC (10??) + instead of 10??LU, perform unit multiplication in wide_int, + don't change alloc_object_size_limit if the limit is larger + than SSIZE_MAX. + PR tree-optimization/81655 PR tree-optimization/81588 * tree-ssa-reassoc.c (optimize_range_tests_var_bound): Handle also diff --git a/gcc/calls.c b/gcc/calls.c index 8a23b50fc66..6405f482e91 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -1222,32 +1222,38 @@ alloc_max_size (void) else if (!strcasecmp (end, "KiB") || strcmp (end, "KB")) unit = 1024; else if (!strcmp (end, "MB")) - unit = 1000LU * 1000; + unit = HOST_WIDE_INT_UC (1000) * 1000; else if (!strcasecmp (end, "MiB")) - unit = 1024LU * 1024; + unit = HOST_WIDE_INT_UC (1024) * 1024; else if (!strcasecmp (end, "GB")) - unit = 1000LU * 1000 * 1000; + unit = HOST_WIDE_INT_UC (1000) * 1000 * 1000; else if (!strcasecmp (end, "GiB")) - unit = 1024LU * 1024 * 1024; + unit = HOST_WIDE_INT_UC (1024) * 1024 * 1024; else if (!strcasecmp (end, "TB")) - unit = 1000LU * 1000 * 1000 * 1000; + unit = HOST_WIDE_INT_UC (1000) * 1000 * 1000 * 1000; else if (!strcasecmp (end, "TiB")) - unit = 1024LU * 1024 * 1024 * 1024; + unit = HOST_WIDE_INT_UC (1024) * 1024 * 1024 * 1024; else if (!strcasecmp (end, "PB")) - unit = 1000LU * 1000 * 1000 * 1000 * 1000; + unit = HOST_WIDE_INT_UC (1000) * 1000 * 1000 * 1000 * 1000; else if (!strcasecmp (end, "PiB")) - unit = 1024LU * 1024 * 1024 * 1024 * 1024; + unit = HOST_WIDE_INT_UC (1024) * 1024 * 1024 * 1024 * 1024; else if (!strcasecmp (end, "EB")) - unit = 1000LU * 1000 * 1000 * 1000 * 1000 * 1000; + unit = HOST_WIDE_INT_UC (1000) * 1000 * 1000 * 1000 * 1000 + * 1000; else if (!strcasecmp (end, "EiB")) - unit = 1024LU * 1024 * 1024 * 1024 * 1024 * 1024; + unit = HOST_WIDE_INT_UC (1024) * 1024 * 1024 * 1024 * 1024 + * 1024; else unit = 0; } if (unit) - alloc_object_size_limit - = build_int_cst (ssizetype, limit * unit); + { + wide_int w = wi::uhwi (limit, HOST_BITS_PER_WIDE_INT + 64); + w *= unit; + if (wi::ltu_p (w, alloc_object_size_limit)) + alloc_object_size_limit = wide_int_to_tree (ssizetype, w); + } } } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 58e1b87c6dc..53829f7e779 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-08-03 Jakub Jelinek + + PR driver/81650 + * gcc.dg/pr81650.c: New test. + 2017-08-03 Paolo Carlini PR c++/71440 diff --git a/gcc/testsuite/gcc.dg/pr81650.c b/gcc/testsuite/gcc.dg/pr81650.c new file mode 100644 index 00000000000..99e84ded30d --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr81650.c @@ -0,0 +1,9 @@ +/* PR driver/81650 */ +/* { dg-do compile } */ +/* { dg-options "-Walloc-size-larger-than=9223372036854775807" } */ + +void * +foo (void) +{ + return __builtin_malloc (5); +} -- 2.30.2