m68k structure packing

Jim Wilson wilson@cygnus.com
Tue Sep 30 18:20:00 GMT 1997


	I would be interested in any such cases that you know of.

It will happen for the m68k ports, of course, which are the ones that you
are trying to fix.

This problem has been discussed before, and is well known.  There are many
places in the code that document it.  See in particular the discussion
of PCC_BITFIELD_TYPE_MATTERS in the tm.texi file.

Note that most m68k ports do not define PCC_BITFIELD_TYPE_MATTERS, and hence
must define STRUCTURE_SIZE_BOUNDARY to >=16, and hence must not allow structure
packing.

The m68kemb.h file goes the other way, defining PCC_BITFIELD_TYPE_MATTERS,
and defining STRUCTURE_SIZE_BOUNDARY to 8, and hence does allow structure
packing.  If you want structure packing, this is what you should do.

	Why do you think generated code will fail? 

Because I have seen the problem before, and I have seen it so many times
that it falls into the category of things that are obvious to me, but which
I can't easily explain because I forgot the reasons for it long ago.

My recollection is that it will only fail if you compile for the 68000,
because the 68000 has no bit field instructions, and requires 2 byte alignment
for non-byte loads/stores.  (As per the PCC_BITFIELD_TYPE_MATTERS
documentation.) Most other 68k family members do not have both these
restrictions.

	Further, Kamil has claimed that the
	amiga m68k port works fine with STRUCTURE_SIZE_BOUNDARY as 8.

It will appear to work fine until you trigger the bug.  Obviously, he did
not try any testcase that would trigger the bug.  Probably because he did
not test on a m68000.

	Maybe if you describe that case I
	can hunt for it.

I believe it has already been described:

>From: Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
>The only place where it can fail is on a STRICT_ALIGNMENT target when
>using a packed structure in an array.

	I think that in the absence a bug that can be reproduced,

Unfortunately, you are putting the burden in the wrong place.  I am much
busier than you, and do not have time to search for a testcase to reproduce
a bug that I already know exists.  I would prefer that you put some effort into
demonstrating that the known bug does not exist with your patch.  It
should be easy to prove or disprove this with some simple experimentation.

First demonstrate the problem that exists as per the PCC_BITFIELD_TYPE_MATTERS
documentation.  Then check to see if your patch triggers this bug.  I believe
that it does.

Because the patch is already in the FSF gcc sources, it will probably also
be added to the EGCS sources.  However, I think it is important for you
to understand that this is not the `bug fix' patch that you think it is.
What this patch does is trade one set of complex problems for a different
set of complex problems, and it is not clear which set of problems is worse.
After we do install the patch, we may end up needing to remove it if the new
set of problems are worse than the old set.

Jim



More information about the Gcc mailing list