On 08/28/2011 01:04 PM, Linus Torvalds wrote:
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.
We _already_ do this in the backend, and LLVM supports
LOAD-from-random-address just fine:
https://github.com/penberg/sparse-llvm/blob/master/sparse-llvm.c#L325
But that comment was thinking more medium term, supporting multiple
platforms means properly handling struct layout in memory, which gets
into the realm of platform-specific ABIs.
It didn't seem like we would want to encode a ton of ABI detail into the
sparse C front-end. But it sounds like there will be a lot of ABI
detail found, if sparse is doing all the memory layout and such.
Sometimes you cannot even get the "element" name. Look at
./test-linearize output of something like this:
Nobody cares about the element name, least of all LLVM. LLVM provides a
convenience naming feature, but you don't have to use that.
ABI-dictated memory layout is the main detail to get right, across
platforms.
Jeff
--
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