aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2017-11-09 09:54:19 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2017-11-09 09:54:19 +0100
commit6bc322a11bec51aceb463fb2336198645dca993f (patch)
tree8ca86eec5904dd459014b877b1bc6b7d7aa43bd9
parente7c77c4f12100602e078cee454b8d0e7433c2660 (diff)
downloadgcc-6bc322a11bec51aceb463fb2336198645dca993f.zip
gcc-6bc322a11bec51aceb463fb2336198645dca993f.tar.gz
gcc-6bc322a11bec51aceb463fb2336198645dca993f.tar.bz2
re PR debug/82837 (ICE in output_operand: invalid expression as operand)
PR debug/82837 * dwarf2out.c (const_ok_for_output_1): Reject NEG in addition to NOT. (mem_loc_descriptor): Handle (const (neg (...))) as (neg (const (...))) and similarly for not instead of neg. * gcc.dg/debug/dwarf2/pr82837.c: New test. From-SVN: r254561
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/dwarf2out.c38
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/debug/dwarf2/pr82837.c29
4 files changed, 74 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 442e565..982b43b 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2017-11-09 Jakub Jelinek <jakub@redhat.com>
+
+ PR debug/82837
+ * dwarf2out.c (const_ok_for_output_1): Reject NEG in addition to NOT.
+ (mem_loc_descriptor): Handle (const (neg (...))) as (neg (const (...)))
+ and similarly for not instead of neg.
+
2017-11-08 Andi Kleen <ak@linux.intel.com>
* config/i386/i386.opt: Add -mforce-indirect-call.
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index f396997..b8f4e48 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -13783,10 +13783,14 @@ const_ok_for_output_1 (rtx rtl)
We should really identify / validate expressions
enclosed in CONST that can be handled by assemblers on various
targets and only handle legitimate cases here. */
- if (GET_CODE (rtl) != SYMBOL_REF)
+ switch (GET_CODE (rtl))
{
- if (GET_CODE (rtl) == NOT)
- return false;
+ case SYMBOL_REF:
+ break;
+ case NOT:
+ case NEG:
+ return false;
+ default:
return true;
}
@@ -14959,8 +14963,32 @@ mem_loc_descriptor (rtx rtl, machine_mode mode,
if (!const_ok_for_output (rtl))
{
if (GET_CODE (rtl) == CONST)
- mem_loc_result = mem_loc_descriptor (XEXP (rtl, 0), int_mode,
- mem_mode, initialized);
+ switch (GET_CODE (XEXP (rtl, 0)))
+ {
+ case NOT:
+ op = DW_OP_not;
+ goto try_const_unop;
+ case NEG:
+ op = DW_OP_neg;
+ goto try_const_unop;
+ try_const_unop:
+ rtx arg;
+ arg = XEXP (XEXP (rtl, 0), 0);
+ if (!CONSTANT_P (arg))
+ arg = gen_rtx_CONST (int_mode, arg);
+ op0 = mem_loc_descriptor (arg, int_mode, mem_mode,
+ initialized);
+ if (op0)
+ {
+ mem_loc_result = op0;
+ add_loc_descr (&mem_loc_result, new_loc_descr (op, 0, 0));
+ }
+ break;
+ default:
+ mem_loc_result = mem_loc_descriptor (XEXP (rtl, 0), int_mode,
+ mem_mode, initialized);
+ break;
+ }
break;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 73d5f87..cb577bf 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2017-11-09 Jakub Jelinek <jakub@redhat.com>
+
+ PR debug/82837
+ * gcc.dg/debug/dwarf2/pr82837.c: New test.
+
2017-11-08 Andi Kleen <ak@linux.intel.com>
* gcc.target/i386/force-indirect-call-1.c: New test.
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/pr82837.c b/gcc/testsuite/gcc.dg/debug/dwarf2/pr82837.c
new file mode 100644
index 0000000..743fb28
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/pr82837.c
@@ -0,0 +1,29 @@
+/* PR debug/82837 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -g" } */
+/* { dg-additional-options "-march=athlon" { target ia32 } } */
+/* { dg-additional-options "-fPIE" { target pie } } */
+
+static char b[100];
+static int *c;
+char *e;
+void a(char *f, char *i) {
+ int d = __builtin_object_size(f, 1);
+ __builtin___strcpy_chk(f, i, d);
+}
+void g(void) {
+ int h;
+ switch (*c) {
+ case 8:
+ e = "swapgs";
+ break;
+ case 9:
+ e = "rdtscp";
+ break;
+ default:
+ return;
+ }
+ h = __builtin_strlen(b);
+ a(b + h - 6, e);
+ c++;
+}