diff mbox series

Make dwarf2out punt for MODE_VECTOR_BOOL

Message ID mptwob44d8e.fsf@arm.com
State New
Headers show
Series Make dwarf2out punt for MODE_VECTOR_BOOL | expand

Commit Message

Richard Sandiford Dec. 10, 2019, 11:44 a.m. UTC
The dwarf2 handling of vector constants currently divides the vector
into a length (number of elements) and byte element size.  This doesn't
work well for MODE_VECTOR_BOOL, where several elements are packed into
the same byte.

We should probably add a way of encoding this in future, but for now
the safest thing is to punt, like we already do for variable-length
vectors.

Tested on aarch64-linux-gnu and x86_64-linux-gnu.  OK to install?

Richard


2019-12-10  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
	* dwarf2out.c (loc_descriptor): Punt for MODE_VECTOR_BOOL.
	(add_const_value_attribute): Likewise.

gcc/testsuite/
	* gcc.target/aarch64/sve/acle/general/debug_4.c: New test.

Comments

Richard Biener Dec. 10, 2019, 12:14 p.m. UTC | #1
On December 10, 2019 12:44:01 PM GMT+01:00, Richard Sandiford <richard.sandiford@arm.com> wrote:
>The dwarf2 handling of vector constants currently divides the vector
>into a length (number of elements) and byte element size.  This doesn't
>work well for MODE_VECTOR_BOOL, where several elements are packed into
>the same byte.
>
>We should probably add a way of encoding this in future, but for now
>the safest thing is to punt, like we already do for variable-length
>vectors.
>
>Tested on aarch64-linux-gnu and x86_64-linux-gnu.  OK to install?

Ok. 

Richard. 

>Richard
>
>
>2019-12-10  Richard Sandiford  <richard.sandiford@arm.com>
>
>gcc/
>	* dwarf2out.c (loc_descriptor): Punt for MODE_VECTOR_BOOL.
>	(add_const_value_attribute): Likewise.
>
>gcc/testsuite/
>	* gcc.target/aarch64/sve/acle/general/debug_4.c: New test.
>
>Index: gcc/dwarf2out.c
>===================================================================
>--- gcc/dwarf2out.c	2019-11-29 13:04:13.978672241 +0000
>+++ gcc/dwarf2out.c	2019-12-10 11:43:15.560875505 +0000
>@@ -16763,7 +16763,12 @@ loc_descriptor (rtx rtl, machine_mode mo
>       if (mode == VOIDmode)
> 	mode = GET_MODE (rtl);
> 
>-      if (mode != VOIDmode && (dwarf_version >= 4 || !dwarf_strict))
>+      if (mode != VOIDmode
>+	  /* The combination of a length and byte elt_size doesn't extend
>+	     naturally to boolean vectors, where several elements are packed
>+	     into the same byte.  */
>+	  && GET_MODE_CLASS (mode) != MODE_VECTOR_BOOL
>+	  && (dwarf_version >= 4 || !dwarf_strict))
> 	{
> 	  unsigned int length;
> 	  if (!CONST_VECTOR_NUNITS (rtl).is_constant (&length))
>@@ -19622,6 +19627,12 @@ add_const_value_attribute (dw_die_ref di
> 	  return false;
> 
> 	machine_mode mode = GET_MODE (rtl);
>+	/* The combination of a length and byte elt_size doesn't extend
>+	   naturally to boolean vectors, where several elements are packed
>+	   into the same byte.  */
>+	if (GET_MODE_CLASS (mode) == MODE_VECTOR_BOOL)
>+	  return false;
>+
> 	unsigned int elt_size = GET_MODE_UNIT_SIZE (mode);
> 	unsigned char *array
> 	  = ggc_vec_alloc<unsigned char> (length * elt_size);
>Index: gcc/testsuite/gcc.target/aarch64/sve/acle/general/debug_4.c
>===================================================================
>--- /dev/null	2019-09-17 11:41:18.176664108 +0100
>+++
>gcc/testsuite/gcc.target/aarch64/sve/acle/general/debug_4.c	2019-12-10
>11:43:15.572875421 +0000
>@@ -0,0 +1,16 @@
>+/* { dg-options "-O -g -msve-vector-bits=512" } */
>+
>+#include <arm_sve.h>
>+
>+void __attribute__((noipa))
>+g (volatile int *x, svbool_t pg)
>+{
>+  *x = 1;
>+}
>+
>+void
>+f (volatile int *x)
>+{
>+  svbool_t pg = svorr_z (svpfalse (), svpfalse (), svpfalse ());
>+  g (x, pg);
>+}
diff mbox series

Patch

Index: gcc/dwarf2out.c
===================================================================
--- gcc/dwarf2out.c	2019-11-29 13:04:13.978672241 +0000
+++ gcc/dwarf2out.c	2019-12-10 11:43:15.560875505 +0000
@@ -16763,7 +16763,12 @@  loc_descriptor (rtx rtl, machine_mode mo
       if (mode == VOIDmode)
 	mode = GET_MODE (rtl);
 
-      if (mode != VOIDmode && (dwarf_version >= 4 || !dwarf_strict))
+      if (mode != VOIDmode
+	  /* The combination of a length and byte elt_size doesn't extend
+	     naturally to boolean vectors, where several elements are packed
+	     into the same byte.  */
+	  && GET_MODE_CLASS (mode) != MODE_VECTOR_BOOL
+	  && (dwarf_version >= 4 || !dwarf_strict))
 	{
 	  unsigned int length;
 	  if (!CONST_VECTOR_NUNITS (rtl).is_constant (&length))
@@ -19622,6 +19627,12 @@  add_const_value_attribute (dw_die_ref di
 	  return false;
 
 	machine_mode mode = GET_MODE (rtl);
+	/* The combination of a length and byte elt_size doesn't extend
+	   naturally to boolean vectors, where several elements are packed
+	   into the same byte.  */
+	if (GET_MODE_CLASS (mode) == MODE_VECTOR_BOOL)
+	  return false;
+
 	unsigned int elt_size = GET_MODE_UNIT_SIZE (mode);
 	unsigned char *array
 	  = ggc_vec_alloc<unsigned char> (length * elt_size);
Index: gcc/testsuite/gcc.target/aarch64/sve/acle/general/debug_4.c
===================================================================
--- /dev/null	2019-09-17 11:41:18.176664108 +0100
+++ gcc/testsuite/gcc.target/aarch64/sve/acle/general/debug_4.c	2019-12-10 11:43:15.572875421 +0000
@@ -0,0 +1,16 @@ 
+/* { dg-options "-O -g -msve-vector-bits=512" } */
+
+#include <arm_sve.h>
+
+void __attribute__((noipa))
+g (volatile int *x, svbool_t pg)
+{
+  *x = 1;
+}
+
+void
+f (volatile int *x)
+{
+  svbool_t pg = svorr_z (svpfalse (), svpfalse (), svpfalse ());
+  g (x, pg);
+}