From: Jakub Jelinek <jakub@redhat.com>
To: Florian Weimer <fweimer@redhat.com>
Cc: gcc-patches@gcc.gnu.org,
Andre Vieira <andre.simoesdiasvieira@arm.com>,
Andrew Pinski <pinskia@gmail.com>,
Jeff Law <jeffreyalaw@gmail.com>
Subject: Re: [PATCH] Various fixes for DWARF register size computation
Date: Tue, 3 Jan 2023 13:05:32 +0100 [thread overview]
Message-ID: <Y7QaDPdpmBCMU+Cd@tucnak> (raw)
In-Reply-To: <87pmbvx41g.fsf@oldenburg.str.redhat.com>
On Tue, Jan 03, 2023 at 12:15:23PM +0100, Florian Weimer wrote:
> --- a/gcc/debug.h
> +++ b/gcc/debug.h
> @@ -245,7 +245,18 @@ extern const struct gcc_debug_hooks vmsdbg_debug_hooks;
>
> /* Dwarf2 frame information. */
>
> -extern int dwarf_reg_sizes_constant ();
> +/* Query size information about DWARF registers. */
> +struct dwarf_single_register_size
> +{
> + dwarf_single_register_size();
Formatting, space before (
> @@ -334,27 +333,39 @@ generate_dwarf_reg_sizes (poly_uint16 *sizes)
> targetm.init_dwarf_reg_sizes_extra (sizes);
> }
>
> -/* Return 0 if the DWARF register sizes are not constant, otherwise
> - return the size constant. */
> -
> -int
> -dwarf_reg_sizes_constant ()
> +dwarf_single_register_size::dwarf_single_register_size()
Likewise.
> + for (int i = DWARF_FRAME_REGISTERS; i >= 0; --i)
> + {
> + unsigned short value;
> + if (!sizes[i].is_constant (&value) || value != 0)
if (!known_eq (sizes[i], 0))
?
Though, I still wonder, because all of this is a hack for a single target
- x86_64-linux -m64 - I think no other target has similar constant sizes, whether
it wouldn't be better to revert all this compiler side stuff and handle it
purely on the libgcc side - allow target headers to specify a simple
expression how to compute dwarf_reg_size + don't define dwarf_reg_size_table
array in that case and instead in a testcase verify that
__builtin_init_dwarf_reg_size_table initializes an array to the exact same
values as the libgcc/config/**/*.h overridden dwarf_reg_size version.
That way, for x86_64-linux we can use
((index) <= __LIBGCC_DWARF_FRAME_REGISTERS__ ? 8 : 0)
but could provide something reasonable even for other targets if it improves
the unwinder sufficiently.
Say s390x-linux -m64 is
((index) <= 32 ? 8 : (index) == 33 ? 4 : 0)
etc.
Or, if you want to do it on the compiler side, instead of predefining
__LIBGCC_DWARF_REG_SIZES_CONSTANT__ and __LIBGCC_DWARF_REG_MAXIMUM__
register conditionally a new builtin, __builtin_dwarf_reg_size,
which would be defined only if -fbuilding-libgcc and the compiler determines
dwarf_reg_size is desirable to be computed inline without a table and
would fold the builtin to say that
index <= 16U ? 8 : 0 on x86_64 -m64,
index <= 9U ? 4 : index - 11U <= 5U ? 12 : 0 on x86_64 -m32 etc.
and if the expression is too large/complex, wouldn't predefine the builtin.
Then you can
#if __has_builtin(__builtin_dwarf_reg_size)
use the builtin and don't provide the table + initialize it,
otherwise initialize + use the table.
Or, is it actually the use of table that is bad on the unwinder side,
or lack of a small upper bound for what you get from the table?
In that case you could predefine upper bound on the sizes instead (if
constant) and simply add if (size > __LIBGCC_DWARF_REG_SIZE_MAX__)
__builtin_unreachable ()).
Jakub
next prev parent reply other threads:[~2023-01-03 12:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-03 11:15 Florian Weimer
2023-01-03 12:05 ` Jakub Jelinek [this message]
2023-01-03 13:25 ` Florian Weimer
2023-01-03 13:54 ` Jakub Jelinek
2023-01-12 16:50 ` Richard Sandiford
2023-01-12 17:07 ` Jakub Jelinek
2023-01-12 21:03 ` Richard Sandiford
2023-01-13 10:05 ` [pushed] aarch64: Fix DWARF frame register sizes for predicates Richard Sandiford
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y7QaDPdpmBCMU+Cd@tucnak \
--to=jakub@redhat.com \
--cc=andre.simoesdiasvieira@arm.com \
--cc=fweimer@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jeffreyalaw@gmail.com \
--cc=pinskia@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).