public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Martin Sebor <msebor@gmail.com>
Cc: Gcc Patch List <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] diagnose unsupported uses of hardware register variables (PR 88000)
Date: Wed, 14 Nov 2018 09:48:00 -0000	[thread overview]
Message-ID: <20181114094757.GO11625@tucnak> (raw)
In-Reply-To: <edacc336-963e-37e1-804d-44870c12bd55@gmail.com>

On Tue, Nov 13, 2018 at 09:11:41PM -0700, Martin Sebor wrote:
> --- gcc/c-family/c-warn.c	(revision 266086)
> +++ gcc/c-family/c-warn.c	(working copy)
> @@ -2609,3 +2609,39 @@ warn_for_multistatement_macros (location_t body_lo
>      inform (guard_loc, "some parts of macro expansion are not guarded by "
>  	    "this %qs clause", guard_tinfo_to_string (keyword));
>  }
> +
> +
> +/* Diagnose unsuported use of explicit hardware register variable ARG
> +   as an argument ARGNO to function FNDECL.  */
> +
> +void
> +warn_hw_reg_arg (tree fndecl, int argno, tree arg)
> +{
> +  if (!fndecl)
> +    return;
> +
> +  /* Avoid diagnosing GCC intrinsics with no library fallbacks.  */
> +  if (fndecl_built_in_p (fndecl)
> +      && DECL_IS_BUILTIN (fndecl)
> +      && !c_decl_implicit (fndecl)
> +      && !DECL_ASSEMBLER_NAME_SET_P (fndecl))
> +    return;
> +
> +  /* Also avoid diagnosing always_inline functions since those are
> +     often used to implement vectorization intrinsics that make use
> +     of hardware register variables.  */
> +  if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (fndecl)))
> +    return;
> +
> +  /* Diagnose uses of local variables declared asm register.  */
> +  STRIP_ANY_LOCATION_WRAPPER (arg);
> +  if (VAR_P (arg)
> +      && !TREE_STATIC (arg)
> +      && DECL_HARD_REGISTER (arg)
> +      && warning_at (input_location, OPT_Wasm_register_var,
> +		     "unsupported use of hardware register %qD as "
> +		     "argument %d of %qD",
> +		     arg, argno, fndecl))
> +    inform (DECL_SOURCE_LOCATION (arg),
> +	    "%qD declared here", arg);
> +}

This makes no sense to me.  There is nothing unsupported in passing
a local hard register variable to a function, that is well defined,
and as your testcase changes show, you broke quite some completely valid
testcases with that.

What doesn't work as the reporter expect is assumption that local hard
register variables that live across function calls must have their values
preserved; they can be modified by the callees.

	Jakub

  parent reply	other threads:[~2018-11-14  9:48 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-14  4:11 Martin Sebor
2018-11-14  9:39 ` Alexander Monakov
2018-11-15 22:34   ` Martin Sebor
2018-11-14  9:48 ` Jakub Jelinek [this message]
2018-11-14 11:35   ` Segher Boessenkool
2018-11-14 11:40     ` Jakub Jelinek
2018-11-14 11:50       ` Segher Boessenkool
2018-11-14 12:00         ` Jakub Jelinek
2018-11-14 12:11           ` Segher Boessenkool
2018-11-14 12:14             ` Jakub Jelinek
2018-11-15 18:31   ` Martin Sebor
2018-11-14 12:22 Segher Boessenkool
2018-11-14 12:27 ` Jakub Jelinek
2018-11-14 12:33   ` Alexander Monakov
2018-11-14 13:53     ` Segher Boessenkool
2018-11-14 15:50       ` Alexander Monakov
2018-11-14 17:47         ` Segher Boessenkool
2018-11-14 18:01           ` Alexander Monakov
2018-11-15 15:54             ` Michael Matz
2018-11-15 16:23               ` Alexander Monakov
2018-11-16 15:21                 ` Michael Matz
2018-11-16 16:28                   ` Alexander Monakov
2018-11-16 16:43                     ` Michael Matz
2018-11-16 22:12               ` Segher Boessenkool
2018-11-19 12:59                 ` Michael Matz
2018-11-19 17:18                   ` Segher Boessenkool
2018-11-14 13:47   ` Segher Boessenkool

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=20181114094757.GO11625@tucnak \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=msebor@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).