diff mbox

PATCH: Properly handle arg_pointer and frame_pointer in DWARF output

Message ID 20120428151113.GA5935@intel.com
State New
Headers show

Commit Message

H.J. Lu April 28, 2012, 3:11 p.m. UTC
Hi,

arg_pointer and frame_pointer are handled as special cases in
based_loc_descr.

(plus:DI (reg/f:DI 16 argp)
    (const_int -20 [0xffffffffffffffec]))

is perfectly valid when Pmode == DImode and DWARF2_ADDR_SIZE is 32bit
with ptr_mode == SImode.  This patch fixes ICE on the 2 testcases here.
OK for trunk?

Thanks. 


H.J.
----
gcc/

2012-04-06  H.J. Lu  <hongjiu.lu@intel.com>

	PR debug/52857
	* dwarf2out.c (mem_loc_descriptor): Allow arg_pointer_rtx and
	frame_pointer_rtx for based_loc_descr.

gcc/testsuite/

2012-04-06  H.J. Lu  <hongjiu.lu@intel.com>

	PR debug/52857
	* gcc.target/i386/pr52857-1.c: New.
	* gcc.target/i386/pr52857-2.c: Likewise.

Comments

Jakub Jelinek Aug. 24, 2012, 9:22 a.m. UTC | #1
On Sat, Apr 28, 2012 at 08:11:14AM -0700, H.J. Lu wrote:
> arg_pointer and frame_pointer are handled as special cases in
> based_loc_descr.
> 
> (plus:DI (reg/f:DI 16 argp)
>     (const_int -20 [0xffffffffffffffec]))
> 
> is perfectly valid when Pmode == DImode and DWARF2_ADDR_SIZE is 32bit
> with ptr_mode == SImode.  This patch fixes ICE on the 2 testcases here.
> OK for trunk?

Ok.  I must say I don't like these ugly hacks for wider Pmode than
DWARF2_ADDR_SIZE very much, and they keep being added in lots of places,
but I can live with this change.

> 2012-04-06  H.J. Lu  <hongjiu.lu@intel.com>
> 
> 	PR debug/52857
> 	* dwarf2out.c (mem_loc_descriptor): Allow arg_pointer_rtx and
> 	frame_pointer_rtx for based_loc_descr.
> 
> gcc/testsuite/
> 
> 2012-04-06  H.J. Lu  <hongjiu.lu@intel.com>
> 
> 	PR debug/52857
> 	* gcc.target/i386/pr52857-1.c: New.
> 	* gcc.target/i386/pr52857-2.c: Likewise.
> 
> diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
> index ca88fc5..515a824 100644
> --- a/gcc/dwarf2out.c
> +++ b/gcc/dwarf2out.c
> @@ -11655,6 +11657,8 @@ mem_loc_descriptor (rtx rtl, enum machine_mode mode,
>      case REG:
>        if (GET_MODE_CLASS (mode) != MODE_INT
>  	  || (GET_MODE_SIZE (mode) > DWARF2_ADDR_SIZE
> +	      && rtl != arg_pointer_rtx
> +	      && rtl != frame_pointer_rtx
>  #ifdef POINTERS_EXTEND_UNSIGNED
>  	      && (mode != Pmode || mem_mode == VOIDmode)
>  #endif
> @@ -11927,7 +11931,9 @@ mem_loc_descriptor (rtx rtl, enum machine_mode mode,
>      case PLUS:
>      plus:
>        if (is_based_loc (rtl)
> -	  && GET_MODE_SIZE (mode) <= DWARF2_ADDR_SIZE
> +	  && (GET_MODE_SIZE (mode) <= DWARF2_ADDR_SIZE
> +	      || XEXP (rtl, 0) == arg_pointer_rtx
> +	      || XEXP (rtl, 0) == frame_pointer_rtx)
>  	  && GET_MODE_CLASS (mode) == MODE_INT)
>  	mem_loc_result = based_loc_descr (XEXP (rtl, 0),
>  					  INTVAL (XEXP (rtl, 1)),
> diff --git a/gcc/testsuite/gcc.target/i386/pr52857-1.c b/gcc/testsuite/gcc.target/i386/pr52857-1.c
> new file mode 100644
> index 0000000..16fd78f
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/i386/pr52857-1.c
> @@ -0,0 +1,10 @@
> +/* { dg-do compile { target { ! { ia32 } } } } */
> +/* { dg-options "-g -O -mx32 -maddress-mode=long" } */
> +
> +extern void get_BID128 (int *);
> +void 
> +__bid128_div (void)
> +{
> +  int res;
> +  get_BID128 (&res);
> +}
> diff --git a/gcc/testsuite/gcc.target/i386/pr52857-2.c b/gcc/testsuite/gcc.target/i386/pr52857-2.c
> new file mode 100644
> index 0000000..879240a
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/i386/pr52857-2.c
> @@ -0,0 +1,8 @@
> +/* { dg-do compile { target { ! { ia32 } } } } */
> +/* { dg-options "-g -O -mx32 -maddress-mode=long" } */
> +
> +void uw_init_context_1 (void *);
> +void _Unwind_ForcedUnwind (void)
> +{
> +  uw_init_context_1 (__builtin_dwarf_cfa ());
> +}

	Jakub
diff mbox

Patch

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index ca88fc5..515a824 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -11655,6 +11657,8 @@  mem_loc_descriptor (rtx rtl, enum machine_mode mode,
     case REG:
       if (GET_MODE_CLASS (mode) != MODE_INT
 	  || (GET_MODE_SIZE (mode) > DWARF2_ADDR_SIZE
+	      && rtl != arg_pointer_rtx
+	      && rtl != frame_pointer_rtx
 #ifdef POINTERS_EXTEND_UNSIGNED
 	      && (mode != Pmode || mem_mode == VOIDmode)
 #endif
@@ -11927,7 +11931,9 @@  mem_loc_descriptor (rtx rtl, enum machine_mode mode,
     case PLUS:
     plus:
       if (is_based_loc (rtl)
-	  && GET_MODE_SIZE (mode) <= DWARF2_ADDR_SIZE
+	  && (GET_MODE_SIZE (mode) <= DWARF2_ADDR_SIZE
+	      || XEXP (rtl, 0) == arg_pointer_rtx
+	      || XEXP (rtl, 0) == frame_pointer_rtx)
 	  && GET_MODE_CLASS (mode) == MODE_INT)
 	mem_loc_result = based_loc_descr (XEXP (rtl, 0),
 					  INTVAL (XEXP (rtl, 1)),
diff --git a/gcc/testsuite/gcc.target/i386/pr52857-1.c b/gcc/testsuite/gcc.target/i386/pr52857-1.c
new file mode 100644
index 0000000..16fd78f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr52857-1.c
@@ -0,0 +1,10 @@ 
+/* { dg-do compile { target { ! { ia32 } } } } */
+/* { dg-options "-g -O -mx32 -maddress-mode=long" } */
+
+extern void get_BID128 (int *);
+void 
+__bid128_div (void)
+{
+  int res;
+  get_BID128 (&res);
+}
diff --git a/gcc/testsuite/gcc.target/i386/pr52857-2.c b/gcc/testsuite/gcc.target/i386/pr52857-2.c
new file mode 100644
index 0000000..879240a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr52857-2.c
@@ -0,0 +1,8 @@ 
+/* { dg-do compile { target { ! { ia32 } } } } */
+/* { dg-options "-g -O -mx32 -maddress-mode=long" } */
+
+void uw_init_context_1 (void *);
+void _Unwind_ForcedUnwind (void)
+{
+  uw_init_context_1 (__builtin_dwarf_cfa ());
+}