public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] x86-64: Find a scratch register for large model profiling
Date: Thu, 1 Feb 2024 19:31:54 +0100	[thread overview]
Message-ID: <Zbvjmhnu4vCb+PKh@tucnak> (raw)
In-Reply-To: <20240201181530.99684-1-hjl.tools@gmail.com>

On Thu, Feb 01, 2024 at 10:15:30AM -0800, H.J. Lu wrote:
> --- a/gcc/config/i386/i386.cc
> +++ b/gcc/config/i386/i386.cc
> @@ -22749,6 +22749,31 @@ current_fentry_section (const char **name)
>    return true;
>  }
>  
> +/* Return an unused caller-saved register at entry for profile.  */
> +
> +static int
> +x86_64_select_profile_regnum (bool r11_ok ATTRIBUTE_UNUSED)
> +{
> +  int i;

Why not just return R10_REG here if flag_entry != 0 (i.e. keep existing
behavior unless emitting profiler after prologue)?

> +  for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
> +    if (GENERAL_REGNO_P (i)
> +#ifdef NO_PROFILE_COUNTERS
> +	&& (r11_ok || i != R11_REG)
> +#else
> +	&& i != R11_REG
> +#endif
> +	&& (!REX2_INT_REGNO_P (i) || TARGET_APX_EGPR)
> +	&& !fixed_regs[i]
> +	&& call_used_regs[i]
> +	&& !df_regs_ever_live_p (i))

Also, isn't this too restrictive?
I mean, all we care about is whether there is some register
which is not live across the NOTE_INSN_PROLOG_END note, no?
I.e. doesn't contain any of function's argument that are used later,
and isn't set in the prologue to be used later.  E.g. call used
register which is just saved to stack in the prologue might be just fine.

> +      return i;
> +
> +  sorry ("No register available for profiling %<-mcmodel=large%s%>",

Diagnostics shouldn't start with capital letter.

> +	 ix86_cmodel == CM_LARGE_PIC ? " -fPIC" : "");
> +
> +  return INVALID_REGNUM;
> +}
> +
>  /* Output assembler code to FILE to increment profiler label # LABELNO
>     for profiling a function entry.  */
>  void

	Jakub


  reply	other threads:[~2024-02-01 18:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-01 18:15 H.J. Lu
2024-02-01 18:31 ` Jakub Jelinek [this message]
2024-02-01 23:02   ` H.J. Lu
2024-02-02 12:07     ` rep.dot.nop
2024-02-02 12:22       ` H.J. Lu

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=Zbvjmhnu4vCb+PKh@tucnak \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hjl.tools@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).