linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luc Van Oostenryck <lucvoo@kernel.org>
To: linux-sparse@vger.kernel.org
Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH 3/6] inline: declaration of the variadic vars is useless
Date: Sun, 26 Jun 2022 15:07:45 +0200	[thread overview]
Message-ID: <20220626130748.74163-4-lucvoo@kernel.org> (raw)
In-Reply-To: <20220626130748.74163-1-lucvoo@kernel.org>

From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>

When inlining a function call, the arguments of this call must
somehow be assigned to the names used in the function definition.
This is done via a STMT_DECLARATION associated to the top
STMT_COMPOUND which now correspond to the inlined code.

This is perfectly fine for the normal case of non-variadic function
but when inlining a variadic function there is no corresponding name
to assign the non-fixed arguments to (such arguments must either be
not used at all or copied via __builtin_va_arg_pack()). What's then
happening is essentially that these variables are self-assigned.
Not Good.

This seems to be relatively harmless but is confusing.
So only put the fixed/named arguments in the declaration list.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 inline.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/inline.c b/inline.c
index d031c9b19128..4696eb509f9a 100644
--- a/inline.c
+++ b/inline.c
@@ -546,14 +546,14 @@ int inline_function(struct expression *expr, struct symbol *sym)
 			*a = *name;
 			set_replace(name, a);
 			add_symbol(&fn_symbol_list, a);
+			a->initializer = arg;
+			add_symbol(&arg_decl, a);
 		} else {
 			// This may create a node of a node but it will
 			// be resolved later when the corresponding
 			// STMT_DECLARATION will be evaluated.
 			a->ctype.base_type = arg->ctype;
 		}
-		a->initializer = arg;
-		add_symbol(&arg_decl, a);
 
 		NEXT_PTR_LIST(name);
 	} END_FOR_EACH_PTR(arg);
-- 
2.36.1


  parent reply	other threads:[~2022-06-26 13:08 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-26 13:07 [PATCH 0/6] cleanup related to inlining of variadic functions Luc Van Oostenryck
2022-06-26 13:07 ` [PATCH 1/6] inline: add testcases for inlining of variadics Luc Van Oostenryck
2022-06-26 13:07 ` [PATCH 2/6] inline: comment about creating node of node on variadics Luc Van Oostenryck
2022-06-26 14:42   ` Ramsay Jones
2022-06-26 16:07     ` Luc Van Oostenryck
2022-06-26 13:07 ` Luc Van Oostenryck [this message]
2022-06-26 13:07 ` [PATCH 4/6] inline: avoid needless intermediate vars Luc Van Oostenryck
2022-06-26 14:45   ` Ramsay Jones
2022-06-26 13:07 ` [PATCH 5/6] inline: allocate statement after guards Luc Van Oostenryck
2022-06-26 13:07 ` [PATCH 6/6] inline: free symbol list after use Luc Van Oostenryck

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=20220626130748.74163-4-lucvoo@kernel.org \
    --to=lucvoo@kernel.org \
    --cc=linux-sparse@vger.kernel.org \
    --cc=luc.vanoostenryck@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 NNTP newsgroup(s).