From: Dibyendu Majumdar <mobile@majumdar.org.uk>
To: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>,
Christopher Li <sparse@chrisli.org>
Cc: Linux-Sparse <linux-sparse@vger.kernel.org>
Subject: Re: Question about Sparse Linear form and pseudos
Date: Sun, 20 Aug 2017 17:12:21 +0100 [thread overview]
Message-ID: <CACXZuxenUKprEMjScasEMZNxYDFGeSy8soPpYxbDbd+1kWHY1w@mail.gmail.com> (raw)
In-Reply-To: <20170820151513.ddoxdwo7iwd2nefh@ltop.local>
Hi Luc,
On 20 August 2017 at 16:15, Luc Van Oostenryck
<luc.vanoostenryck@gmail.com> wrote:
> On Sun, Aug 20, 2017 at 03:54:47PM +0100, Dibyendu Majumdar wrote:
>> I am trying to get to grips with the Sparse Linear format and the use
>> of pseudos.
>>
>> 1) A Sparse document says that pseudos are akin to SSA variables. Is
>> that a true statement - i.e. do pseudos follow the discipline that
>> only one assignment to a pseudo is allowed. As pseudos have also
>> different sub-types - does this statement apply to all pseudo types or
>> only some sub types?
>>
>> 2) In a recent conversation it was stated that the baseline Linear
>> output from Sparse is already in SSA form. That implies that all
>> pseudos used are in SSA form already. However we know that in the
>> baseline line IR phi nodes may not be present. In LLVM the initial IR
>> lacks phi nodes too - instead local stack memory and load/store
>> sequences are used. However LLVM IR is still SSA at this stage. When
>> it is said that the baseline Linear IR is already SSA is it in this
>> sense?
>
> One way to answer this with few words is to look at what's happening
> to a variable assigned in different paths in a simple example:
Thank you - it is always good to look at examples.
>
> int f(void);
>
> int foo(int p)
> {
> int a;
>
> if (p) {
> a = 0;
> a++;
> } else {
> a = f();
> }
>
> return a;
> }
>
>
> Just after linearization:
> foo:
> .L0:
> <entry-point>
> store.32 %arg1 -> 0[p]
> load.32 %r1 <- 0[p]
> cbr %r1, .L1, .L2
>
> .L1:
> store.32 $0 -> 0[a]
> load.32 %r2 <- 0[a]
> add.32 %r3 <- %r2, $1
> store.32 %r3 -> 0[a]
> br .L3
>
> .L2:
> call.32 %r4 <- f
> store.32 %r4 -> 0[a]
> br .L3
>
> .L3:
> load.32 %r5 <- 0[a]
> ret.32 %r5
>
Okay the linear output above seems SSA if we consider how it is shown
in the output. But in the code, access to 0[a] occurs via a pseudo -
of type PSEUDO_SYM. We see multiple stores happening to this pseudo.
So the question is each access generated through a different instance
of a pseudo? I see that in the code if a symbol already has a pseudo
then it is reused. So presumably then PSEUDO_SYMs are not SSA, but
PSEUDO_REGs are?
So then is it more accurate to say that PSEUDO_SYM and possibly
PSEUDO_ARG too - represent memory access, and are just a proxy for
stack allocated memory?
Regards
Dibyendu
next prev parent reply other threads:[~2017-08-20 16:12 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-20 14:54 Question about Sparse Linear form and pseudos Dibyendu Majumdar
2017-08-20 15:15 ` Luc Van Oostenryck
2017-08-20 16:12 ` Dibyendu Majumdar [this message]
2017-08-20 16:20 ` Linus Torvalds
2017-08-20 16:26 ` Dibyendu Majumdar
2017-08-20 16:33 ` Linus Torvalds
2017-08-20 16:45 ` Luc Van Oostenryck
2017-09-07 2:22 ` Luc Van Oostenryck
2017-08-20 16:50 ` Dibyendu Majumdar
2017-08-20 18:22 ` Christopher Li
2017-08-20 16:20 ` Christopher Li
2017-08-20 16:40 ` Dibyendu Majumdar
2017-08-20 15:44 ` Christopher Li
2017-08-20 16:18 ` Dibyendu Majumdar
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=CACXZuxenUKprEMjScasEMZNxYDFGeSy8soPpYxbDbd+1kWHY1w@mail.gmail.com \
--to=mobile@majumdar.org.uk \
--cc=linux-sparse@vger.kernel.org \
--cc=luc.vanoostenryck@gmail.com \
--cc=sparse@chrisli.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).