Re: PATCH: PR debug/52857: DW_OP_GNU_regval_type is generated with INVALID_REGNUM

2012-04-25 Thread Richard Henderson
On 04/25/12 06:59, H.J. Lu wrote:
>   PR debug/52857
>   * dwarf2out.c (dbx_reg_number): Assert return value !=
>   INVALID_REGNUM.

Ok.

r~


PATCH: PR debug/52857: DW_OP_GNU_regval_type is generated with INVALID_REGNUM

2012-04-25 Thread H.J. Lu
Hi,

We may generate DW_OP_GNU_regval_type with INVALID_REGNUM.  This patch
adds an assert to make sure that we don't.  OK for trunk?

Thanks.

H.J.
---
2012-04-06  H.J. Lu  

PR debug/52857
* dwarf2out.c (dbx_reg_number): Assert return value !=
INVALID_REGNUM.

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index ca88fc5..515a824 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -10167,7 +10167,9 @@ dbx_reg_number (const_rtx rtl)
 }
 #endif
 
-  return DBX_REGISTER_NUMBER (regno);
+  regno = DBX_REGISTER_NUMBER (regno);
+  gcc_assert (regno != INVALID_REGNUM);
+  return regno;
 }
 
 /* Optionally add a DW_OP_piece term to a location description expression.


Re: PATCH: PR debug/52857: DW_OP_GNU_regval_type is generated with INVALID_REGNUM

2012-04-06 Thread H.J. Lu
On Fri, Apr 6, 2012 at 6:30 AM, H.J. Lu  wrote:
> Hi,
>
> With ptr_mode = SImode and Pmode == DImode, given
>
> (note 21 8 17 2 (expr_list:REG_DEP_TRUE (concat:SI (reg:SI 5 di)
>        (subreg:SI (plus:DI (reg/f:DI 16 argp)
>                (const_int -20 [0xffec])) 0))
>    (nil)) NOTE_INSN_CALL_ARG_LOCATION)
>
> when
>
> (plus:DI (reg/f:DI 16 argp)
>    (const_int -20 [0xffec]))
>
> reaches mem_loc_descriptor:
>
>   case PLUS:
>    plus:
>      if (is_based_loc (rtl)
>          && GET_MODE_SIZE (mode) <= DWARF2_ADDR_SIZE
>          && GET_MODE_CLASS (mode) == MODE_INT)
>        mem_loc_result = based_loc_descr (XEXP (rtl, 0),
>                                          INTVAL (XEXP (rtl, 1)),
>                                          VAR_INIT_STATUS_INITIALIZED);
>      else
>
> it fails "GET_MODE_SIZE (mode) <= DWARF2_ADDR_SIZE" since mode is DImode
> and DWARF2_ADDR_SIZE is 4.  arg_pointer_rtx and frame_pointer_rtx are
> special cases.  They should be allowed for based_loc_descr even if their
> mode sizes > DWARF2_ADDR_SIZE.  OK for trunk?
>

I missed another place where arg_pointer_rtx and frame_pointer_rtx should
be allowed  for based_loc_descr.   Tested on Linux/ia32, Linux/x86-64 and
Linux/x32.  OK for trunk?

Thanks.


-- 
H.J.


gcc-pr52857-2.patch
Description: Binary data


PATCH: PR debug/52857: DW_OP_GNU_regval_type is generated with INVALID_REGNUM

2012-04-06 Thread H.J. Lu
Hi,

With ptr_mode = SImode and Pmode == DImode, given

(note 21 8 17 2 (expr_list:REG_DEP_TRUE (concat:SI (reg:SI 5 di) 
(subreg:SI (plus:DI (reg/f:DI 16 argp)
(const_int -20 [0xffec])) 0)) 
(nil)) NOTE_INSN_CALL_ARG_LOCATION)

when

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

reaches mem_loc_descriptor:

   case PLUS: 
plus: 
  if (is_based_loc (rtl) 
  && GET_MODE_SIZE (mode) <= DWARF2_ADDR_SIZE
  && GET_MODE_CLASS (mode) == MODE_INT)
mem_loc_result = based_loc_descr (XEXP (rtl, 0),
  INTVAL (XEXP (rtl, 1)),
  VAR_INIT_STATUS_INITIALIZED);
  else  

it fails "GET_MODE_SIZE (mode) <= DWARF2_ADDR_SIZE" since mode is DImode
and DWARF2_ADDR_SIZE is 4.  arg_pointer_rtx and frame_pointer_rtx are
special cases.  They should be allowed for based_loc_descr even if their
mode sizes > DWARF2_ADDR_SIZE.  OK for trunk?

Thanks.


H.J.

gcc/

2012-04-06  H.J. Lu  

PR debug/52857
* dwarf2out.c (mem_loc_descriptor): Assert dbx_reg_number !=
INVALID_REGNUM for DW_OP_GNU_regval_type.  Allow
arg_pointer_rtx and frame_pointer_rtx for based_loc_descr.

gcc/testsuite/

2012-04-06  H.J. Lu  

PR debug/52857
* gcc.target/i386/pr52857.c: New.

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index ca88fc5..ab20683 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -11661,6 +11661,7 @@ mem_loc_descriptor (rtx rtl, enum machine_mode mode,
  ))
{
  dw_die_ref type_die;
+ unsigned int dbx_regno;
 
  if (dwarf_strict)
break;
@@ -11670,8 +11671,10 @@ mem_loc_descriptor (rtx rtl, enum machine_mode mode,
 GET_MODE_CLASS (mode) == MODE_INT);
  if (type_die == NULL)
break;
+ dbx_regno = dbx_reg_number (rtl);
+ gcc_assert (dbx_regno != INVALID_REGNUM);
  mem_loc_result = new_loc_descr (DW_OP_GNU_regval_type,
- dbx_reg_number (rtl), 0);
+ dbx_regno, 0);
  mem_loc_result->dw_loc_oprnd2.val_class = dw_val_class_die_ref;
  mem_loc_result->dw_loc_oprnd2.v.val_die_ref.die = type_die;
  mem_loc_result->dw_loc_oprnd2.v.val_die_ref.external = 0;
@@ -11927,7 +11930,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.c 
b/gcc/testsuite/gcc.target/i386/pr52857.c
new file mode 100644
index 000..16fd78f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr52857.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);
+}


PATCH: PR debug/52857: DW_OP_GNU_regval_type is generated with INVALID_REGNUM

2012-04-03 Thread H.J. Lu
Hi,

As the testcase in

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52857

shows, for

(subreg:SI (plus:DI (reg/f:DI 16 argp)
(const_int -128 [0xff80])) 0)

we generates DW_OP_GNU_regval_type with INVALID_REGNUM.  This patch
checks dbx_reg_number for INVALID_REGNUM before using it.  OK for
trunk and 4.7?

Thanks.

H.J.
---
2012-04-03  H.J. Lu  

PR debug/52857
* dwarf2out.c (mem_loc_descriptor): Don't generate
DW_OP_GNU_regval_type with INVALID_REGNUM.

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index ca88fc5..935c86f 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -11664,7 +11664,8 @@ mem_loc_descriptor (rtx rtl, enum machine_mode mode,
 
  if (dwarf_strict)
break;
- if (REGNO (rtl) > FIRST_PSEUDO_REGISTER)
+ if (REGNO (rtl) > FIRST_PSEUDO_REGISTER
+ || dbx_reg_number (rtl) == INVALID_REGNUM)
break;
  type_die = base_type_for_mode (mode,
 GET_MODE_CLASS (mode) == MODE_INT);