[llvm-commits] Struct-handling patches

Duncan Sands baldrick at free.fr
Wed Oct 1 01:21:52 PDT 2008


Hi,

> > I agree with Duncan that this doesn't sound safe in the case of
> > structs with holes.
> Yeah, I hadn't thought of that. However, doesn't this problem arise in case of
> a memcpy of a {double}. I'm completely unsure of how this works, but if double
> is the same as fp80, ie a 10 byte value, and the struct, and thus a memcpy of
> it, gets a size of 16 bytes (due to alignment?), then replacing sucy a memcpy
> with load + store will skip the 6-byte hole at the end of the struct, right?
> It might very well be that any or all of the assumptions in the above are
> wrong, though.

the HasPadding method takes care of this.  For x86 long double it's taken
care of by this line:

  return TD.getTypeSizeInBits(Ty) != TD.getABITypeSizeInBits(Ty);

The LHS is 80, the RHS is 96 or 128 depending on the platform.

Ciao,

Duncan.



More information about the llvm-commits mailing list