Re: [PATCH] Re: LLVM and PSEUDO_REG/PSEUDO_PHI

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Aug 28, 2011 at 3:04 AM, Jeff Garzik <jeff@xxxxxxxxxx> wrote:
>
> * need to start integrating struct support.  LLVM has a type system where
> one defines data structures in the IR, then uses 'getelementptr' LLVM
> instruction to build addresses for complex load/store operations. The Linux
> kernel uses a lot of function calls (indirect branches) from values buried
> deep within a struct.

You really shouldn't need to do that.

You should consider all types to be just "blocks of memory", and
sparse has already calculated all offsets etc for you. As far as LLVM
is concerned, the memory has no structure, it's just a blob.

Sometimes you cannot even get the "element" name. Look at
./test-linearize output of something like this:

  struct hello {
    int a,b,c;
  };

  int bar(struct hello *arg)
  {
	return ((char *)&arg->b)[1] + arg->c;
  }

and realize that that byte access isn't accessing an element at all -
it's just accessing a *part* of an element. The more complicated cases
is actually when you access multiple elements in one go.

And sparse has figured all that out for you already, done the alias
analysis (ok, just stupid overlap analysis) etc.

Btw, if you look at test-linearize output for that, you'll see the
"ptrcast" thing. We don't simplify that away, so you will see
something like

	add.32      %r2 <- %arg1, $4
	ptrcast.32  %r3 <- (32) %r2
	load.8      %r4 <- 1[%r3]

instead of just

	load.8      %r4 <- 5[%arg1]

but that's just a small "I left all pointer casts around, even if they
don't do anything" detail.

                           Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux