From 386a83c170348577379c4def0bc41090be230333 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 5 Mar 2019 10:03:50 +0100 Subject: [PATCH] re PR bootstrap/89560 (ICE In function 'rtx_def* gen_vec_extract_lo_v64qi(rtx, rtx)') PR bootstrap/89560 * fold-const.c (fold_checksum_tree): Don't use fixed size buffer, instead alloca it only when needed with the needed size. * g++.dg/other/pr89560.C: New test. From-SVN: r269386 --- gcc/ChangeLog | 4 ++++ gcc/fold-const.c | 28 +++++++++++++++++----------- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/other/pr89560.C | 13 +++++++++++++ 4 files changed, 37 insertions(+), 11 deletions(-) create mode 100644 gcc/testsuite/g++.dg/other/pr89560.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 54c736b340b..788ce54da7f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,9 @@ 2019-03-05 Jakub Jelinek + PR bootstrap/89560 + * fold-const.c (fold_checksum_tree): Don't use fixed size buffer, + instead alloca it only when needed with the needed size. + PR tree-optimization/89570 * match.pd (vec_cond into cond_op simplification): Guard with vectorized_internal_fn_supported_p test and #if GIMPLE. diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 8989fc7827e..571566aa6bc 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -12112,7 +12112,7 @@ fold_checksum_tree (const_tree expr, struct md5_ctx *ctx, { const tree_node **slot; enum tree_code code; - union tree_node buf; + union tree_node *buf; int i, len; recursive_label: @@ -12127,11 +12127,13 @@ fold_checksum_tree (const_tree expr, struct md5_ctx *ctx, && HAS_DECL_ASSEMBLER_NAME_P (expr)) { /* Allow DECL_ASSEMBLER_NAME and symtab_node to be modified. */ - memcpy ((char *) &buf, expr, tree_size (expr)); - SET_DECL_ASSEMBLER_NAME ((tree)&buf, NULL); - buf.decl_with_vis.symtab_node = NULL; - buf.base.nowarning_flag = 0; - expr = (tree) &buf; + size_t sz = tree_size (expr); + buf = XALLOCAVAR (union tree_node, sz); + memcpy ((char *) buf, expr, sz); + SET_DECL_ASSEMBLER_NAME ((tree) buf, NULL); + buf->decl_with_vis.symtab_node = NULL; + buf->base.nowarning_flag = 0; + expr = (tree) buf; } else if (TREE_CODE_CLASS (code) == tcc_type && (TYPE_POINTER_TO (expr) @@ -12143,8 +12145,10 @@ fold_checksum_tree (const_tree expr, struct md5_ctx *ctx, { /* Allow these fields to be modified. */ tree tmp; - memcpy ((char *) &buf, expr, tree_size (expr)); - expr = tmp = (tree) &buf; + size_t sz = tree_size (expr); + buf = XALLOCAVAR (union tree_node, sz); + memcpy ((char *) buf, expr, sz); + expr = tmp = (tree) buf; TYPE_CONTAINS_PLACEHOLDER_INTERNAL (tmp) = 0; TYPE_POINTER_TO (tmp) = NULL; TYPE_REFERENCE_TO (tmp) = NULL; @@ -12160,9 +12164,11 @@ fold_checksum_tree (const_tree expr, struct md5_ctx *ctx, { /* Allow TREE_NO_WARNING to be set. Perhaps we shouldn't allow that and change builtins.c etc. instead - see PR89543. */ - memcpy ((char *) &buf, expr, tree_size (expr)); - buf.base.nowarning_flag = 0; - expr = (tree) &buf; + size_t sz = tree_size (expr); + buf = XALLOCAVAR (union tree_node, sz); + memcpy ((char *) buf, expr, sz); + buf->base.nowarning_flag = 0; + expr = (tree) buf; } md5_process_bytes (expr, tree_size (expr), ctx); if (CODE_CONTAINS_STRUCT (code, TS_TYPED)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f9d770c96f1..b9bfeced886 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2019-03-05 Jakub Jelinek + PR bootstrap/89560 + * g++.dg/other/pr89560.C: New test. + PR tree-optimization/89570 * gcc.dg/pr89570.c: New test. diff --git a/gcc/testsuite/g++.dg/other/pr89560.C b/gcc/testsuite/g++.dg/other/pr89560.C new file mode 100644 index 00000000000..deb983969d7 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr89560.C @@ -0,0 +1,13 @@ +// PR bootstrap/89560 +// { dg-do compile } + +#define TEN(x) x##0, x##1, x##2, x##3, x##4, x##5, x##6, x##7, x##8, x##9, +#define HUNDRED(x) TEN(x##0) TEN(x##1) TEN(x##2) TEN(x##3) TEN(x##4) \ + TEN(x##5) TEN(x##6) TEN(x##7) TEN(x##8) TEN(x##9) +int foo (int, ...); + +int +bar () +{ + return (foo (HUNDRED (1) 0)); +} -- 2.30.2