All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christopher Li <sparse@chrisli.org>
To: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Cc: Linux-Sparse <linux-sparse@vger.kernel.org>,
	Dibyendu Majumdar <mobile@majumdar.org.uk>,
	Jeff Garzik <jeff@garzik.org>
Subject: Re: [PATCH 06/13] llvm: fix type of literal integer passed as arguments
Date: Mon, 6 Mar 2017 22:56:29 +0800	[thread overview]
Message-ID: <CANeU7Qn7XP18dexKFNiD34SFEATVMEQ8TJ=jV3DFeAyr_O58AQ@mail.gmail.com> (raw)
In-Reply-To: <20170305112047.3411-7-luc.vanoostenryck@gmail.com>

On Sun, Mar 5, 2017 at 7:20 PM, Luc Van Oostenryck
<luc.vanoostenryck@gmail.com> wrote:
> Like for all others instructions, LLVM needs the type
> of each operands. However this information is not always
> available via the pseudo, like here when passing a integer
> constant as argument since for sparse constants are typeless.
>
> Fix this by getting the type via the function prototype.
>
> Reported-by: Dibyendu Majumdar <mobile@majumdar.org.uk>
> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
> ---
>  sparse-llvm.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/sparse-llvm.c b/sparse-llvm.c
> index c593f831f..27cc1b88c 100644
> --- a/sparse-llvm.c
> +++ b/sparse-llvm.c
> @@ -740,7 +740,16 @@ static void output_op_call(struct function *fn, struct instruction *insn)

Adding CC to Jeff Garzik,

I notice a near by line in the same function does:

FOR_EACH_PTR(insn->arguments, arg) {
                  n_arg++;
} END_FOR_EACH_PTR(arg);

Shouldn't it just use ptr_list_size() instead?

>
>         i = 0;
>         FOR_EACH_PTR(insn->arguments, arg) {
> -               args[i++] = pseudo_to_value(fn, insn, arg);
> +               LLVMValueRef value;
> +               if (arg->type == PSEUDO_VAL) {
> +                       /* Value pseudos do not have type information. */
> +                       /* Use the function prototype to get the type. */
> +                       struct symbol *ctype = get_nth1_arg(insn->func->sym, i + 1);

Here is an usage case of iterate through two separate list in order.
You can use PREPARE_PTR_LIST() and NEXT_PTR_LIST()
with FOR_EACH_PTR() to iterate the ins->func->sym list in order.

You can take a look at evaluate.c how to use PREPARE_PTR_LIST
with FOR_EACH_PTR().  e.g. evaluate.c::evaluate_arguments().

If we use get_nth1_arg here. We are effectively using two for loops.
The outer loop count from one to nth argument. The inner loop in
get_nth1_arg() count from one to nth argument again.

Using PREPARE_PTR_LIST(), it has just one loop.

Chris

  reply	other threads:[~2017-03-06 15:05 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-05 11:20 [WIP 00/13] LLVM fixes Luc Van Oostenryck
2017-03-05 11:20 ` [PATCH 01/13] llvm: add a helper to convert an integer to a ValueRef Luc Van Oostenryck
2017-03-05 11:20 ` [PATCH 02/13] llvm: fix translation of PSEUDO_VALs into a ValueRefs Luc Van Oostenryck
2017-03-07 15:11   ` Christopher Li
2017-03-07 16:18     ` Luc Van Oostenryck
2017-03-07 22:48       ` Christopher Li
2017-03-05 11:20 ` [PATCH 03/13] llvm: fix output_op_store() which modify its operand Luc Van Oostenryck
2017-03-05 11:20 ` [PATCH 04/13] llvm: fix output_op_[ptr]cast() Luc Van Oostenryck
2017-03-05 11:20 ` [PATCH 05/13] add get_nth1_arg() Luc Van Oostenryck
2017-03-06 14:40   ` Christopher Li
2017-03-06 16:52     ` Luc Van Oostenryck
2017-03-05 11:20 ` [PATCH 06/13] llvm: fix type of literal integer passed as arguments Luc Van Oostenryck
2017-03-06 14:56   ` Christopher Li [this message]
2017-03-07 15:33   ` Christopher Li
2017-03-07 16:21     ` Luc Van Oostenryck
2017-03-07 19:41     ` Dibyendu Majumdar
2017-03-10 16:08       ` Dibyendu Majumdar
2017-03-10 17:47         ` Luc Van Oostenryck
2017-03-05 11:20 ` [PATCH 07/13] llvm: fix output OP_ADD mixed with pointers Luc Van Oostenryck
2017-03-06 15:16   ` Christopher Li
2017-03-06 15:32     ` Dibyendu Majumdar
2017-03-06 16:22       ` Christopher Li
2017-03-06 16:43         ` Luc Van Oostenryck
2017-03-06 17:06           ` Dibyendu Majumdar
2017-03-06 19:50             ` Luc Van Oostenryck
2017-03-06 17:07           ` Christopher Li
2017-03-06 19:52             ` Luc Van Oostenryck
2017-03-06 21:15             ` [PATCH v2] " Luc Van Oostenryck
2017-03-06 18:17           ` [PATCH 07/13] " Linus Torvalds
2017-03-06 20:09             ` Luc Van Oostenryck
2017-03-05 11:20 ` [PATCH 08/13] llvm: add support for OP_NEG Luc Van Oostenryck
2017-03-05 11:20 ` [PATCH 09/13] give a type to OP_PHISOURCE Luc Van Oostenryck
2017-03-05 11:20 ` [PATCH 10/13] give a type to OP_SEL, always Luc Van Oostenryck
2017-03-05 11:20 ` [PATCH 11/13] llvm: remove unneeded arg 'module' Luc Van Oostenryck
2017-03-05 11:20 ` [PATCH 12/13] llvm: remove unneeded arg 'fn' Luc Van Oostenryck
2017-03-05 11:20 ` [PATCH 13/13] llvm: fix: do not mix pointers and floats when doing compares Luc Van Oostenryck
2017-03-06  1:47 ` [WIP 00/13] LLVM fixes 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='CANeU7Qn7XP18dexKFNiD34SFEATVMEQ8TJ=jV3DFeAyr_O58AQ@mail.gmail.com' \
    --to=sparse@chrisli.org \
    --cc=jeff@garzik.org \
    --cc=linux-sparse@vger.kernel.org \
    --cc=luc.vanoostenryck@gmail.com \
    --cc=mobile@majumdar.org.uk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.