From: law@redhat.com
To: Alan Modra <alan@SPRI.Levels.UniSA.Edu.Au>
Cc: gcc-bugs@gcc.gnu.org, parisc-linux@lists.parisc-linux.org
Subject: [parisc-linux] Re: pa __builtin_return_addr
Date: Sun, 06 May 2001 09:25:38 -0700 [thread overview]
Message-ID: <20603.989166338@slagheap.cygnus.com> (raw)
In-Reply-To: Your message of Sat, 05 May 2001 22:11:43 +0930. <Pine.LNX.4.30.0105052051010.7143-100000@mullet.itr.unisa.edu.au>
In message <Pine.LNX.4.30.0105052051010.7143-100000@mullet.itr.unisa.edu.au>y
ou write:
> Hi Jeff,
> I stumbled on this one a couple of hours ago, and haven't figured out
> a good fix yet.
>
> cat >builtin_ret.c <<EOF
> void *foo (void) { return __builtin_return_address (0); }
> EOF
> gcc -O -S -mno-space-regs builtin_ret.c
>
> gives (trimming somewhat)
> foo:
> bv %r0(%r2)
> ldw -20(%r30),%r28 # Oops, we never stored r2 at -20(%r30)
>
> The fix I have in mind is to add some communication between
> builtins.c:expand_builtin_return_addr and pa.c:hppa_expand_prologue.
> eg. add a field to struct machine_function, and set it in
> pa.c:return_addr_rtx to indicate that r2 must be saved.
The "right" way to handle this would be to have return_addr_rtx return
%r2 in the case where %r2 isn't ever saved into the stack. However, I
don't know if we can reliably determine if %r2 is saved into the stack
at the point where we call return_addr_rtx.
If we can't reliably make that determination, then we can just force
%r2 to be saved into the stack if we ever call __builtin_return_address.
> A similar problem occurs with
> cat >builtin_frame.c <<EOF
> void *foo (void) { return __builtin_frame_address (1); }
> EOF
> gcc -O -S builtin_frame.c
>
> foo:
> bv %r0(%r2)
> ldw 0(%r30),%r28 # Oops, we haven't saved a frame pointer.
>
> We ought to be able to make __builtin_frame_address (n) work reliably for
> n = 0 and n = 1 by something similar to the fix I'm proposing for the
> return address problem. ie. set a "frame_pointer_needed" flag in
> struct machine_function.
I disagree about the solutoin for this one. I believe it should be
possible to derive the frame address from the stack pointer fairly
easily since the difference between the stack and frame pointer is
a constant.
jeff
prev parent reply other threads:[~2001-05-06 16:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-05-05 12:41 [parisc-linux] pa __builtin_return_addr Alan Modra
2001-05-06 16:25 ` law [this message]
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=20603.989166338@slagheap.cygnus.com \
--to=law@redhat.com \
--cc=alan@SPRI.Levels.UniSA.Edu.Au \
--cc=gcc-bugs@gcc.gnu.org \
--cc=parisc-linux@lists.parisc-linux.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