linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pekka Enberg <penberg@kernel.org>
To: linux-sparse@vger.kernel.org
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Christopher Li <sparse@chrisli.org>,
	Jeff Garzik <jgarzik@redhat.com>,
	Pekka Enberg <penberg@kernel.org>
Subject: [RFC/PATCH 1/2] sparse, llvm: Make function declaration accessible to backend
Date: Wed,  1 Feb 2012 11:55:51 +0200	[thread overview]
Message-ID: <1328090152-28299-1-git-send-email-penberg@kernel.org> (raw)

From: Linus Torvalds <torvalds@linux-foundation.org>

On Tue, Aug 30, 2011 at 10:43 AM, Jeff Garzik <jeff@garzik.org> wrote:
> * if someone knows how to access a function declaration, I can solve the
> varargs problem

Hmm. Right now we do not have access to the function declaration at
linearize time. We've checked that the arguments match, and we've cast
the arguments to the right types (evaluate.c), so the thinking was
that you just use the arguments as-is.

But if llvm needs the declaration of a function, we'd need to squirrel it away.

Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
[ penberg@kernel.org: Fix validation/context.c breakage. ]
Signed-off-by: Pekka Enberg <penberg@kernel.org>
---
 linearize.c |    8 ++++++++
 linearize.h |    1 +
 2 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/linearize.c b/linearize.c
index 1899978..7d57474 100644
--- a/linearize.c
+++ b/linearize.c
@@ -1195,6 +1195,7 @@ static pseudo_t linearize_call_expression(struct entrypoint *ep, struct expressi
 	struct instruction *insn = alloc_typed_instruction(OP_CALL, expr->ctype);
 	pseudo_t retval, call;
 	struct ctype *ctype = NULL;
+	struct symbol *fntype;
 	struct context *context;
 
 	if (!expr->ctype) {
@@ -1212,6 +1213,13 @@ static pseudo_t linearize_call_expression(struct entrypoint *ep, struct expressi
 	if (fn->ctype)
 		ctype = &fn->ctype->ctype;
 
+	fntype = fn->ctype;
+	if (fntype) {
+		if (fntype->type == SYM_NODE)
+			fntype = fntype->ctype.base_type;
+	}
+	insn->fntype = fntype;
+
 	if (fn->type == EXPR_PREOP) {
 		if (fn->unop->type == EXPR_SYMBOL) {
 			struct symbol *sym = fn->unop->symbol;
diff --git a/linearize.h b/linearize.h
index 424ba97..61fbd83 100644
--- a/linearize.h
+++ b/linearize.h
@@ -116,6 +116,7 @@ struct instruction {
 		struct /* call */ {
 			pseudo_t func;
 			struct pseudo_list *arguments;
+			struct symbol *fntype;
 		};
 		struct /* context */ {
 			int increment;
-- 
1.7.6.4


             reply	other threads:[~2012-02-01  9:56 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-01  9:55 Pekka Enberg [this message]
2012-02-01  9:55 ` [RFC/PATCH 2/2] sparse, llvm: Fix varargs functions Pekka Enberg
2012-02-01 10:47   ` Benjamin Herrenschmidt
2012-02-01 13:58     ` Jeff Garzik
2012-02-02  0:09 ` [RFC/PATCH 1/2] sparse, llvm: Make function declaration accessible to backend Christopher Li
2012-02-02  0:54   ` Benjamin Herrenschmidt
2012-02-02  6:28     ` Pekka Enberg
2012-02-02  1:03   ` Jeff Garzik
2012-02-02  1:22     ` Benjamin Herrenschmidt
2012-02-02  1:33       ` Christopher Li
2012-02-02  1:50         ` Benjamin Herrenschmidt
2012-02-02  2:10           ` Christopher Li
2012-02-03  9:09             ` Pekka Enberg
2012-02-03 11:31               ` Benjamin Herrenschmidt
2012-02-04 12:20               ` Christopher Li
2012-02-04 12:56                 ` Pekka Enberg
2012-02-04 15:27                   ` Linus Torvalds
2012-02-04 15:34                     ` Pekka Enberg
2012-02-02  1:22     ` Christopher Li

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=1328090152-28299-1-git-send-email-penberg@kernel.org \
    --to=penberg@kernel.org \
    --cc=benh@kernel.crashing.org \
    --cc=jgarzik@redhat.com \
    --cc=linux-sparse@vger.kernel.org \
    --cc=sparse@chrisli.org \
    --cc=torvalds@linux-foundation.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 NNTP newsgroup(s).