public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Stafford Horne <shorne@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-4777] or1k: Add return address argument to _mcount call
Date: Thu, 28 Oct 2021 20:41:41 +0000 (GMT)	[thread overview]
Message-ID: <20211028204141.848033858405@sourceware.org> (raw)

https://gcc.gnu.org/g:308531d148afa3fd77c0efc82a80b26300f9615a

commit r12-4777-g308531d148afa3fd77c0efc82a80b26300f9615a
Author: Stafford Horne <shorne@gmail.com>
Date:   Thu Oct 28 06:54:05 2021 +0900

    or1k: Add return address argument to _mcount call
    
    This fixes an issue in the glibc port I am working on where the build
    fails due to the warning:
    
      error: calling ‘__builtin_return_address’ with a nonzero argument is unsafe [-Werror=frame-address]
    
    This is due to how the current implementation of _mcount in glibc uses
    __builtin_return_address with a count argument of 1.
    
    Fix that by passing the value of LR_REGNUM to the _mcount function,
    effectivtly providing the value _mcount is after.
    
    This is an ABI change, but I think it's OK because the glibc port for
    or1k is not yet upstreamed.  Also, I think just adding an argument
    should not break anything anyway.
    
    gcc/ChangeLog:
    
            * config/or1k/or1k.h (PROFILE_HOOK): Add return address argument
            to _mcount.

Diff:
---
 gcc/config/or1k/or1k.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gcc/config/or1k/or1k.h b/gcc/config/or1k/or1k.h
index 669907e7e74..8a529f4c67c 100644
--- a/gcc/config/or1k/or1k.h
+++ b/gcc/config/or1k/or1k.h
@@ -394,9 +394,10 @@ do {                                                    \
    profiling a function entry.  */
 #define PROFILE_HOOK(LABEL)						\
   {									\
-    rtx fun;								\
+    rtx fun, ra;							\
+    ra = get_hard_reg_initial_val (Pmode, LR_REGNUM);			\
     fun = gen_rtx_SYMBOL_REF (Pmode, "_mcount");			\
-    emit_library_call (fun, LCT_NORMAL, VOIDmode);			\
+    emit_library_call (fun, LCT_NORMAL, VOIDmode, ra, Pmode);		\
   }
 
 /* All the work is done in PROFILE_HOOK, but this is still required.  */


                 reply	other threads:[~2021-10-28 20:41 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20211028204141.848033858405@sourceware.org \
    --to=shorne@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.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).