public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* expand_builtin_dwarf_reg_size
@ 1998-09-23 11:33 Hasdi R Hashim
  1998-09-23 15:55 ` expand_builtin_dwarf_reg_size John Carr
  0 siblings, 1 reply; 3+ messages in thread
From: Hasdi R Hashim @ 1998-09-23 11:33 UTC (permalink / raw)
  To: egcs

Hello guys,

	[you may want to take a look at the function in dwarf2out.c to
understand what I am saying]

	I am in the process of building/modifying an md. One thing that
botched me is this function (while compiling _eh in libgcc2.c).
Specifically, this code: 

	  if ((DWARF_FRAME_REGNUM (ranges[n_ranges].end)
	       - DWARF_FRAME_REGNUM (ranges[n_ranges].beg))
	      != ranges[n_ranges].end - ranges[n_ranges].beg)
	    abort();

	[ DWARF_FRAME_REGNUM is aliased to DBX_REGISTER_NUMBER ]

	This function has an alternative block to speed up a common case
where n_ranges == 3. For n_ranges == 3, this is executed for ranges[1]. 
For machines for n_ranges!= 0, every single range will be tested. For most
machines, this isn't a problem. It will give a problem if a machine have
1) n_ranges != 3 and 2) DBX_REGISTER_NUMBER that orders the register
number in a particular way. config/i386/linux for example:

	 #define DBX_REGISTER_NUMBER(n) \
	 ((n) == 0 ? 0 \
	  : (n) == 1 ? 2 \
	  : (n) == 2 ? 1 \
	  : (n) == 3 ? 3 \
	  : (n) == 4 ? 6 \
	  : (n) == 5 ? 7 \
	  : (n) == 6 ? 5 \
	  : (n) == 7 ? 4 \
	  : ((n) >= FIRST_STACK_REG && (n) <= LAST_STACK_REG) ? (n)+3 \
	  : (-1))

	ranges[0].beg == 0; DBX_...(ranges[0].beg) == 0
	ranges[0].end == 7; DBX_...(ranges[0].end) == 4

These values will case cc1 to abort if i386 additional register range.

I see this is a bug because, the common case is not handled consistently
to the general case. I would submit a patch if I knew what this code is
trying to check. 

I noticed another inconsistency. This next code is executed only the
general case but not for the common case. Why is that?

	if (DWARF_FRAME_REGNUM (ranges[n_ranges].beg) >= size)
	   abort ();

Also, why is the final else-clause for DBX_REGISTER_NUMBER is (-1)? It
used to be (n+4) or (n+3) in 2.8 or so. What is the criteria of numbers to
return for DBX_REGISTER_NUMBER?

Thanks y'all

Hasdi

www.bigfoot.com/~hasdi



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: expand_builtin_dwarf_reg_size
  1998-09-23 11:33 expand_builtin_dwarf_reg_size Hasdi R Hashim
@ 1998-09-23 15:55 ` John Carr
  0 siblings, 0 replies; 3+ messages in thread
From: John Carr @ 1998-09-23 15:55 UTC (permalink / raw)
  To: Hasdi R Hashim; +Cc: egcs, egcs-patches

I ran across the same bug (also modifying the i386 machine
description).  Here is my fix.

*** dwarf2out.c	1998/09/10 10:45:57	1.68
--- dwarf2out.c	1998/09/23 22:51:23
*************** expand_builtin_dwarf_reg_size (reg_tree,
*** 642,665 ****
      }
    else
      {
        --n_ranges;
        t = build_int_2 (ranges[n_ranges].size, 0);
!       size = DWARF_FRAME_REGNUM (ranges[n_ranges].beg);
!       for (; n_ranges--; )
  	{
! 	  if ((DWARF_FRAME_REGNUM (ranges[n_ranges].end)
! 	       - DWARF_FRAME_REGNUM (ranges[n_ranges].beg))
! 	      != ranges[n_ranges].end - ranges[n_ranges].beg)
  	    abort ();
! 	  if (DWARF_FRAME_REGNUM (ranges[n_ranges].beg) >= size)
  	    abort ();
- 	  size = DWARF_FRAME_REGNUM (ranges[n_ranges].beg);
  	  t2 = fold (build (LE_EXPR, integer_type_node, reg_tree,
! 			    build_int_2 (DWARF_FRAME_REGNUM
! 					 (ranges[n_ranges].end), 0)));
  	  t = fold (build (COND_EXPR, integer_type_node, t2,
  			   build_int_2 (ranges[n_ranges].size, 0), t));
  	}
      }
    return expand_expr (t, target, Pmode, 0);
  }
--- 642,667 ----
      }
    else
      {
+       int last_end = 100;
        --n_ranges;
        t = build_int_2 (ranges[n_ranges].size, 0);
!       do
  	{
! 	  int beg = DWARF_FRAME_REGNUM (ranges[n_ranges].beg);
! 	  int end = DWARF_FRAME_REGNUM (ranges[n_ranges].end);
! 	  if (beg < 0)
! 	    continue;
! 	  if (end >= last_end)
  	    abort ();
! 	  last_end = end;
! 	  if (end - beg != ranges[n_ranges].end - ranges[n_ranges].beg)
  	    abort ();
  	  t2 = fold (build (LE_EXPR, integer_type_node, reg_tree,
! 			    build_int_2 (end, 0)));
  	  t = fold (build (COND_EXPR, integer_type_node, t2,
  			   build_int_2 (ranges[n_ranges].size, 0), t));
  	}
+       while (--n_ranges > 0);
      }
    return expand_expr (t, target, Pmode, 0);
  }

^ permalink raw reply	[flat|nested] 3+ messages in thread

* expand_builtin_dwarf_reg_size
@ 1998-10-03  5:59 John Carr
  0 siblings, 0 replies; 3+ messages in thread
From: John Carr @ 1998-10-03  5:59 UTC (permalink / raw)
  To: davem; +Cc: egcs

This change is wrong:

	* dwarf2out.c (expand_builtin_dwarf_reg_size): Use
	FIRST_PSEUDO_REGISTER as upper bound for last_end, not an
	arbitrary constant.

DBX register numbers can be larger than FIRST_PSEUDO_REGISTER.  The
old code was wrong too, but this isn't the right fix.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1998-10-03  5:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-09-23 11:33 expand_builtin_dwarf_reg_size Hasdi R Hashim
1998-09-23 15:55 ` expand_builtin_dwarf_reg_size John Carr
1998-10-03  5:59 expand_builtin_dwarf_reg_size John Carr

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).