diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2024-06-03 17:44:13 +0200 |
---|---|---|
committer | Eric Botcazou <ebotcazou@adacore.com> | 2024-06-03 18:03:31 +0200 |
commit | f3d6d60d2ae584a23bb7c681cbd511202953c391 (patch) | |
tree | a4f7adadeb2a812797134d7c9903fa26c713f64c /gcc/cp/parser.cc | |
parent | 482f97e79fc29ea2d61f1425b32564a668b51e1c (diff) | |
download | gcc-f3d6d60d2ae584a23bb7c681cbd511202953c391.zip gcc-f3d6d60d2ae584a23bb7c681cbd511202953c391.tar.gz gcc-f3d6d60d2ae584a23bb7c681cbd511202953c391.tar.bz2 |
Implement wrap-around arithmetics in DWARF expressions
For the following Ada package declaring a simple variable-sized record type:
package P is
type Enum is (Zero, One, Two, Three, Four, Five, Six, Seven, Eight, Nine);
type Rec (Kind : Enum := Zero) is record
case Kind is
when Four .. Seven =>
S : String (1 .. 32);
when others =>
null;
end case;
end record;
end P;
the compiler builds a "size function" in GENERIC which is at -Og:
sizetype _GLOBAL.SZ5_p (p__enum p0)
{
return (UNSIGNED_8) p0 + 252 <= 3 ? 32 : 0;
}
The UNSIGNED_8-based trick makes it possible to eliminates one branch but
relies on the wrap-around arithmetics of UNSIGNED_8. This size function
is then translated into a DWARF procedure, but the wrap-around arithmetics
is dropped on the floor, leading to a wrong size calculation when the DWARF
procedure is executed.
The fix also contains an optimization of unsigned comparisons in DWARF for
the case where the type is smaller than the "generic type" like here.
gcc/
* dwarf2out.cc (loc_list_from_tree_1) <CEIL_DIV_EXPR>; Add const.
<do_comp_binop>: Use a signed comparison for small unsigned types.
Implement wrap-around arithmetics for small integer types.
Diffstat (limited to 'gcc/cp/parser.cc')
0 files changed, 0 insertions, 0 deletions