public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Maciej W. Rozycki" <macro@orcam.me.uk>
To: Paul Koning <paulkoning@comcast.net>
Cc: Segher Boessenkool <segher@kernel.crashing.org>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] Turn on LRA on all targets
Date: Fri, 16 Feb 2024 11:34:55 +0000 (GMT)	[thread overview]
Message-ID: <alpine.DEB.2.21.2402152341510.3971@angie.orcam.me.uk> (raw)
In-Reply-To: <2A759520-2D62-472E-A97F-35E09B6E50F5@comcast.net>

On Thu, 15 Feb 2024, Paul Koning wrote:

> > On May 15, 2023, at 5:09 PM, Maciej W. Rozycki <macro@orcam.me.uk> wrote:
> > 
> > ...
> > 
> > I may choose to implement a non-DWARF unwinder instead, as the VAX stack 
> > frame is always fully described by the hardware and there is never ever a 
> > need for debug information to be able to decode any VAX stack frame (the 
> > RET machine instruction uses the stack frame information to restore the 
> > previous PC, FP, SP, AP and any static registers saved by CALLS).
> 
> That would make sense; it's like the heuristic unwinder found in some 
> other targets (I remember the MIPS one, which worked fairly well and 
> allowed debugging without useable debug data).

 Not really, in particular because EH unwinding has to be reliable and 
heuristics inherently is not.

 The MIPS heuristic unwinder continues living in GDB; I have extended it
to the microMIPS ISA at one point.  It has a major flaw though: the MIPS 
psABI uses a variable frame layout, with the frame maintained solely by 
software and with no fixed hardware frame pointer, so to analyse it in the 
absence of debug information the instruction sequence of the function's in 
question prologue has to be decoded to discover the location of individual 
frame slots.

 Consequently the more aggressive the compiler has become to schedule
function body instructions within a function's prologue the more lost the 
machine code interpreter has become.  Ultimately it would have to become a 
full-fledged CPU simulator to do its heuristics.  In reality it means the 
unwinder may fail to produce acceptable results, which will happen at any 
frequency between hardly ever to most often, depending on the exact 
circumstances.

 A mixed approach by interpreting lightweight PDR (Procedure Description 
Record) information inherited from the ECOFF Mdebug format combined with 
function prologue scanning might be more reliable, because in that case 
frame slot positions are known and the only unknown is the code locations 
they are initialised each at.  So all the prologue scanner has to know it 
is the store machine instructions and any that set a frame pointer from 
the stack pointer.  All the other instructions can be simply ignored.  And 
then only in the innermost frame, because any outer frames must have been 
fully set up already.  But I never got to implementing it and remnants of 
the PDR unwinder have long been removed from GDB.

 Conversely no heuristics is required to unwind VAX frames, because they 
are fixed in layout by hardware, fully self-described, and with the 
hardware frame pointer always available.  Therefore to unwind a VAX frame 
steps similar to those made by hardware on a function return (machine RET 
instruction) can simply be recreated from information produced by hardware 
at the function call and recorded in the stack frame and registers.  There 
is room reserved in the stack frame for a pointer to an exception handler 
even ("condition handler" in VAX-speak), preset to zero (a null pointer) 
by hardware at function entry.

 It does seem really attractive (and saves some storage space, which VAX 
hardware users will likely appreciate), but implies dedicated libgcc code 
as opposed to reusing common bits, which may or may not be welcome by the 
community for such an exotic corner case target.

  Maciej

  reply	other threads:[~2024-02-16 11:34 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-23 16:47 Segher Boessenkool
2023-04-23 17:01 ` Jeff Law
2023-04-23 20:23   ` Segher Boessenkool
2023-04-24  8:42   ` Andreas Schwab
2023-04-23 18:36 ` Paul Koning
2023-04-23 20:19   ` Segher Boessenkool
2023-04-23 18:56 ` Maciej W. Rozycki
2023-04-23 20:33   ` Segher Boessenkool
2023-05-15 21:09     ` Maciej W. Rozycki
2023-05-15 21:16       ` Sam James
2024-02-15 19:34         ` Sam James
2024-02-15 22:56           ` Segher Boessenkool
2024-02-16  1:41             ` Paul Koning
2024-02-16 10:22               ` Segher Boessenkool
2024-02-15 22:21       ` Paul Koning
2024-02-16 11:34         ` Maciej W. Rozycki [this message]
2024-02-16 13:47           ` Segher Boessenkool
2024-02-16 14:23             ` Maciej W. Rozycki
2024-02-16 14:31               ` Jakub Jelinek
2024-02-16 17:01                 ` Maciej W. Rozycki
2024-02-17  0:38                   ` Maciej W. Rozycki
2024-02-16 14:50           ` Paul Koning
2023-04-23 21:06 ` Uros Bizjak
2023-04-24  9:17   ` Segher Boessenkool
2023-04-24  9:46     ` Uros Bizjak
2023-04-29 14:38       ` Segher Boessenkool
2023-04-24  8:19 ` Richard Biener
2023-04-24  9:44   ` Segher Boessenkool
2023-04-30 19:52 ` Jeff Law
2023-04-29 13:37 Roger Sayle
2023-04-29 15:06 ` Jeff Law

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=alpine.DEB.2.21.2402152341510.3971@angie.orcam.me.uk \
    --to=macro@orcam.me.uk \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=paulkoning@comcast.net \
    --cc=segher@kernel.crashing.org \
    /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).