]> git.ipfire.org Git - thirdparty/gcc.git/commit
Fix signedness issue in DWARF functions (2)
authorEric Botcazou <ebotcazou@adacore.com>
Fri, 28 May 2021 17:31:18 +0000 (19:31 +0200)
committerEric Botcazou <ebotcazou@adacore.com>
Thu, 3 Jun 2021 10:41:20 +0000 (12:41 +0200)
commitdf741be17ee09974ad46750ebbbacf55f8e108a8
tree518f4b3aa4f5e605a38770cb75ad70f0b7cae70b
parente26b748a62e5bc59f6671faab75f737503c87319
Fix signedness issue in DWARF functions (2)

The compiler can synthesize DWARF functions to describe the location and
size of components in discriminated record types with variant part in Ada,
but in peculiar cases the compiler drops expressions on the floor, for
example in the divide case:

     case ROUND_DIV_EXPR:
     case TRUNC_DIV_EXPR:
     case EXACT_DIV_EXPR:
      if (TYPE_UNSIGNED (TREE_TYPE (loc)))
        return 0;
       op = DW_OP_div;
       goto do_binop;

Now sizetype and bitsizetype are unsigned types, which means that any divide
expression in them is dropped.

gcc/
* dwarf2out.c (mem_loc_descriptor) <UDIV>: Fix typo.
(typed_binop_from_tree): New function.
(loc_list_from_tree_1) <EXACT_DIV_EXPR>: For an unsigned type,
turn a divide by a power of 2 into a shift.
<CEIL_DIV_EXPR>: For an unsigned type, use a signed divide if the
size of the mode is lower than DWARF2_ADDR_SIZE; otherwise, do a
typed divide by calling typed_binop_from_tree.
gcc/dwarf2out.c