From: Jakub Jelinek Date: Sat, 5 Jan 2019 11:12:35 +0000 (+0100) Subject: re PR debug/88635 (Assembler error when building with "-g -O2 -m32") X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4a3e7df872be0bb7198fed02746ff5e96ff1d584;p=gcc.git 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 87be8ae512a..e6992b0e982 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +2019-01-05 Jakub Jelinek + + 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 * 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 016d6e3fcb5..5cf876a16a7 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 8d9a3849fa4..0d643dd713d 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 (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 814d846e41a..af59095b05b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,10 +1,11 @@ -2019-01-05 Dominique d'Humieres +2019-01-05 Jakub Jelinek - 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 + PR target/60563 * g++.dg/ext/sync-4.C: Add dg-xfail-run-if for darwin. 2019-01-04 Martin Sebor 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 00000000000..02c53d1001a --- /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 (""); +}