linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Garzik <jeff@garzik.org>
To: Christopher Li <sparse@chrisli.org>
Cc: linux-sparse@vger.kernel.org, Al Viro <viro@zeniv.linux.org.uk>
Subject: Re: sparse: Why test-parse shows "+=" as a store?
Date: Mon, 27 Apr 2009 06:28:10 -0400	[thread overview]
Message-ID: <49F588BA.4060503@garzik.org> (raw)
In-Reply-To: <70318cbf0904262304j3d85f839o5fbd37d48f0e79e8@mail.gmail.com>

Christopher Li wrote:
> On Sun, Apr 26, 2009 at 1:52 PM, Jeff Garzik <jeff@garzik.org> wrote:
>> Consider this testcase:
>>
>> int bloo = 0;
>>
>> void inc_bloo(void)
>> {
>>        bloo += 2;
>> }
>>
> 
> test-linearize show:
> 
> inc_bloo:
> .L0x7fc013df7010:
> 	<entry-point>
> 	load.32     %r1 <- 0[bloo]
> 	add.32      %r3 <- %r1, $2
> 	store.32    %r3 -> 0[bloo]
> 	ret
> 
> 
> get_bloo:
> .L0x7fc013df70a0:
> 	<entry-point>
> 	load.32     %r5 <- 0[bloo]
> 	ret.32      %r5
> 
>> Any idea why?  I'm not sure if this is a tree-walker bug or something from
>> the parsing.  The test-parse output is below...
> 
> So obvious the parser is correct and I will blame your code :-).

I did not write test-parsing / show_symbol_list().

Use of test-parsing eliminates my code as a factor -- which was why I 
mentioned it.

Oh well, I will figure it out.


> This bring the points that you really should make your LLVM converter
> base on the linearized byte code. Being able to convert to LLVM
> byte code is actually one of my consideration when I hack on the linearized
> back end back then. Look, there is even reserved an opcode for
> GET_ELEMENT_PTR. If there is some thing need to change to the linearized
> back end to make this happen, I am glad to do it.
> 
> But I don't want to have yet another linearized equivalent code base in
> sparse. This is duplicated effort. Bugs will need to fix in both place.
> I am pretty sure using the linearized back end will greatly simplify
> your LLVM byte code generation.
> 
> Do you want to give it a try?

linearized output is too low level for LLVM in several cases.  The 
shifts in linearize_load_gen() and linearize_store_gen() get in the way, 
for example.  Having sparse calculate struct offsets itself is also not 
desirable: in order to use LLVM's getelementptr instruction, you should 
instead give LLVM the type information and member indices, and let it 
figure out the address calculation from there.

Thus, use of linearize would imply having to work backwards and recreate 
information lost during the linearization.

The general idea with LLVM bitcode is to pass it type information, and 
it will ensure that bitfields are handled properly, structs are laid out 
and padded properly, function return types handled, etc.  LLVM handles 
all the address generation for us, once we give it enough type info.

	Jeff




  reply	other threads:[~2009-04-27 10:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-26 20:52 sparse: Why test-parse shows "+=" as a store? Jeff Garzik
2009-04-27  6:04 ` Christopher Li
2009-04-27 10:28   ` Jeff Garzik [this message]
2009-04-27 17:45     ` Christopher Li
2009-04-27 17:53       ` Christopher Li
2009-04-27 22:57       ` Jeff Garzik
2009-04-27 23:39         ` Christopher Li
2009-04-28  0:24           ` Jeff Garzik

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=49F588BA.4060503@garzik.org \
    --to=jeff@garzik.org \
    --cc=linux-sparse@vger.kernel.org \
    --cc=sparse@chrisli.org \
    --cc=viro@zeniv.linux.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 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).