From f6742350318da0dd5403bed055bd6d17b365aaf5 Mon Sep 17 00:00:00 2001 From: jakub Date: Wed, 14 Nov 2018 12:38:20 +0000 Subject: [PATCH] PR other/88007 * c-common.c (parse_optimize_options): Allocate option string from opts_obstack rather than as GC memory. Move the allocation after warning for invalid option. * gcc.dg/pr88007.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@266141 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/c-family/ChangeLog | 7 +++++++ gcc/c-family/c-common.c | 5 +++-- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/gcc.dg/pr88007.c | 15 +++++++++++++++ 4 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr88007.c diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 4b8d8228dfa..94b823fe398 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,10 @@ +2018-11-14 Jakub Jelinek + + PR other/88007 + * c-common.c (parse_optimize_options): Allocate option string from + opts_obstack rather than as GC memory. Move the allocation after + warning for invalid option. + 2018-11-13 David Malcolm * c-common.c (c_get_substring_location): Update for renaming of diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 9c2f18609ac..cd88f3a5ed3 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -5523,8 +5523,6 @@ parse_optimize_options (tree args, bool attr_p) next_p = NULL; } - r = q = (char *) ggc_alloc_atomic (len2 + 3); - /* If the user supplied -Oxxx or -fxxx, only allow -Oxxx or -fxxx options. */ if (*p == '-' && p[1] != 'O' && p[1] != 'f') @@ -5539,6 +5537,9 @@ parse_optimize_options (tree args, bool attr_p) continue; } + /* Can't use GC memory here, see PR88007. */ + r = q = XOBNEWVEC (&opts_obstack, char, len2 + 3); + if (*p != '-') { *r++ = '-'; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d8897fa5dbe..5f58860714d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2018-11-14 Jakub Jelinek + PR other/88007 + * gcc.dg/pr88007.c: New test. + PR rtl-optimization/87817 * gcc.target/i386/bmi2-bzhi-3.c (main): Add a couple of new tests. diff --git a/gcc/testsuite/gcc.dg/pr88007.c b/gcc/testsuite/gcc.dg/pr88007.c new file mode 100644 index 00000000000..4f56ba49a35 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr88007.c @@ -0,0 +1,15 @@ +/* PR other/88007 */ +/* { dg-do compile } */ +/* { dg-options "--param ggc-min-expand=3 --param ggc-min-heapsize=1024" } */ +/* { dg-skip-if "no code alignment > 2" { "pdp11-*-*" } } */ + +void bar (void); + +__attribute__((optimize ("align-loops=16", "align-jumps=16", + "align-labels=16", "align-functions=16"))) +void +foo (void) +{ + for (int i = 0; i < 1024; ++i) + bar (); +} -- 2.11.4.GIT