All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: Dibyendu Majumdar <mobile@majumdar.org.uk>
Cc: Linux-Sparse <linux-sparse@vger.kernel.org>
Subject: Re: sparse-llvm incorrect handling of function pointers
Date: Fri, 10 Mar 2017 18:44:46 +0100	[thread overview]
Message-ID: <20170310174445.4fmyibgvl7yyaz2s@macbook.local> (raw)
In-Reply-To: <CACXZuxeHAXK11Tyx0PSg_uqDo0rZ3Cw+aZ5gN1S_LpPMZG8cCQ@mail.gmail.com>

On Fri, Mar 10, 2017 at 02:23:26PM +0000, Dibyendu Majumdar wrote:
> Hi,
> 
> This example fails:
> 
> extern int (*f) (int);
> int main(int argc, const char *argv[]) {
>  if (f) {
>   return (*f)(6);
>  }
> }
> 
> The linearized output is:
> 
> main:
> .L0:
>         <entry-point>
>         load.64     %r1(f) <- 0[f]
>         br          %r1(f), .L1, .L3
> .L1:
>         load        %r3 <- 0[%r1(f)]
>         call.32     %r4 <- %r3, $6
>         br          .L3
> .L3:
>         ret.32      %r4
> 
> It is the second load that is failing. Am investigating the cause - it
> seems something to do with calc_memop_addr().

No, it's a problem with the linearized code.
There is no reasons for this second load to even exist.
You can see this by replacing '(*f)(6)' by the equivalent 'f(6)'.

Also you should be careful with this example as there is no
return for the 'else' part which create some undefined value
which can create weirdness.

-- Luc Van Oostenryck

  reply	other threads:[~2017-03-10 17:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-10 14:23 sparse-llvm incorrect handling of function pointers Dibyendu Majumdar
2017-03-10 17:44 ` Luc Van Oostenryck [this message]
2017-03-10 18:13   ` Dibyendu Majumdar
2017-03-11 11:54     ` Luc Van Oostenryck
2017-03-11 11:56       ` Dibyendu Majumdar
2017-03-11 11:58     ` [PATCH] llvm: add script to display the deserialized LLVM IR Luc Van Oostenryck
2017-04-25 20:43       ` Christopher Li
2017-04-26  2:11         ` 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=20170310174445.4fmyibgvl7yyaz2s@macbook.local \
    --to=luc.vanoostenryck@gmail.com \
    --cc=linux-sparse@vger.kernel.org \
    --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.