Re: C struct Ordering Rules (Bill Leonard)
Tue, 1 Nov 1994 22:00:41 GMT

          From comp.compilers

Related articles
CProf cache profiling system available (1994-10-13)
Re: C struct Ordering Rules (Re: Data Structure Reorganizing Optimizat (1994-10-27)
Re: C struct Ordering Rules (1994-10-31)
Re: C struct Ordering Rules (1994-10-31)
Re: C struct Ordering Rules (1994-11-01)
Re: C struct Ordering Rules (1994-11-01)
Re: C struct Ordering Rules (1994-11-01)
| List of all articles for this month |

Newsgroups: comp.arch,comp.compilers
From: (Bill Leonard)
Keywords: C, design, optimize
Organization: Harris Computer Systems, Ft. Lauderdale FL
References: 94-10-108 94-10-160
Date: Tue, 1 Nov 1994 22:00:41 GMT (Barton C. Massey) writes:
> All this said, I too would like to see field rearrangement.
> There's several possibilities: my favorite suggestion is to
> forbid rearrangement to move fields past non-volatile fields
> (i.e. treat them as tombstones), and to force volatile structs
> to be completely unpadded and in order (possibly necessitating
> structure packing and unpacking across assignment).

Unfortunately, "volatile" is a pretty big sledgehammer to use just to get
field placement the way you want it. Declaring objects volatile disables
lots of useful optimizations that have nothing to do with structure-field
placement, such as elimination of redundant loads, common subexpression
elimination, and dead store elimination. That's a lot to give up just so I
can make the compiler lay out the structure the way I wanted.

As Robert Bedichek pointed out in a related article, lots of code would
break as a result of different compilations doing different structure
layouts. In practice, how would you make sure that compiling two source
files, which will eventually be linked together, get the same layout of the
same structure? You can't unless the compiler sees the whole program, I
think, and even then there is the operating system to consider, which is
*certainly* going to be compiled separately.

To put this another way, on what would you base your structure
rearrangement optimizations?

Bill Leonard
Harris Computer Systems Corporation
2101 W. Cypress Creek Road
Fort Lauderdale, FL 33309

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.