diff options
author | Jakub Jelinek <jakub@redhat.com> | 2019-01-05 12:12:35 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2019-01-05 12:12:35 +0100 |
commit | 4a3e7df872be0bb7198fed02746ff5e96ff1d584 (patch) | |
tree | 97a36f848c0517c5f72bd38b604a7d343cff158b /gcc | |
parent | 46ca1b43ed79cb5627285bee59f15344df18d8d5 (diff) | |
download | gcc-4a3e7df872be0bb7198fed02746ff5e96ff1d584.zip gcc-4a3e7df872be0bb7198fed02746ff5e96ff1d584.tar.gz gcc-4a3e7df872be0bb7198fed02746ff5e96ff1d584.tar.bz2 |
re PR debug/88635 (Assembler error when building with "-g -O2 -m32")
PR debug/88635
* dwarf2out.c (const_ok_for_output_1): Reject MINUS that contains
SYMBOL_REF, CODE_LABEL or UNSPEC in subexpressions of second argument.
Reject PLUS that contains SYMBOL_REF, CODE_LABEL or UNSPEC in
subexpressions of both operands.
(mem_loc_descriptor): Handle UNSPEC if target hook acks it and all the
subrtxes are CONSTANT_P.
* config/i386/i386.c (ix86_const_not_ok_for_debug_p): Revert
2018-11-09 changes.
* gcc.dg/debug/dwarf2/pr88635.c: New test.
From-SVN: r267594
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 12 | ||||
-rw-r--r-- | gcc/config/i386/i386.c | 12 | ||||
-rw-r--r-- | gcc/dwarf2out.c | 64 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/debug/dwarf2/pr88635.c | 24 |
5 files changed, 100 insertions, 19 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 87be8ae..e6992b0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +2019-01-05 Jakub Jelinek <jakub@redhat.com> + + PR debug/88635 + * dwarf2out.c (const_ok_for_output_1): Reject MINUS that contains + SYMBOL_REF, CODE_LABEL or UNSPEC in subexpressions of second argument. + Reject PLUS that contains SYMBOL_REF, CODE_LABEL or UNSPEC in + subexpressions of both operands. + (mem_loc_descriptor): Handle UNSPEC if target hook acks it and all the + subrtxes are CONSTANT_P. + * config/i386/i386.c (ix86_const_not_ok_for_debug_p): Revert + 2018-11-09 changes. + 2019-01-04 Jan Hubicka <hubicka@ucw.cz> * params.def (hot-bb-count-ws-permille): Set to 990. diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 016d6e3..5cf876a 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -17240,18 +17240,6 @@ ix86_const_not_ok_for_debug_p (rtx x) if (SYMBOL_REF_P (x) && strcmp (XSTR (x, 0), GOT_SYMBOL_NAME) == 0) return true; - /* Reject UNSPECs within expressions. We could accept symbol@gotoff - + literal_constant, but that would hardly come up in practice, - and it's not worth the trouble of having to reject that as an - operand to pretty much anything else. */ - if (UNARY_P (x) - && GET_CODE (XEXP (x, 0)) == UNSPEC) - return true; - if (BINARY_P (x) - && (GET_CODE (XEXP (x, 0)) == UNSPEC - || GET_CODE (XEXP (x, 1)) == UNSPEC)) - return true; - return false; } diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 8d9a384..0d643dd 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -14464,6 +14464,41 @@ const_ok_for_output_1 (rtx rtl) case NOT: case NEG: return false; + case PLUS: + { + /* Make sure SYMBOL_REFs/UNSPECs are at most in one of the + operands. */ + subrtx_var_iterator::array_type array; + bool first = false; + FOR_EACH_SUBRTX_VAR (iter, array, XEXP (rtl, 0), ALL) + if (SYMBOL_REF_P (*iter) + || LABEL_P (*iter) + || GET_CODE (*iter) == UNSPEC) + { + first = true; + break; + } + if (!first) + return true; + FOR_EACH_SUBRTX_VAR (iter, array, XEXP (rtl, 1), ALL) + if (SYMBOL_REF_P (*iter) + || LABEL_P (*iter) + || GET_CODE (*iter) == UNSPEC) + return false; + return true; + } + case MINUS: + { + /* Disallow negation of SYMBOL_REFs or UNSPECs when they + appear in the second operand of MINUS. */ + subrtx_var_iterator::array_type array; + FOR_EACH_SUBRTX_VAR (iter, array, XEXP (rtl, 1), ALL) + if (SYMBOL_REF_P (*iter) + || LABEL_P (*iter) + || GET_CODE (*iter) == UNSPEC) + return false; + return true; + } default: return true; } @@ -15607,6 +15642,7 @@ mem_loc_descriptor (rtx rtl, machine_mode mode, pool. */ case CONST: case SYMBOL_REF: + case UNSPEC: if (!is_a <scalar_int_mode> (mode, &int_mode) || (GET_MODE_SIZE (int_mode) > DWARF2_ADDR_SIZE #ifdef POINTERS_EXTEND_UNSIGNED @@ -15614,6 +15650,30 @@ mem_loc_descriptor (rtx rtl, machine_mode mode, #endif )) break; + + if (GET_CODE (rtl) == UNSPEC) + { + /* If delegitimize_address couldn't do anything with the UNSPEC, we + can't express it in the debug info. This can happen e.g. with some + TLS UNSPECs. Allow UNSPECs formerly from CONST that the backend + approves. */ + bool not_ok = false; + subrtx_var_iterator::array_type array; + FOR_EACH_SUBRTX_VAR (iter, array, rtl, ALL) + if ((*iter != rtl && !CONSTANT_P (*iter)) + || !const_ok_for_output_1 (*iter)) + { + not_ok = true; + break; + } + + if (not_ok) + break; + + rtl = gen_rtx_CONST (GET_MODE (rtl), rtl); + goto symref; + } + if (GET_CODE (rtl) == SYMBOL_REF && SYMBOL_REF_TLS_MODEL (rtl) != TLS_MODEL_NONE) { @@ -16282,7 +16342,6 @@ mem_loc_descriptor (rtx rtl, machine_mode mode, case VEC_CONCAT: case VEC_DUPLICATE: case VEC_SERIES: - case UNSPEC: case HIGH: case FMA: case STRICT_LOW_PART: @@ -16291,9 +16350,6 @@ mem_loc_descriptor (rtx rtl, machine_mode mode, case CLRSB: case CLOBBER: case CLOBBER_HIGH: - /* If delegitimize_address couldn't do anything with the UNSPEC, we - can't express it in the debug info. This can happen e.g. with some - TLS UNSPECs. */ break; case CONST_STRING: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 814d846..af59095 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,10 +1,11 @@ -2019-01-05 Dominique d'Humieres <dominiq@gcc.gnu.org> +2019-01-05 Jakub Jelinek <jakub@redhat.com> - PR target/60563 - Missing PR entry in the previous commit. + PR debug/88635 + * gcc.dg/debug/dwarf2/pr88635.c: New test. 2019-01-05 Dominique d'Humieres <dominiq@gcc.gnu.org> + PR target/60563 * g++.dg/ext/sync-4.C: Add dg-xfail-run-if for darwin. 2019-01-04 Martin Sebor <msebor@redhat.com> diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/pr88635.c b/gcc/testsuite/gcc.dg/debug/dwarf2/pr88635.c new file mode 100644 index 0000000..02c53d1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/debug/dwarf2/pr88635.c @@ -0,0 +1,24 @@ +/* PR debug/88635 */ +/* { dg-do assemble } */ +/* { dg-options "-g -O2" } */ +/* { dg-additional-options "-fpie" { target pie } } */ + +static void +foo (char *b) +{ + unsigned c = 0; + --c; + do + if (++*b++ == 0) + break; + while (--c); + if (c == 0) + while (*b++) + ; +} + +void +bar (void) +{ + foo (""); +} |