dwarf2out.c (loc_descriptor_from_tree_1): Don't handle unsigned division.

* dwarf2out.c (loc_descriptor_from_tree_1): Don't handle unsigned
	division.  Handle signed modulo using DW_OP_{over,over,div,mul,minus}.
	* unwind-dw2.c (execute_stack_op): Handle DW_OP_mod using unsigned
	modulo instead of signed.

	* gcc.dg/cleanup-13.c: Expect DW_OP_mod to do unsigned modulo instead
	of signed, add a few new tests.

From-SVN: r156065
This commit is contained in:
Jakub Jelinek 2010-01-20 09:39:18 +01:00 committed by Jakub Jelinek
parent 6388d3ace2
commit e3079365b6
5 changed files with 49 additions and 6 deletions

View File

@ -1,3 +1,10 @@
2010-01-20 Jakub Jelinek <jakub@redhat.com>
* dwarf2out.c (loc_descriptor_from_tree_1): Don't handle unsigned
division. Handle signed modulo using DW_OP_{over,over,div,mul,minus}.
* unwind-dw2.c (execute_stack_op): Handle DW_OP_mod using unsigned
modulo instead of signed.
2010-01-18 Uros Bizjak <ubizjak@gmail.com>
PR target/42774

View File

@ -1,6 +1,7 @@
/* Output Dwarf2 format symbol table information from GCC.
Copyright (C) 1992, 1993, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
Free Software Foundation, Inc.
Contributed by Gary Funck (gary@intrepid.com).
Derived from DWARF 1 implementation of Ron Guilmette (rfg@monkeys.com).
Extensively modified by Jason Merrill (jason@cygnus.com).
@ -10640,6 +10641,8 @@ loc_descriptor_from_tree_1 (tree loc, int want_address)
case CEIL_DIV_EXPR:
case ROUND_DIV_EXPR:
case TRUNC_DIV_EXPR:
if (TYPE_UNSIGNED (TREE_TYPE (loc)))
return 0;
op = DW_OP_div;
goto do_binop;
@ -10651,8 +10654,23 @@ loc_descriptor_from_tree_1 (tree loc, int want_address)
case CEIL_MOD_EXPR:
case ROUND_MOD_EXPR:
case TRUNC_MOD_EXPR:
op = DW_OP_mod;
goto do_binop;
if (TYPE_UNSIGNED (TREE_TYPE (loc)))
{
op = DW_OP_mod;
goto do_binop;
}
ret = loc_descriptor_from_tree_1 (TREE_OPERAND (loc, 0), 0);
ret1 = loc_descriptor_from_tree_1 (TREE_OPERAND (loc, 1), 0);
if (ret == 0 || ret1 == 0)
return 0;
add_loc_descr (&ret, ret1);
add_loc_descr (&ret, new_loc_descr (DW_OP_over, 0, 0));
add_loc_descr (&ret, new_loc_descr (DW_OP_over, 0, 0));
add_loc_descr (&ret, new_loc_descr (DW_OP_div, 0, 0));
add_loc_descr (&ret, new_loc_descr (DW_OP_mul, 0, 0));
add_loc_descr (&ret, new_loc_descr (DW_OP_minus, 0, 0));
break;
case MULT_EXPR:
op = DW_OP_mul;

View File

@ -1,3 +1,8 @@
2010-01-20 Jakub Jelinek <jakub@redhat.com>
* gcc.dg/cleanup-13.c: Expect DW_OP_mod to do unsigned modulo instead
of signed, add a few new tests.
2010-01-18 Uros Bizjak <ubizjak@gmail.com>
PR target/42774

View File

@ -210,9 +210,22 @@ OP_const1s(-123) OP_abs OP_const1u(123) OP_eq ASSERT_TOS_NON0 \
OP_lit3 OP_lit6 OP_and OP_lit2 OP_eq ASSERT_TOS_NON0 \
OP_lit3 OP_lit6 OP_or OP_lit7 OP_eq ASSERT_TOS_NON0 \
OP_lit17 OP_lit2 OP_minus OP_lit15 OP_eq ASSERT_TOS_NON0 \
/* Divide is signed truncating toward zero. */ \
OP_const1s(-6) OP_const1s(-2) OP_div OP_lit3 OP_eq ASSERT_TOS_NON0 \
OP_const1s(-6) OP_const1s(-4) OP_mod OP_const1s(-2) \
OP_const1s(-7) OP_const1s(3) OP_div OP_const1s(-2) \
OP_eq ASSERT_TOS_NON0 \
/* Modulo is unsigned. */ \
OP_const1s(-6) OP_const1s(-4) OP_mod OP_const1s(-6) \
OP_eq ASSERT_TOS_NON0 \
OP_const1s(-6) OP_lit4 OP_mod OP_lit2 OP_eq ASSERT_TOS_NON0 \
OP_lit6 OP_const1s(-4) OP_mod OP_lit6 OP_eq ASSERT_TOS_NON0 \
/* Signed modulo can be implemented using "over over div mul minus". */\
OP_const1s(-6) OP_const1s(-4) OP_over OP_over OP_div OP_mul OP_minus \
OP_const1s(-2) OP_eq ASSERT_TOS_NON0 \
OP_const1s(-7) OP_lit3 OP_over OP_over OP_div OP_mul OP_minus \
OP_const1s(-1) OP_eq ASSERT_TOS_NON0 \
OP_lit7 OP_const1s(-3) OP_over OP_over OP_div OP_mul OP_minus \
OP_lit1 OP_eq ASSERT_TOS_NON0 \
OP_lit16 OP_lit31 OP_plus_uconst(1) OP_mul OP_const2u(512) \
OP_eq ASSERT_TOS_NON0 \
OP_lit5 OP_not OP_lit31 OP_and OP_lit26 OP_eq ASSERT_TOS_NON0 \

View File

@ -1,6 +1,6 @@
/* DWARF2 exception handling and frame unwind runtime interface routines.
Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
2008, 2009 Free Software Foundation, Inc.
2008, 2009, 2010 Free Software Foundation, Inc.
This file is part of GCC.
@ -765,7 +765,7 @@ execute_stack_op (const unsigned char *op_ptr, const unsigned char *op_end,
result = second - first;
break;
case DW_OP_mod:
result = (_Unwind_Sword) second % (_Unwind_Sword) first;
result = second % first;
break;
case DW_OP_mul:
result = second * first;